Пример #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)))')
Пример #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))")
Пример #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)")
Пример #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))')
Пример #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)')
Пример #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)))"
        )
Пример #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)")
Пример #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)')
Пример #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)')
Пример #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))')
Пример #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))')
Пример #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)))'
        )
Пример #13
0
 def test_kwargs(self):
     node = parseq(a="A", b="B")
     self.assertEqual(unicode(node), "(a = A AND b = B)")
Пример #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))')
Пример #15
0
 def test_kwargs(self):
     node = parseq(a='A', b='B')
     self.assertEqual(unicode(node), '(a = A AND b = B)')
Пример #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))")
Пример #17
0
 def test_kwargs(self):
     node = parseq(a='A', b='B')
     self.assertEqual(unicode(node), '(a = A AND b = B)')