Skip to content

Commit 6ab90bf

Browse files
authored
Tests legacy (#135)
* tests included in the test_operators / tests_accumulators forder * testing functions in the accumulator folder * tests arithmetic folder passed and completed * tests_array folder passed and completed * tests_boolean folder passed and completed * tests_comparison folder passed and completed * tests_conditional folder passed and completed * tests_date folder passed and completed * tests_objects folder passed and completed * tests_type_ & tests_strings passed and completed
1 parent a8676ee commit 6ab90bf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+656
-19
lines changed

tests/tests_monggregate/tests_operators/tests_accumulators/test_avg.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
"""Tests for `monggregate.operators.accumulators.avg` module."""
22

3-
from monggregate.operators.accumulators.avg import Average
3+
from monggregate.operators.accumulators.avg import Average, avg
44

5+
def test_avg_expression():
6+
# Setup
7+
expected_expression = {
8+
"$avg": None
9+
}
10+
11+
# Act
12+
avg_op = Average()
13+
result_expression = avg_op.expression
14+
15+
# Assert
16+
assert result_expression == expected_expression
517

618
class TestAverage:
719
"""Tests for `Average` class."""
@@ -15,4 +27,4 @@ def test_expression(self) -> None:
1527
"""Test that `Average` class returns the correct expression."""
1628

1729
average = Average(operand=1)
18-
assert average.expression == {"$avg": 1}
30+
assert average.expression == {"$avg": 1}

tests/tests_monggregate/tests_operators/tests_accumulators/test_count.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
11
"""Tests for `monggregate.operators.accumulators.count` module."""
22

3-
from monggregate.operators.accumulators.count import Count
3+
import pytest
4+
from monggregate.operators.accumulators.count import Count, count
45

6+
def test_count_expression():
7+
# Setup
8+
expected_expression = {
9+
"$count": {}
10+
}
11+
12+
# Act
13+
count_op = count()
14+
result_expression = count_op.expression
15+
16+
# Assert
17+
assert result_expression == expected_expression
518

619
class TestCount:
720
"""Tests for `Count` class."""
@@ -14,4 +27,4 @@ def test_instantiation(self) -> None:
1427
def test_expression(self) -> None:
1528
"""Test that `Count` class returns the correct expression."""
1629
count_op = Count()
17-
assert count_op.expression == {"$count": {}}
30+
assert count_op.expression == {"$count": {}}

tests/tests_monggregate/tests_operators/tests_accumulators/test_first.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
"""Tests for `monggregate.operators.accumulators.first` module."""
22

3-
from monggregate.operators.accumulators.first import First
3+
import pytest
4+
from monggregate.operators.accumulators.first import First, first
5+
6+
def test_first_expression():
7+
# Setup
8+
operand = "$someField"
9+
expected_expression = {
10+
"$first": operand
11+
}
12+
13+
# Act
14+
first_op = first(operand)
15+
result_expression = first_op.expression
16+
17+
# Assert
18+
assert result_expression == expected_expression
419

520

621
class TestFirst:
@@ -14,4 +29,4 @@ def test_instantiation(self) -> None:
1429
def test_expression(self) -> None:
1530
"""Test that `First` class returns the correct expression."""
1631
first_op = First(operand=1)
17-
assert first_op.expression == {"$first": 1}
32+
assert first_op.expression == {"$first": 1}

tests/tests_monggregate/tests_operators/tests_accumulators/test_last.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
"""Tests for `monggregate.operators.accumulators.last` module."""
22

3-
from monggregate.operators.accumulators.last import Last
3+
import pytest
4+
from monggregate.operators.accumulators.last import Last, last
5+
6+
def test_last_expression():
7+
# Setup
8+
operand = "$someField"
9+
expected_expression = {
10+
"$last": operand
11+
}
12+
13+
# Act
14+
last_op = last(operand)
15+
result_expression = last_op.expression
16+
17+
# Assert
18+
assert result_expression == expected_expression
419

520

621
class TestLast:
@@ -14,4 +29,4 @@ def test_instantiation(self) -> None:
1429
def test_expression(self) -> None:
1530
"""Test that `Last` class returns the correct expression."""
1631
last_op = Last(operand=1)
17-
assert last_op.expression == {"$last": 1}
32+
assert last_op.expression == {"$last": 1}

tests/tests_monggregate/tests_operators/tests_accumulators/test_max.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
"""Tests for `monggregate.operators.accumulators.max` module."""
22

3-
from monggregate.operators.accumulators.max import Max
3+
import pytest
4+
from monggregate.operators.accumulators.max import Max, max
5+
6+
def test_max_expression():
7+
# Setup
8+
operand = "$someNumericField"
9+
expected_expression = {
10+
"$max": operand
11+
}
12+
13+
# Act
14+
max_op = max(operand)
15+
result_expression = max_op.expression
16+
17+
# Assert
18+
assert result_expression == expected_expression
419

520

621
class TestMax:
@@ -14,4 +29,4 @@ def test_instantiation(self) -> None:
1429
def test_expression(self) -> None:
1530
"""Test that `Max` class returns the correct expression."""
1631
max_op = Max(operand=1)
17-
assert max_op.expression == {"$max": 1}
32+
assert max_op.expression == {"$max": 1}

tests/tests_monggregate/tests_operators/tests_accumulators/test_min.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
"""Tests for `monggregate.operators.accumulators.min` module."""
22

3-
from monggregate.operators.accumulators.min import Min
3+
import pytest
4+
from monggregate.operators.accumulators.min import Min, min
5+
6+
def test_min_expression():
7+
# Setup
8+
operand = "$someNumericField"
9+
expected_expression = {
10+
"$min": operand
11+
}
12+
13+
# Act
14+
min_op = min(operand)
15+
result_expression = min_op.expression
16+
17+
# Assert
18+
assert result_expression == expected_expression
419

520

621
class TestMin:
@@ -14,4 +29,4 @@ def test_instantiation(self) -> None:
1429
def test_expression(self) -> None:
1530
"""Test that `Min` class returns the correct expression."""
1631
min_op = Min(operand=1)
17-
assert min_op.expression == {"$min": 1}
32+
assert min_op.expression == {"$min": 1}

tests/tests_monggregate/tests_operators/tests_accumulators/test_push.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
"""Tests for `monggregate.operators.accumulators.push` module."""
22

3-
from monggregate.operators.accumulators.push import Push
3+
import pytest
4+
from monggregate.operators.accumulators.push import Push, push
5+
6+
def test_push_expression():
7+
# Setup
8+
operand = "$someField"
9+
expected_expression = {
10+
"$push": operand
11+
}
12+
13+
# Act
14+
push_op = push(operand)
15+
result_expression = push_op.expression
16+
17+
# Assert
18+
assert result_expression == expected_expression
419

520

621
class TestPush:
@@ -14,4 +29,4 @@ def test_instantiation(self) -> None:
1429
def test_expression(self) -> None:
1530
"""Test that `Push` class returns the correct expression."""
1631
push_op = Push(operand=1)
17-
assert push_op.expression == {"$push": 1}
32+
assert push_op.expression == {"$push": 1}

tests/tests_monggregate/tests_operators/tests_accumulators/test_sum.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
"""Tests for `monggregate.operators.accumulators.sum` module."""
22

3-
from monggregate.operators.accumulators.sum import Sum
3+
import pytest
4+
from monggregate.operators.accumulators.sum import Sum, sum
5+
6+
def test_sum_operand():
7+
# Setup
8+
operand = "$amount"
9+
10+
# Act
11+
result_op = {"$sum": operand}
12+
expected_expression = {"$sum": "$amount"}
13+
14+
# Assert
15+
assert result_op == expected_expression
416

517

618
class TestSum:
@@ -14,4 +26,4 @@ def test_instantiation(self) -> None:
1426
def test_expression(self) -> None:
1527
"""Test that `Sum` class returns the correct expression."""
1628
sum_op = Sum(operand=1)
17-
assert sum_op.expression == {"$sum": 1}
29+
assert sum_op.expression == {"$sum": 1}

tests/tests_monggregate/tests_operators/tests_arithmetic/test_add.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
from monggregate.operators.arithmetic.add import Add
44

5+
def test_add_expression():
6+
# Setup
7+
operands = [1, 2, 3]
8+
expected_expression = {"$add": operands}
9+
10+
# Act
11+
add_op = Add(operands=operands)
12+
result_expression = add_op.expression
13+
14+
# Assert
15+
assert result_expression == expected_expression
16+
517

618
class TestAdd:
719
"""Tests for `Add` class."""

tests/tests_monggregate/tests_operators/tests_arithmetic/test_divide.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22

33
from monggregate.operators.arithmetic.divide import Divide
44

5+
def test_divide_expression():
6+
# Setup
7+
numerator = 10
8+
denominator = 2
9+
expected_expression = {"$divide": [numerator, denominator]}
10+
11+
# Act
12+
divide_op = Divide(numerator=numerator, denominator=denominator)
13+
result_expression = divide_op.expression
14+
15+
# Assert
16+
assert result_expression == expected_expression
17+
518

619
class TestDivide:
720
"""Tests for `Divide` class."""

0 commit comments

Comments
 (0)