From c30d05c805643031e38b06c314800bd836400e99 Mon Sep 17 00:00:00 2001 From: Ryan Kingsbury Date: Fri, 27 May 2022 11:56:47 -0700 Subject: [PATCH] MongoStore.groupby: add tests for sort, skip, limit --- tests/stores/test_mongolike.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/stores/test_mongolike.py b/tests/stores/test_mongolike.py index 2cb33cab8..ec7c06db1 100644 --- a/tests/stores/test_mongolike.py +++ b/tests/stores/test_mongolike.py @@ -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})