Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_predicate_q_expansion():
assert Q(C(1), C(2), module=3) == And(C(1), C(2), Q(module=3))
assert Q(C(1), C(2), module=3, action=C(4)) == When(And(C(1), C(2), Q(module=3)), C(4))
assert Q(C(1), C(2), module=3, actions=[C(4), C(5)]) == When(And(C(1), C(2), Q(module=3)), C(4), C(5))
def test_predicate_no_inf_recursion(mockevent):
assert Or(And(1)) == 1
assert Or(Or(1)) == 1
assert And(Or(1)) == 1
assert And(And(1)) == 1
predicate = Q(Q(lambda ev: 1, module='wat'))
print('predicate:', predicate)
predicate(mockevent)
def test_predicate_and(mockevent):
assert And(C(1), C(2)) == And(C(1), C(2))
assert Q(module=1) & Q(module=2) == And(Q(module=1), Q(module=2))
assert Q(module=1) & Q(module=2) & Q(module=3) == And(Q(module=1), Q(module=2), Q(module=3))
assert (Q(module=__name__) & Q(module='foo'))(mockevent) is False
assert (Q(module=__name__) & Q(function='mockevent'))(mockevent) is True
assert And(1, 2) | 3 == Or(And(1, 2), 3)
def test_predicate_or(mockevent):
assert Q(module=1) | Q(module=2) == Or(Q(module=1), Q(module=2))
assert Q(module=1) | Q(module=2) | Q(module=3) == Or(Q(module=1), Q(module=2), Q(module=3))
assert (Q(module='foo') | Q(module='bar'))(mockevent) == False
assert (Q(module='foo') | Q(module=__name__))(mockevent) == True
assert Or(1, 2) & 3 == And(Or(1, 2), 3)
def test_predicate_and(mockevent):
assert And(C(1), C(2)) == And(C(1), C(2))
assert Q(module=1) & Q(module=2) == And(Q(module=1), Q(module=2))
assert Q(module=1) & Q(module=2) & Q(module=3) == And(Q(module=1), Q(module=2), Q(module=3))
assert (Q(module=__name__) & Q(module='foo'))(mockevent) is False
assert (Q(module=__name__) & Q(function='mockevent'))(mockevent) is True
assert And(1, 2) | 3 == Or(And(1, 2), 3)
def test_predicate_and(mockevent):
assert And(C(1), C(2)) == And(C(1), C(2))
assert Q(module=1) & Q(module=2) == And(Q(module=1), Q(module=2))
assert Q(module=1) & Q(module=2) & Q(module=3) == And(Q(module=1), Q(module=2), Q(module=3))
assert (Q(module=__name__) & Q(module='foo'))(mockevent) is False
assert (Q(module=__name__) & Q(function='mockevent'))(mockevent) is True
assert And(1, 2) | 3 == Or(And(1, 2), 3)
def test_predicate_and(mockevent):
assert And(C(1), C(2)) == And(C(1), C(2))
assert Q(module=1) & Q(module=2) == And(Q(module=1), Q(module=2))
assert Q(module=1) & Q(module=2) & Q(module=3) == And(Q(module=1), Q(module=2), Q(module=3))
assert (Q(module=__name__) & Q(module='foo'))(mockevent) is False
assert (Q(module=__name__) & Q(function='mockevent'))(mockevent) is True
assert And(1, 2) | 3 == Or(And(1, 2), 3)
def test_predicate_no_inf_recursion(mockevent):
assert Or(And(1)) == 1
assert Or(Or(1)) == 1
assert And(Or(1)) == 1
assert And(And(1)) == 1
predicate = Q(Q(lambda ev: 1, module='wat'))
print('predicate:', predicate)
predicate(mockevent)