Beispiel #1
0
 def test_include_include(self):
     q = QueryFieldList()
     q += QueryFieldList(fields=["a", "b"],
                         value=QueryFieldList.ONLY,
                         _only_called=True)
     self.assertEqual(q.as_dict(), {"a": 1, "b": 1})
     q += QueryFieldList(fields=["b", "c"], value=QueryFieldList.ONLY)
     self.assertEqual(q.as_dict(), {"a": 1, "b": 1, "c": 1})
Beispiel #2
0
 def test_include_include(self):
     q = QueryFieldList()
     q += QueryFieldList(fields=['a', 'b'],
                         value=QueryFieldList.ONLY,
                         _only_called=True)
     self.assertEqual(q.as_dict(), {'a': 1, 'b': 1})
     q += QueryFieldList(fields=['b', 'c'], value=QueryFieldList.ONLY)
     self.assertEqual(q.as_dict(), {'a': 1, 'b': 1, 'c': 1})
Beispiel #3
0
 def test_reset(self):
     q = QueryFieldList(always_include=["x", "y"])
     q += QueryFieldList(fields=["a", "b", "x"], value=QueryFieldList.EXCLUDE)
     q += QueryFieldList(fields=["b", "c"], value=QueryFieldList.ONLY)
     self.assertEqual(q.as_dict(), {"x": 1, "y": 1, "c": 1})
     q.reset()
     self.assertFalse(q)
     q += QueryFieldList(fields=["b", "c"], value=QueryFieldList.ONLY)
     self.assertEqual(q.as_dict(), {"x": 1, "y": 1, "b": 1, "c": 1})
Beispiel #4
0
 def test_reset(self):
     q = QueryFieldList(always_include=['x', 'y'])
     q += QueryFieldList(fields=['a', 'b', 'x'], value=QueryFieldList.EXCLUDE)
     q += QueryFieldList(fields=['b', 'c'], value=QueryFieldList.ONLY)
     self.assertEqual(q.as_dict(), {'x': 1, 'y': 1, 'c': 1})
     q.reset()
     self.assertFalse(q)
     q += QueryFieldList(fields=['b', 'c'], value=QueryFieldList.ONLY)
     self.assertEqual(q.as_dict(), {'x': 1, 'y': 1, 'b': 1, 'c': 1})
Beispiel #5
0
 def test_reset(self):
     q = QueryFieldList(always_include=['x', 'y'])
     q += QueryFieldList(fields=['a', 'b', 'x'], value=QueryFieldList.EXCLUDE)
     q += QueryFieldList(fields=['b', 'c'], value=QueryFieldList.ONLY)
     self.assertEqual(q.as_dict(), {'x': True, 'y': True, 'c': True})
     q.reset()
     self.assertFalse(q)
     q += QueryFieldList(fields=['b', 'c'], value=QueryFieldList.ONLY)
     self.assertEqual(q.as_dict(), {'x': True, 'y': True, 'b': True, 'c': True})
Beispiel #6
0
 def test_reset(self):
     q = QueryFieldList(always_include=["x", "y"])
     q += QueryFieldList(fields=["a", "b", "x"],
                         value=QueryFieldList.EXCLUDE)
     q += QueryFieldList(fields=["b", "c"], value=QueryFieldList.ONLY)
     self.assertEqual(q.as_dict(), {"x": 1, "y": 1, "c": 1})
     q.reset()
     self.assertFalse(q)
     q += QueryFieldList(fields=["b", "c"], value=QueryFieldList.ONLY)
     self.assertEqual(q.as_dict(), {"x": 1, "y": 1, "b": 1, "c": 1})
Beispiel #7
0
 def test_reset(self):
     q = QueryFieldList(always_include=["x", "y"])
     q += QueryFieldList(fields=["a", "b", "x"],
                         value=QueryFieldList.EXCLUDE)
     q += QueryFieldList(fields=["b", "c"], value=QueryFieldList.ONLY)
     assert q.as_dict() == {"x": 1, "y": 1, "c": 1}
     q.reset()
     assert not q
     q += QueryFieldList(fields=["b", "c"], value=QueryFieldList.ONLY)
     assert q.as_dict() == {"x": 1, "y": 1, "b": 1, "c": 1}
Beispiel #8
0
 def test_always_include(self):
     q = QueryFieldList(always_include=['x', 'y'])
     q += QueryFieldList(fields=['a', 'b', 'x'], value=QueryFieldList.EXCLUDE)
     q += QueryFieldList(fields=['b', 'c'], value=QueryFieldList.ONLY)
     self.assertEqual(q.as_dict(), {'x': 1, 'y': 1, 'c': 1})
Beispiel #9
0
 def test_exclude_include(self):
     q = QueryFieldList()
     q += QueryFieldList(fields=["a", "b"], value=QueryFieldList.EXCLUDE)
     self.assertEqual(q.as_dict(), {"a": 0, "b": 0})
     q += QueryFieldList(fields=["b", "c"], value=QueryFieldList.ONLY)
     self.assertEqual(q.as_dict(), {"c": 1})
Beispiel #10
0
 def test_exclude_include(self):
     q = QueryFieldList()
     q += QueryFieldList(fields=["a", "b"], value=QueryFieldList.EXCLUDE)
     assert q.as_dict() == {"a": 0, "b": 0}
     q += QueryFieldList(fields=["b", "c"], value=QueryFieldList.ONLY)
     assert q.as_dict() == {"c": 1}
Beispiel #11
0
 def test_using_a_slice(self):
     q = QueryFieldList()
     q += QueryFieldList(fields=['a'], value={"$slice": 5})
     self.assertEqual(q.as_dict(), {'a': {"$slice": 5}})
Beispiel #12
0
 def test_exclude_include(self):
     q = QueryFieldList()
     q += QueryFieldList(fields=['a', 'b'], value=QueryFieldList.EXCLUDE)
     self.assertEqual(q.as_dict(), {'a': False, 'b': False})
     q += QueryFieldList(fields=['b', 'c'], value=QueryFieldList.ONLY)
     self.assertEqual(q.as_dict(), {'c': True})
Beispiel #13
0
 def test_exclude_include(self):
     q = QueryFieldList()
     q += QueryFieldList(fields=["a", "b"], value=QueryFieldList.EXCLUDE)
     self.assertEqual(q.as_dict(), {"a": 0, "b": 0})
     q += QueryFieldList(fields=["b", "c"], value=QueryFieldList.ONLY)
     self.assertEqual(q.as_dict(), {"c": 1})
Beispiel #14
0
 def test_exclude_include(self):
     q = QueryFieldList()
     q += QueryFieldList(fields=['a', 'b'], value=QueryFieldList.EXCLUDE)
     self.assertEqual(q.as_dict(), {'a': 0, 'b': 0})
     q += QueryFieldList(fields=['b', 'c'], value=QueryFieldList.ONLY)
     self.assertEqual(q.as_dict(), {'c': 1})
Beispiel #15
0
 def test_exclude_exclude(self):
     q = QueryFieldList()
     q += QueryFieldList(fields=['a', 'b'], value=QueryFieldList.EXCLUDE)
     self.assertEqual(q.as_dict(), {'a': 0, 'b': 0})
     q += QueryFieldList(fields=['b', 'c'], value=QueryFieldList.EXCLUDE)
     self.assertEqual(q.as_dict(), {'a': 0, 'b': 0, 'c': 0})
Beispiel #16
0
 def test_include_include(self):
     q = QueryFieldList()
     q += QueryFieldList(fields=['a', 'b'], value=QueryFieldList.ONLY, _only_called=True)
     self.assertEqual(q.as_dict(), {'a': 1, 'b': 1})
     q += QueryFieldList(fields=['b', 'c'], value=QueryFieldList.ONLY)
     self.assertEqual(q.as_dict(), {'a': 1, 'b': 1, 'c': 1})
Beispiel #17
0
 def test_using_a_slice(self):
     q = QueryFieldList()
     q += QueryFieldList(fields=["a"], value={"$slice": 5})
     assert q.as_dict() == {"a": {"$slice": 5}}
Beispiel #18
0
 def test_using_a_slice(self):
     q = QueryFieldList()
     q += QueryFieldList(fields=['a'], value={"$slice": 5})
     self.assertEqual(q.as_dict(), {'a': {"$slice": 5}})
Beispiel #19
0
 def test_include_include(self):
     q = QueryFieldList()
     q += QueryFieldList(fields=["a", "b"], value=QueryFieldList.ONLY, _only_called=True)
     self.assertEqual(q.as_dict(), {"a": 1, "b": 1})
     q += QueryFieldList(fields=["b", "c"], value=QueryFieldList.ONLY)
     self.assertEqual(q.as_dict(), {"a": 1, "b": 1, "c": 1})