Skip to content

Commit

Permalink
fix: added test for null_filter condition. (#53)
Browse files Browse the repository at this point in the history
* Added test for null_filter condition.
* test: integrate tests into subgraph tests

---------

Co-authored-by: 0xMochan <[email protected]>
  • Loading branch information
gabrielfior and 0xMochan authored Jun 10, 2024
1 parent 60278b4 commit d022c85
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions tests/test_subgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -2166,6 +2166,56 @@ def test_filter_2(subgraph: Subgraph):
assert actual == expected


def test_null_filter(subgraph: Subgraph):
"""
This test demonstrates the usage of a null-filter, i.e. a condition where
or "columnA is None".
"""

expected = Filter(
[
TypeMeta.FieldMeta(
name="token0",
description="",
args=[],
type=TypeRef.Named(name="Token", kind="OBJECT"),
)
],
Filter.Operator.EQ,
None,
)

actual = subgraph.Pair.token0 == None # noqa: E711

with fieldpath_test_mode():
assert actual == expected


def test_not_null_filter(subgraph: Subgraph):
"""
This test demonstrates the usage of a none null-filter, i.e. a condition where
or "columnA is not None".
"""

expected = Filter(
[
TypeMeta.FieldMeta(
name="token0",
description="",
args=[],
type=TypeRef.Named(name="Token", kind="OBJECT"),
)
],
Filter.Operator.NEQ,
None,
)

actual = subgraph.Pair.token0 != None # noqa: E711

with fieldpath_test_mode():
assert actual == expected


def test_filter_to_dict(filter: Filter):
expected = {'token0_': {'symbol': 'CRV'}}

Expand Down

0 comments on commit d022c85

Please sign in to comment.