Spaces:
Sleeping
Sleeping
| from app.services.graph_state import GraphStateManager | |
| from app.schemas.graph import NodeData, NodePatch | |
| def test_apply_patch_updates_status(): | |
| mgr = GraphStateManager() | |
| node = NodeData(id="n1", label="Entropy") | |
| mgr.add_node("s1", node) | |
| patched = mgr.apply_node_patch("s1", NodePatch(node_id="n1", status="completed")) | |
| assert patched.status == "completed" | |
| def test_new_children_appended(): | |
| mgr = GraphStateManager() | |
| mgr.add_node("s1", NodeData(id="n1", label="Root")) | |
| mgr.apply_node_patch("s1", NodePatch(node_id="n1", new_children=["n2", "n3"])) | |
| node = mgr.get_node("s1", "n1") | |
| assert "n2" in node.children_ids | |
| assert "n3" in node.children_ids | |
| def test_duplicate_children_not_added(): | |
| mgr = GraphStateManager() | |
| mgr.add_node("s1", NodeData(id="n1", label="Root", children_ids=["n2"])) | |
| mgr.apply_node_patch("s1", NodePatch(node_id="n1", new_children=["n2", "n3"])) | |
| node = mgr.get_node("s1", "n1") | |
| assert node.children_ids.count("n2") == 1 | |