From 688c3dfdb7094340269b5a221ca374d67b5778d2 Mon Sep 17 00:00:00 2001 From: hajdul88 <52442977+hajdul88@users.noreply.github.com> Date: Tue, 3 Dec 2024 14:33:46 +0100 Subject: [PATCH] Fix: deletes test that were implemented the faulty get_model_from_graph method --- .../get_graph_from_model_generative_test.py | 37 ------------------- ...del_instance_from_graph_generative_test.py | 33 ----------------- .../get_model_instance_from_graph_test.py | 35 ------------------ 3 files changed, 105 deletions(-) delete mode 100644 cognee/tests/unit/interfaces/graph/get_graph_from_model_generative_test.py delete mode 100644 cognee/tests/unit/interfaces/graph/get_model_instance_from_graph_generative_test.py delete mode 100644 cognee/tests/unit/interfaces/graph/get_model_instance_from_graph_test.py diff --git a/cognee/tests/unit/interfaces/graph/get_graph_from_model_generative_test.py b/cognee/tests/unit/interfaces/graph/get_graph_from_model_generative_test.py deleted file mode 100644 index dec751f89..000000000 --- a/cognee/tests/unit/interfaces/graph/get_graph_from_model_generative_test.py +++ /dev/null @@ -1,37 +0,0 @@ -import warnings - -import pytest - -from cognee.modules.graph.utils import get_graph_from_model -from cognee.tests.unit.interfaces.graph.util import ( - PERSON_NAMES, - count_society, - create_organization_recursive, -) - - -@pytest.mark.parametrize("recursive_depth", [1, 2, 3]) -def test_society_nodes_and_edges(recursive_depth): - import sys - - if sys.version_info[0] == 3 and sys.version_info[1] >= 11: - society = create_organization_recursive( - "society", "Society", PERSON_NAMES, recursive_depth - ) - - n_organizations, n_persons = count_society(society) - society_counts_total = n_organizations + n_persons - - nodes, edges = get_graph_from_model(society) - - assert ( - len(nodes) == society_counts_total - ), f"{society_counts_total = } != {len(nodes) = }, not all DataPoint instances were found" - - assert len(edges) == ( - len(nodes) - 1 - ), f"{(len(nodes) - 1) = } != {len(edges) = }, there have to be n_nodes - 1 edges, as each node has exactly one parent node, except for the root node" - else: - warnings.warn( - "The recursive pydantic data structure cannot be reconstructed from the graph because the 'inner' pydantic class is not defined. Hence this test is skipped. This problem is solved in Python 3.11" - ) diff --git a/cognee/tests/unit/interfaces/graph/get_model_instance_from_graph_generative_test.py b/cognee/tests/unit/interfaces/graph/get_model_instance_from_graph_generative_test.py deleted file mode 100644 index dd5e19469..000000000 --- a/cognee/tests/unit/interfaces/graph/get_model_instance_from_graph_generative_test.py +++ /dev/null @@ -1,33 +0,0 @@ -import warnings - -import pytest - -from cognee.modules.graph.utils import ( - get_graph_from_model, - get_model_instance_from_graph, -) -from cognee.tests.unit.interfaces.graph.util import ( - PERSON_NAMES, - create_organization_recursive, - show_first_difference, -) - - -@pytest.mark.parametrize("recursive_depth", [1, 2, 3]) -def test_society_nodes_and_edges(recursive_depth): - import sys - - if sys.version_info[0] == 3 and sys.version_info[1] >= 11: - society = create_organization_recursive( - "society", "Society", PERSON_NAMES, recursive_depth - ) - nodes, edges = get_graph_from_model(society) - parsed_society = get_model_instance_from_graph(nodes, edges, "society") - - assert str(society) == (str(parsed_society)), show_first_difference( - str(society), str(parsed_society), "society", "parsed_society" - ) - else: - warnings.warn( - "The recursive pydantic data structure cannot be reconstructed from the graph because the 'inner' pydantic class is not defined. Hence this test is skipped. This problem is solved in Python 3.11" - ) diff --git a/cognee/tests/unit/interfaces/graph/get_model_instance_from_graph_test.py b/cognee/tests/unit/interfaces/graph/get_model_instance_from_graph_test.py deleted file mode 100644 index f1aa7736d..000000000 --- a/cognee/tests/unit/interfaces/graph/get_model_instance_from_graph_test.py +++ /dev/null @@ -1,35 +0,0 @@ -from cognee.modules.graph.utils import ( - get_graph_from_model, - get_model_instance_from_graph, -) -from cognee.tests.unit.interfaces.graph.util import run_test_against_ground_truth - -PARSED_PERSON_GROUND_TRUTH = { - "id": "boris", - "name": "Boris", - "age": 30, - "driving_license": { - "issued_by": "PU Vrsac", - "issued_on": "2025-11-06", - "number": "1234567890", - "expires_on": "2025-11-06", - }, -} - -CAR_GROUND_TRUTH = { - "id": "car1", - "brand": "Toyota", - "model": "Camry", - "year": 2020, - "color": "Blue", -} - - -def test_parsed_person(boris): - nodes, edges = get_graph_from_model(boris) - parsed_person = get_model_instance_from_graph(nodes, edges, "boris") - - run_test_against_ground_truth( - "parsed_person", parsed_person, PARSED_PERSON_GROUND_TRUTH - ) - run_test_against_ground_truth("car", parsed_person.owns_car[0], CAR_GROUND_TRUTH)