From 9f8327926d3fa4f7559834a899bfc998371cfeb1 Mon Sep 17 00:00:00 2001 From: Emmanuel Leblond Date: Thu, 28 Jan 2016 18:18:51 +0100 Subject: [PATCH] Improve a bit queryset's test_elem_match --- tests/queryset/queryset.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/queryset/queryset.py b/tests/queryset/queryset.py index 87c14757..a9a2536a 100644 --- a/tests/queryset/queryset.py +++ b/tests/queryset/queryset.py @@ -4114,6 +4114,10 @@ class QuerySetTest(unittest.TestCase): Foo(shape="circle", color="purple", thick=False)]) b2.save() + b3 = Bar(foo=[Foo(shape="square", thick=True), + Foo(shape="circle", color="purple", thick=False)]) + b3.save() + ak = list( Bar.objects(foo__match={'shape': "square", "color": "purple"})) self.assertEqual([b1], ak) @@ -4133,6 +4137,13 @@ class QuerySetTest(unittest.TestCase): Bar.objects(foo__match={'shape': "square", "color__exists": True})) self.assertEqual([b1, b2], ak) + ak = list( + Bar.objects(foo__elemMatch={'shape': "square", "color__exists": False})) + self.assertEqual([b3], ak) + + ak = list( + Bar.objects(foo__match={'shape': "square", "color__exists": False})) + self.assertEqual([b3], ak) def test_upsert_includes_cls(self): """Upserts should include _cls information for inheritable classes