Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/graphon/utils/condition/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ def _assert_not_null(*, value: Any) -> bool:


def _assert_in(*, value: Any, expected: Any) -> bool:
if not value:
if value is None:
return False

match expected:
Expand All @@ -512,7 +512,7 @@ def _assert_in(*, value: Any, expected: Any) -> bool:


def _assert_not_in(*, value: Any, expected: Any) -> bool:
if not value:
if value is None:
return True

match expected:
Expand Down
32 changes: 32 additions & 0 deletions tests/utils/test_condition_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,38 @@ def test_process_conditions_contains_supports_string_and_list_values() -> None:
assert list_result.final_result is True


def test_process_conditions_in_matches_falsy_value_present_in_list() -> None:
condition_processor = ConditionProcessor()
variable_pool = VariablePool()
variable_pool.add(["test_node_id", "choice"], "")

in_result = condition_processor.process_conditions(
variable_pool=variable_pool,
conditions=[
Condition(
variable_selector=["test_node_id", "choice"],
comparison_operator="in",
value=["", "a", "b"],
),
],
operator="and",
)
not_in_result = condition_processor.process_conditions(
variable_pool=variable_pool,
conditions=[
Condition(
variable_selector=["test_node_id", "choice"],
comparison_operator="not in",
value=["", "a", "b"],
),
],
operator="and",
)

assert in_result.final_result is True
assert not_in_result.final_result is False


def test_process_conditions_resolves_templates_from_read_only_variable_pool() -> None:
condition_processor = ConditionProcessor()
variable_pool = VariablePool()
Expand Down
Loading