Skip to content

Commit

Permalink
MongoStore.groupby: add tests for sort, skip, limit
Browse files Browse the repository at this point in the history
  • Loading branch information
rkingsbury committed May 27, 2022
1 parent 2fb2981 commit c30d05c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/stores/test_mongolike.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,21 @@ def test_mongostore_connect_reconnect():

def test_mongostore_query(mongostore):
mongostore._collection.insert_one({"a": 1, "b": 2, "c": 3})
mongostore._collection.insert_one({"a": 2, "b": 2, "c": 3})
mongostore._collection.insert_one({"a": 4, "b": 5, "e": 6, "g": {"h": 1}})
assert mongostore.query_one(properties=["a"])["a"] == 1
assert mongostore.query_one(properties=["a"])["a"] == 1
assert mongostore.query_one(properties=["b"])["b"] == 2
assert mongostore.query_one(properties=["c"])["c"] == 3

# the whole document should be returned when properties=None
assert all([d.get('a') for d in mongostore.query()])
assert all([d.get('b') for d in mongostore.query()])

# test sort, skip, limit
assert len(list(mongostore.query(limit=2))) == 2
assert len(list(mongostore.query(skip=1))) == 2
assert list(mongostore.query(sort={"g": -1}))[0].get('e')

def test_mongostore_count(mongostore):
mongostore._collection.insert_one({"a": 1, "b": 2, "c": 3})
Expand Down

0 comments on commit c30d05c

Please sign in to comment.