Exemplo n.º 1
0
 def test_inequality(self):
     cond = iter(generate_conditions())
     cond = iter(zip(cond, cond))
     for conditions1, conditions2 in zip(cond, cond):
         qs1 = (Q(**conditions1[0]), Q(**conditions1[1]))
         qs2 = (Q(**conditions2[0]), Q(**conditions2[1]))
         assert_not_equal(Union(*qs1), Union(*qs2))
Exemplo n.º 2
0
 def test_inversion_inversion(self):
     q = Q(foo=42)
     assert_is(~~q, q)
Exemplo n.º 3
0
 def test_q_intersection(self):
     q = Q(foo=42) & Q(bar=42)
     eq_(q, Q(foo=42, bar=42))
     assert_is_instance(q, Q)
Exemplo n.º 4
0
 def test_intersection_query_with_its_inversion(self):
     q = Query()
     self.check_both(q, ~q, ~Q())
Exemplo n.º 5
0
 def test_intersection_nothing(self):
     self.check_both(~Q(), Query(), ~Q())
Exemplo n.º 6
0
 def test_inequality(self):
     args = iter(((None, ), (0, ), (0, 3), (0, 3, 2)))
     for s1, s2 in zip(args, args):
         assert_not_equal(Slice(Q(), slice(*s1)), Slice(Q(), slice(*s2)))
Exemplo n.º 7
0
 def test_with_everything(self):
     self.check_both(Q(), Query(), Q())
Exemplo n.º 8
0
 def test_repr(self):
     for conditions in generate_conditions():
         q = ~Q(**conditions)
         eq_(q, eval(repr(q)))
Exemplo n.º 9
0
 def test_repr(self):
     for fields in ((), ('foo', ), ('foo', '-bar'), ('foo', '-bar', 'baz')):
         q = Q().order_by(*fields)
         eq_(q, eval(repr(q)))
Exemplo n.º 10
0
 def test_q(self):
     matching = [2, 3, 5, 7]
     q = Q()
     q.match = lambda obj_cache, pk: pk in matching
     self.assert_execute(q, matching)
Exemplo n.º 11
0
 def test_inequality(self):
     args = iter(((), ('foo', ), ('foo', '-bar'), ('foo', '-bar', 'baz')))
     for fields1, fields2 in zip(args, args):
         assert_not_equal(Ordered(Q(), *fields1), Ordered(Q(), *fields2))
Exemplo n.º 12
0
 def test_equality(self):
     for fields in ((), ('foo', ), ('foo', '-bar'), ('foo', '-bar', 'baz')):
         eq_(Ordered(Q(), *fields), Ordered(Q(), *fields))
Exemplo n.º 13
0
 def test_repr(self):
     for s in ((None, ), (0, ), (0, 3), (0, 3, 2)):
         q = Q()[slice(*s)]
         eq_(q, eval(repr(q)))
Exemplo n.º 14
0
 def test_equality(self):
     for conditions in generate_conditions():
         q = Q(**conditions)
         eq_(Inversion(q), Inversion(q))
Exemplo n.º 15
0
 def test_with_nothing(self):
     q = Query()
     self.check_both(~Q(), q, q)
Exemplo n.º 16
0
 def test_inequality(self):
     cond = iter(generate_conditions())
     for conditions1, conditions2 in zip(cond, cond):
         assert_not_equal(~Q(**conditions1), ~Q(**conditions2))
Exemplo n.º 17
0
 def test_equality(self):
     for conditions in generate_conditions():
         eq_(Q(**conditions), Q(**conditions))
Exemplo n.º 18
0
 def test_equality(self):
     cond = iter(generate_conditions())
     for conditions1, conditions2 in zip(cond, cond):
         qs = (Q(**conditions1), Q(**conditions2))
         eq_(Union(*qs), Union(*qs))
Exemplo n.º 19
0
 def test_intersection_everything(self):
     q = Query()
     self.check_both(Q(), q, q)
Exemplo n.º 20
0
 def test_repr(self):
     cond = iter(generate_conditions())
     for conditions1, conditions2 in zip(cond, cond):
         q = Q(**conditions1) & Q(**conditions2)
         eq_(q, eval(repr(q)))
Exemplo n.º 21
0
 def test_equality(self):
     for s in ((None, ), (0, ), (0, 3), (0, 3, 2)):
         eq_(Slice(Q(), slice(*s)), Slice(Q(), slice(*s)))