Beispiel #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))
Beispiel #2
0
 def test_inversion_inversion(self):
     q = Q(foo=42)
     assert_is(~~q, q)
Beispiel #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)
Beispiel #4
0
 def test_intersection_query_with_its_inversion(self):
     q = Query()
     self.check_both(q, ~q, ~Q())
Beispiel #5
0
 def test_intersection_nothing(self):
     self.check_both(~Q(), Query(), ~Q())
Beispiel #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)))
Beispiel #7
0
 def test_with_everything(self):
     self.check_both(Q(), Query(), Q())
Beispiel #8
0
 def test_repr(self):
     for conditions in generate_conditions():
         q = ~Q(**conditions)
         eq_(q, eval(repr(q)))
Beispiel #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)))
Beispiel #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)
Beispiel #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))
Beispiel #12
0
 def test_equality(self):
     for fields in ((), ('foo', ), ('foo', '-bar'), ('foo', '-bar', 'baz')):
         eq_(Ordered(Q(), *fields), Ordered(Q(), *fields))
Beispiel #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)))
Beispiel #14
0
 def test_equality(self):
     for conditions in generate_conditions():
         q = Q(**conditions)
         eq_(Inversion(q), Inversion(q))
Beispiel #15
0
 def test_with_nothing(self):
     q = Query()
     self.check_both(~Q(), q, q)
Beispiel #16
0
 def test_inequality(self):
     cond = iter(generate_conditions())
     for conditions1, conditions2 in zip(cond, cond):
         assert_not_equal(~Q(**conditions1), ~Q(**conditions2))
Beispiel #17
0
 def test_equality(self):
     for conditions in generate_conditions():
         eq_(Q(**conditions), Q(**conditions))
Beispiel #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))
Beispiel #19
0
 def test_intersection_everything(self):
     q = Query()
     self.check_both(Q(), q, q)
Beispiel #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)))
Beispiel #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)))