From 0a30010ac3473ea10a61d7d9f8b91e4e5447aca4 Mon Sep 17 00:00:00 2001 From: nia-sg-bot Date: Tue, 29 Sep 2026 15:03:20 +0530 Subject: [PATCH] test(structural): cover call and containment topology --- tests/fixtures/python_topology.json | 13 +++++++++++++ tests/test_structural.py | 6 +++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/fixtures/python_topology.json b/tests/fixtures/python_topology.json index 13da081..e73f6b6 100644 --- a/tests/fixtures/python_topology.json +++ b/tests/fixtures/python_topology.json @@ -27,6 +27,11 @@ "kind": "function", "change_kind": "added" }, + { + "id": "sym::add.py::added.child", + "kind": "function", + "change_kind": "added" + }, { "id": "sym::add.py::import::external.pkg", "kind": "import", @@ -87,6 +92,14 @@ { "id": "rel::file::renamed.py->sym::renamed.py::moved", "kind": "defines" + }, + { + "id": "rel::sym::add.py::added->sym::add.py::added.child", + "kind": "calls" + }, + { + "id": "rel::sym::add.py::added->sym::add.py::added.child", + "kind": "contains" } ] } diff --git a/tests/test_structural.py b/tests/test_structural.py index eaf2703..69d4122 100644 --- a/tests/test_structural.py +++ b/tests/test_structural.py @@ -67,7 +67,7 @@ def test_staged_add_modify_delete_rename_import_is_schema_valid_and_golden(tmp_p write(root, "rename.py", "def moved():\n return 1\n") commit(root) - write(root, "add.py", "import os\nfrom external.pkg import value\n\ndef added():\n return value\n") + write(root, "add.py", "import os\nfrom external.pkg import value\n\ndef added():\n def child():\n return value\n return child()\n") write(root, "modify.py", "def retained():\n return 2\n\ndef created():\n return 3\n") os.unlink(root / "delete.py") git(root, "mv", "rename.py", "renamed.py") @@ -92,6 +92,10 @@ def test_staged_add_modify_delete_rename_import_is_schema_valid_and_golden(tmp_p assert [r["label"] for r in imports] == [ "unresolved/external module: external.pkg", "unresolved/external module: os" ] + assert {(r["kind"], r["source_id"], r["target_id"]) for r in artifact["relationships"] if r["kind"] in ("contains", "calls")} == { + ("contains", "sym::add.py::added", "sym::add.py::added.child"), + ("calls", "sym::add.py::added", "sym::add.py::added.child"), + } for file_entry in artifact["files"]: provenance = json.loads(file_entry["evidence"][0]["detail"]) assert provenance["old_oid"] is None or len(provenance["old_oid"]) == 40