Esempio n. 1
0
 def test_weird_nesting(self):
     node = parseq(
         Q(a='A', b='B'),
         (
             Q(c='C') |
             Q(d='D')
         )
     )
     self.assertEqual(unicode(node), '(a = A AND b = B) AND (c = C OR d = D)')
     
     node = parseq((
         (
             Q(c='C') |
             Q(d='D')
         ) |
         (
             Q(e='E', f='F')
         )
     ), a='A', b='B')
     self.assertEqual(unicode(node), '(a = A AND b = B) AND (c = C OR d = D OR (e = E AND f = F))')
     
     node = parseq((
         (
             Q(c='C') |
             Q(d='D')
         ) |
         (
             Q(e='E', f='F') |
             Q(g='G', h='H')
         )
     ), a='A', b='B')
     self.assertEqual(unicode(node), '(a = A AND b = B) AND ((c = C OR d = D) OR ((e = E AND f = F) OR (h = H AND g = G)))')
Esempio n. 2
0
    def test_nesting(self):
        node = parseq((Q(a="A") | Q(b="B")), (Q(c="C") | Q(d="D")))
        self.assertEqual(unicode(node), "(a = A OR b = B) AND (c = C OR d = D)")

        node = parseq((Q(a="A") | Q(b="B")) & (Q(c="C") | Q(d="D")))
        self.assertEqual(unicode(node), "((a = A OR b = B) AND (c = C OR d = D))")

        node = parseq((Q(a="A") | Q(b="B")) | (Q(c="C") | Q(d="D")))
        self.assertEqual(unicode(node), "((a = A OR b = B) OR (c = C OR d = D))")
Esempio n. 3
0
    def test_mixed(self):
        node = parseq(Q(a="A"), Q(b="B"), c="C", d="D")
        self.assertEqual(unicode(node), "a = A AND b = B AND (c = C AND d = D)")

        node = parseq((Q(a="A") & Q(b="B")), c="C", d="D")
        self.assertEqual(unicode(node), "(c = C AND d = D) AND (a = A AND b = B)")

        node = parseq((Q(a="A") | Q(b="B")), c="C", d="D")
        self.assertEqual(unicode(node), "(c = C AND d = D) AND (a = A OR b = B)")
Esempio n. 4
0
 def test_node_and_q(self):
     node = parseq(
         (Q(a='A') & Q(b='B')) |
         (Q(c='C'))
     )
     self.assertEqual(unicode(node), '(c = C OR (a = A AND b = B))')
     
     node = parseq(Q(c='C') & (Q(a='A') | Q(b='B')))
     self.assertEqual(unicode(node), '((c = C) AND (a = A OR b = B))')
Esempio n. 5
0
 def test_mixed(self):
     node = parseq(Q(a='A'), Q(b='B'), c='C', d='D')
     self.assertEqual(unicode(node), 'a = A AND b = B AND (c = C AND d = D)')
     
     node = parseq((Q(a='A') & Q(b='B')), c='C', d='D')
     self.assertEqual(unicode(node), '(c = C AND d = D) AND (a = A AND b = B)')
     
     node = parseq((Q(a='A') | Q(b='B')), c='C', d='D')
     self.assertEqual(unicode(node), '(c = C AND d = D) AND (a = A OR b = B)')
Esempio n. 6
0
    def test_weird_nesting(self):
        node = parseq(Q(a="A", b="B"), (Q(c="C") | Q(d="D")))
        self.assertEqual(unicode(node), "(a = A AND b = B) AND (c = C OR d = D)")

        node = parseq(((Q(c="C") | Q(d="D")) | (Q(e="E", f="F"))), a="A", b="B")
        self.assertEqual(unicode(node), "(a = A AND b = B) AND (c = C OR d = D OR (e = E AND f = F))")

        node = parseq(((Q(c="C") | Q(d="D")) | (Q(e="E", f="F") | Q(g="G", h="H"))), a="A", b="B")
        self.assertEqual(
            unicode(node), "(a = A AND b = B) AND ((c = C OR d = D) OR ((e = E AND f = F) OR (h = H AND g = G)))"
        )
Esempio n. 7
0
    def test_simple(self):
        node = Q(a="A") | Q(b="B")
        self.assertEqual(unicode(node), "a = A OR b = B")

        node = parseq(Q(a="A") | Q(b="B"))
        self.assertEqual(unicode(node), "(a = A OR b = B)")

        node = Q(a="A") & Q(b="B")
        self.assertEqual(unicode(node), "a = A AND b = B")

        node = parseq(Q(a="A") & Q(b="B"))
        self.assertEqual(unicode(node), "(a = A AND b = B)")
Esempio n. 8
0
 def test_simple(self):
     node = Q(a='A') | Q(b='B')
     self.assertEqual(unicode(node), 'a = A OR b = B')
     
     node = parseq(Q(a='A') | Q(b='B'))
     self.assertEqual(unicode(node), '(a = A OR b = B)')
     
     node = Q(a='A') & Q(b='B')
     self.assertEqual(unicode(node), 'a = A AND b = B')
     
     node = parseq(Q(a='A') & Q(b='B'))
     self.assertEqual(unicode(node), '(a = A AND b = B)')
Esempio n. 9
0
    def test_simple(self):
        node = Q(a='A') | Q(b='B')
        self.assertEqual(unicode(node), 'a = A OR b = B')

        node = parseq(Q(a='A') | Q(b='B'))
        self.assertEqual(unicode(node), '(a = A OR b = B)')

        node = Q(a='A') & Q(b='B')
        self.assertEqual(unicode(node), 'a = A AND b = B')

        node = parseq(Q(a='A') & Q(b='B'))
        self.assertEqual(unicode(node), '(a = A AND b = B)')
Esempio n. 10
0
    def test_nesting(self):
        node = parseq(
            (Q(a='A') | Q(b='B')),
            (Q(c='C') | Q(d='D'))
        )
        self.assertEqual(unicode(node), '(a = A OR b = B) AND (c = C OR d = D)')
        
        node = parseq(
            (Q(a='A') | Q(b='B')) &
            (Q(c='C') | Q(d='D'))
        )
        self.assertEqual(unicode(node), '((a = A OR b = B) AND (c = C OR d = D))')

        node = parseq(
            (Q(a='A') | Q(b='B')) |
            (Q(c='C') | Q(d='D'))
        )
        self.assertEqual(unicode(node), '((a = A OR b = B) OR (c = C OR d = D))')
Esempio n. 11
0
    def test_nesting(self):
        node = parseq(
            (Q(a='A') | Q(b='B')),
            (Q(c='C') | Q(d='D'))
        )
        self.assertEqual(unicode(node), '(a = A OR b = B) AND (c = C OR d = D)')
        
        node = parseq(
            (Q(a='A') | Q(b='B')) &
            (Q(c='C') | Q(d='D'))
        )
        self.assertEqual(unicode(node), '((a = A OR b = B) AND (c = C OR d = D))')

        node = parseq(
            (Q(a='A') | Q(b='B')) |
            (Q(c='C') | Q(d='D'))
        )
        self.assertEqual(unicode(node), '((a = A OR b = B) OR (c = C OR d = D))')
Esempio n. 12
0
    def test_weird_nesting(self):
        node = parseq(Q(a='A', b='B'), (Q(c='C') | Q(d='D')))
        self.assertEqual(unicode(node),
                         '(a = A AND b = B) AND (c = C OR d = D)')

        node = parseq(((Q(c='C') | Q(d='D')) | (Q(e='E', f='F'))),
                      a='A',
                      b='B')
        self.assertEqual(
            unicode(node),
            '(a = A AND b = B) AND (c = C OR d = D OR (e = E AND f = F))')

        node = parseq(
            ((Q(c='C') | Q(d='D')) | (Q(e='E', f='F') | Q(g='G', h='H'))),
            a='A',
            b='B')
        self.assertEqual(
            unicode(node),
            '(a = A AND b = B) AND ((c = C OR d = D) OR ((e = E AND f = F) OR (h = H AND g = G)))'
        )
Esempio n. 13
0
 def test_kwargs(self):
     node = parseq(a="A", b="B")
     self.assertEqual(unicode(node), "(a = A AND b = B)")
Esempio n. 14
0
    def test_node_and_q(self):
        node = parseq((Q(a='A') & Q(b='B')) | (Q(c='C')))
        self.assertEqual(unicode(node), '(c = C OR (a = A AND b = B))')

        node = parseq(Q(c='C') & (Q(a='A') | Q(b='B')))
        self.assertEqual(unicode(node), '((c = C) AND (a = A OR b = B))')
Esempio n. 15
0
 def test_kwargs(self):
     node = parseq(a='A', b='B')
     self.assertEqual(unicode(node), '(a = A AND b = B)')
Esempio n. 16
0
    def test_node_and_q(self):
        node = parseq((Q(a="A") & Q(b="B")) | (Q(c="C")))
        self.assertEqual(unicode(node), "(c = C OR (a = A AND b = B))")

        node = parseq(Q(c="C") & (Q(a="A") | Q(b="B")))
        self.assertEqual(unicode(node), "((c = C) AND (a = A OR b = B))")
Esempio n. 17
0
 def test_kwargs(self):
     node = parseq(a='A', b='B')
     self.assertEqual(unicode(node), '(a = A AND b = B)')