Skip to content

Commit

Permalink
Test different value comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
nineteendo committed Sep 19, 2024
1 parent 79dc3c6 commit a270691
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions src/jsonyx/test/test_run_filter_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,6 @@ def test_has_key(obj: list[Any], keep: bool) -> None: # noqa: FBT001
assert run_filter_query((obj, 0), "@") == expected


@pytest.mark.parametrize(("obj", "keep"), [
# Missing second key
({"a": 0}, False),
# Missing first key
({"b": 0}, False),
# Both keys present
({"a": 0, "b": 0}, True),
])
def test_has_two_keys(
obj: dict[Any, Any], keep: bool, # noqa: FBT001
) -> None:
"""Test has two keys."""
expected: list[_Node] = [([obj], 0)] if keep else []
assert run_filter_query(([obj], 0), "@.a == @.b") == expected


@pytest.mark.parametrize(("obj", "keep"), [
# Missing key
([], True),
Expand Down Expand Up @@ -107,6 +89,25 @@ def test_operator_whitespace(query: str) -> None:
assert run_filter_query([], query) == []


@pytest.mark.parametrize(("obj", "keep"), [
# Missing first key
({"b": 0}, False),
# Missing second key
({"a": 0}, False),
# Both keys present
({"a": 0, "b": 1}, False), # Different value
({"a": 0, "b": 0}, True), # Same value
])
def test_value_comparison(
obj: dict[Any, Any], keep: bool, # noqa: FBT001
) -> None:
"""Test comparison of two values."""
expected: list[_Node] = [([obj], 0)] if keep else []
assert run_filter_query(([obj], 0), "@.a == @.b") == expected


def test_and() -> None:
"""Test and."""
query: str = "@ != 1 && @ != 2 && @ != 3"
Expand Down

0 comments on commit a270691

Please sign in to comment.