Update test_add_conditional_edges to work with string conditions

Co-authored-by: ekzhu <320302+ekzhu@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-05-21 17:45:16 +00:00
parent 247dae035b
commit cf0a38cd41

View File

@ -1040,27 +1040,17 @@ def test_add_conditional_edges() -> None:
edges = builder.nodes["A"].edges edges = builder.nodes["A"].edges
assert len(edges) == 2 assert len(edges) == 2
# Conditions are now lambda functions, so we can't directly compare them # Extract the condition strings to compare them
# We'll test them with mock messages conditions = [e.condition for e in edges]
yes_message = TextMessage(content="This contains yes", source="test") assert "yes" in conditions
no_message = TextMessage(content="This contains no", source="test") assert "no" in conditions
other_message = TextMessage(content="This contains nothing", source="test")
# Find edges by testing with each message # Match edge targets with conditions
yes_matches = [e for e in edges if e.check_condition(yes_message)] yes_edge = next(e for e in edges if e.condition == "yes")
no_matches = [e for e in edges if e.check_condition(no_message)] no_edge = next(e for e in edges if e.condition == "no")
# Should be exactly one edge that matches each message assert yes_edge.target == "B"
assert len(yes_matches) == 1 assert no_edge.target == "C"
assert len(no_matches) == 1
# These edges should go to the expected targets
assert yes_matches[0].target == "B"
assert no_matches[0].target == "C"
# Check if "other_message" doesn't match any edge, meaning neither "yes" nor "no" is in it
other_matches = [e for e in edges if e.check_condition(other_message)]
assert len(other_matches) == 0
def test_set_entry_point() -> None: def test_set_entry_point() -> None: