Skip to content

Commit a8676ee

Browse files
authored
128-revival-add-operators-tests (#136)
* Move test_operators under tests_monggregate * test average example * Add accumulators tests * tests_arithmetic and tests_arrays * Add main operators tests
1 parent 47ec290 commit a8676ee

Some content is hidden

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

44 files changed

+869
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"""Tests for `monggregate.operators.accumulators.avg` module."""
2+
3+
from monggregate.operators.accumulators.avg import Average
4+
5+
6+
class TestAverage:
7+
"""Tests for `Average` class."""
8+
9+
def test_instantiation(self) -> None:
10+
"""Test that `Average` class can be instantiated."""
11+
average = Average(operand=1)
12+
assert isinstance(average, Average)
13+
14+
def test_expression(self) -> None:
15+
"""Test that `Average` class returns the correct expression."""
16+
17+
average = Average(operand=1)
18+
assert average.expression == {"$avg": 1}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""Tests for `monggregate.operators.accumulators.count` module."""
2+
3+
from monggregate.operators.accumulators.count import Count
4+
5+
6+
class TestCount:
7+
"""Tests for `Count` class."""
8+
9+
def test_instantiation(self) -> None:
10+
"""Test that `Count` class can be instantiated."""
11+
count_op = Count()
12+
assert isinstance(count_op, Count)
13+
14+
def test_expression(self) -> None:
15+
"""Test that `Count` class returns the correct expression."""
16+
count_op = Count()
17+
assert count_op.expression == {"$count": {}}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""Tests for `monggregate.operators.accumulators.first` module."""
2+
3+
from monggregate.operators.accumulators.first import First
4+
5+
6+
class TestFirst:
7+
"""Tests for `First` class."""
8+
9+
def test_instantiation(self) -> None:
10+
"""Test that `First` class can be instantiated."""
11+
first_op = First(operand=1)
12+
assert isinstance(first_op, First)
13+
14+
def test_expression(self) -> None:
15+
"""Test that `First` class returns the correct expression."""
16+
first_op = First(operand=1)
17+
assert first_op.expression == {"$first": 1}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""Tests for `monggregate.operators.accumulators.last` module."""
2+
3+
from monggregate.operators.accumulators.last import Last
4+
5+
6+
class TestLast:
7+
"""Tests for `Last` class."""
8+
9+
def test_instantiation(self) -> None:
10+
"""Test that `Last` class can be instantiated."""
11+
last_op = Last(operand=1)
12+
assert isinstance(last_op, Last)
13+
14+
def test_expression(self) -> None:
15+
"""Test that `Last` class returns the correct expression."""
16+
last_op = Last(operand=1)
17+
assert last_op.expression == {"$last": 1}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""Tests for `monggregate.operators.accumulators.max` module."""
2+
3+
from monggregate.operators.accumulators.max import Max
4+
5+
6+
class TestMax:
7+
"""Tests for `Max` class."""
8+
9+
def test_instantiation(self) -> None:
10+
"""Test that `Max` class can be instantiated."""
11+
max_op = Max(operand=1)
12+
assert isinstance(max_op, Max)
13+
14+
def test_expression(self) -> None:
15+
"""Test that `Max` class returns the correct expression."""
16+
max_op = Max(operand=1)
17+
assert max_op.expression == {"$max": 1}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""Tests for `monggregate.operators.accumulators.min` module."""
2+
3+
from monggregate.operators.accumulators.min import Min
4+
5+
6+
class TestMin:
7+
"""Tests for `Min` class."""
8+
9+
def test_instantiation(self) -> None:
10+
"""Test that `Min` class can be instantiated."""
11+
min_op = Min(operand=1)
12+
assert isinstance(min_op, Min)
13+
14+
def test_expression(self) -> None:
15+
"""Test that `Min` class returns the correct expression."""
16+
min_op = Min(operand=1)
17+
assert min_op.expression == {"$min": 1}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""Tests for `monggregate.operators.accumulators.push` module."""
2+
3+
from monggregate.operators.accumulators.push import Push
4+
5+
6+
class TestPush:
7+
"""Tests for `Push` class."""
8+
9+
def test_instantiation(self) -> None:
10+
"""Test that `Push` class can be instantiated."""
11+
push_op = Push(operand=1)
12+
assert isinstance(push_op, Push)
13+
14+
def test_expression(self) -> None:
15+
"""Test that `Push` class returns the correct expression."""
16+
push_op = Push(operand=1)
17+
assert push_op.expression == {"$push": 1}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""Tests for `monggregate.operators.accumulators.sum` module."""
2+
3+
from monggregate.operators.accumulators.sum import Sum
4+
5+
6+
class TestSum:
7+
"""Tests for `Sum` class."""
8+
9+
def test_instantiation(self) -> None:
10+
"""Test that `Sum` class can be instantiated."""
11+
sum_op = Sum(operand=1)
12+
assert isinstance(sum_op, Sum)
13+
14+
def test_expression(self) -> None:
15+
"""Test that `Sum` class returns the correct expression."""
16+
sum_op = Sum(operand=1)
17+
assert sum_op.expression == {"$sum": 1}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""Tests for `monggregate.operators.arithmetic.add` module."""
2+
3+
from monggregate.operators.arithmetic.add import Add
4+
5+
6+
class TestAdd:
7+
"""Tests for `Add` class."""
8+
9+
def test_instantiation(self) -> None:
10+
"""Test that `Add` class can be instantiated."""
11+
add_op = Add(operands=[1, 2, 3])
12+
assert isinstance(add_op, Add)
13+
14+
def test_expression(self) -> None:
15+
"""Test that `Add` class returns the correct expression."""
16+
add_op = Add(operands=[1, 2, 3])
17+
assert add_op.expression == {"$add": [1, 2, 3]}

0 commit comments

Comments
 (0)