diff --git a/tests/conftest.py b/tests/conftest.py index 01c4379de..7708340c9 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -30,6 +30,7 @@ if TYPE_CHECKING: def pytest_configure(): pytest.BASIC_EXAMPLE_PATH = Path(__file__).parent.absolute() / "data" / "basic_example.json" pytest.COMPLEX_EXAMPLE_PATH = Path(__file__).parent.absolute() / "data" / "complex_example.json" + pytest.COMPLEX_DEPS_EXAMPLE_PATH = Path(__file__).parent.absolute() / "data" / "complex_deps_example.json" pytest.OPENAPI_EXAMPLE_PATH = Path(__file__).parent.absolute() / "data" / "Openapi.json" pytest.GROUPED_CHAT_EXAMPLE_PATH = Path(__file__).parent.absolute() / "data" / "grouped_chat.json" pytest.ONE_GROUPED_CHAT_EXAMPLE_PATH = Path(__file__).parent.absolute() / "data" / "one_group_chat.json" @@ -192,6 +193,16 @@ def json_vector_store(): return f.read() +@pytest.fixture +def complex_graph_with_groups(): + with open(pytest.COMPLEX_DEPS_EXAMPLE_PATH, "r") as f: + flow_graph = json.load(f) + data_graph = flow_graph["data"] + nodes = data_graph["nodes"] + edges = data_graph["edges"] + return Graph(nodes, edges) + + @pytest.fixture(name="client", autouse=True) def client_fixture(session: Session, monkeypatch): # Set the database url to a test database diff --git a/tests/test_graph.py b/tests/test_graph.py index e645a1c82..8395c304f 100644 --- a/tests/test_graph.py +++ b/tests/test_graph.py @@ -430,3 +430,15 @@ async def test_pickle_each_vertex(json_vector_store): assert pickled is not None unpickled = pickle.loads(pickled) assert unpickled is not None + + +@pytest.mark.asyncio +async def test_build_ordering(complex_graph_with_groups): + sorted_vertices = complex_graph_with_groups.sort_vertices(stop_component_id="ChatInput-Ay8QQ") + assert sorted_vertices == [ + "ChatInput-Ay8QQ", + "RecordsAsText-vkx2A", + "FileLoader-Vo1Cq", + ] + + sorted_vertices = complex_graph_with_groups.sort_vertices()