Exemplo n.º 1
0
 def test_merge(self):
     "Tests a simple merge"
     p1 = predicate.Predicate('foo')
     p2 = predicate.Predicate('bar')
     p3 = predicate.Predicate('baz')
     p4 = predicate.Predicate('zip')
     m = merge.merge([p1, p2, p3, p4])
     assert isinstance(m, ast.Both)
     assert isinstance(m.left, ast.Both)
     assert isinstance(m.right, ast.Both)
     assert m.left.left.pred == p1
     assert m.left.right.pred == p2
     assert m.right.left.pred == p3
     assert m.right.right.pred == p4
Exemplo n.º 2
0
    def test_count(self):
        pred_str = """foo > 12 and bar != 0 or not test and
name matches '^test$' and list contains elem and foo > 20
"""
        p1 = predicate.Predicate(pred_str)
        count, names = merge.count_expressions(p1.ast)

        assert len(count) == 5
        assert ("Literal", "test") in names

        k = ("CompareOperator", "order", ("Literal", "foo"), ("Number", "static"))
        assert k in names
        assert count[k] == 2