Graph-Native Infrastructure for Context and Accountable AI Systems
Python agent-memoryaiai-governanceai-infrastructureartificial-intelligencecontext-engineeringcontext-graphsdata-engineeringdecision-intelligencedeveloper-toolsexplainable-aigenerative-aigraph-ragknowledge-graphllmontologyprovenancepythonreasoningsemantic-search
test(ingest): run the RepoIngestor security guards without GitPython installed (#1757)
Shubham Srivastava7918f7192c15
diff --git a/tests/ingest/conftest.py b/tests/ingest/conftest.pyindex 98f913a5..50f07153 100644--- a/tests/ingest/conftest.py+++ b/tests/ingest/conftest.py@@ -16,7 +16,7 @@ by patching ``semantica.ingest.ssrf.socket.getaddrinfo`` with their ownfrom __future__ import annotationsimport socket-from unittest.mock import patch+from unittest.mock import MagicMock, patchimport pytest@@ -33,3 +33,24 @@ def mock_dns():],):yield+++def stub_git_module(monkeypatch):+ """Provide a stand-in ``git`` module so repo tests run without GitPython.++ GitPython is the optional ``ingest-git`` extra, so+ ``repo_ingestor.git`` is ``None`` on a core install and+ ``patch("semantica.ingest.repo_ingestor.git.Repo")`` raises+ ``AttributeError: None does not have the attribute 'Repo'``.++ Tests that request this fixture never exercise real git — they replace+ ``git.Repo`` wholesale and assert on what reaches ``clone_from`` — so a+ stub preserves their coverage on a clean install. Deliberately not+ ``autouse``: tests that assert the *absence* of GitPython must still see+ ``git is None``. With GitPython installed this is a no-op.+ """+ from semantica.ingest import repo_ingestor as repo_ingestor_mod++ if repo_ingestor_mod.git is None:+ monkeypatch.setattr(repo_ingestor_mod, "git", MagicMock())diff --git a/tests/ingest/test_repo_ingestor_security.py b/tests/ingest/test_repo_ingestor_security.pyindex 67494abc..1358639b 100644--- a/tests/ingest/test_repo_ingestor_security.py+++ b/tests/ingest/test_repo_ingestor_security.py@@ -13,6 +13,8 @@ from semantica.ingest.repo_ingestor import ()from semantica.utils.exceptions import ValidationError+pytestmark = pytest.mark.usefixtures("stub_git_module")+def _fake_addrinfo(*addrs: str):"""Build a getaddrinfo-shaped result list for the given IP strings."""diff --git a/tests/ingest/test_submodules.py b/tests/ingest/test_submodules.pyindex da5a944d..b2638a90 100644--- a/tests/ingest/test_submodules.py+++ b/tests/ingest/test_submodules.py@@ -404,6 +404,7 @@ class TestPandasIngestor:except ImportError:pytest.skip("Pandas not installed")[email protected]("stub_git_module")class TestRepoIngestor:def test_ingest_repository(self):# Create a real temp dir and populate it