def test_not() -> None: assert_round_trip(not_term, (P.with_id("foo") | P.of_kind("bla")).not_term()) assert_round_trip(not_term, P.of_kind("bla").not_term()) assert_round_trip( not_term, term_parser.parse( "not(is(a) or not is(b) and not a>1 or not b<2 or not(a>1))"))
def test_filter_term() -> None: assert_round_trip(term_parser, P("mem") < 23) assert_round_trip(term_parser, P.with_id("foo")) assert_round_trip(term_parser, P.of_kind("foo")) assert_round_trip(term_parser, P.of_kind("foo") | P.of_kind("bla")) assert_round_trip( term_parser, ((P.of_kind("foo") | P.of_kind("bla")) & (P("a") > 23)) & (P("b").is_in([1, 2, 3])) & (P("c") == { "a": 123 }), )
def test_not() -> None: assert_round_trip(not_term, (P.with_id("foo") | P.of_kind("bla")).not_term()) assert_round_trip(not_term, P.of_kind("bla").not_term()) assert_round_trip( not_term, term_parser.parse( "not(is(a) or not is(b) and not a>1 or not b<2 or not(a>1))")) # make sure not only negates the simple term, not the combined term assert term_parser.parse("not a==b and b==c") == CombinedTerm( NotTerm(P("a") == "b"), "and", P("b") == "c")