test: provide dummy Neo4j credentials in conftest

Any code path reaching the Neo4jConnection singleton requires NEO4J_*
env vars at construction — tests only passed thanks to developers'
local .env files. Driver creation is lazy, nothing connects.

Verified by running all four suites with every .env removed:
458 passed.
This commit is contained in:
dextmorgn
2026-06-05 15:34:58 +02:00
parent dc36ef633e
commit 612d39eadf
2 changed files with 19 additions and 0 deletions

View File

@@ -17,6 +17,12 @@ def setup_test_environment(monkeypatch):
# Set a test master key for vault tests
test_key = "base64:qnHTmwYb+uoygIw9MsRMY22vS5YPchY+QOi/E79GAvM="
monkeypatch.setenv("MASTER_VAULT_KEY_V1", test_key)
# Dummy Neo4j credentials: the Neo4jConnection singleton requires them
# at construction, but driver creation is lazy — nothing connects.
# Without these, tests silently depend on the developer's local .env.
monkeypatch.setenv("NEO4J_URI_BOLT", "bolt://127.0.0.1:7687")
monkeypatch.setenv("NEO4J_USERNAME", "neo4j")
monkeypatch.setenv("NEO4J_PASSWORD", "test-password")
@pytest.fixture(autouse=True)

View File

@@ -2,6 +2,19 @@ import pytest
from tests.logger import TestLogger
@pytest.fixture(autouse=True)
def setup_test_environment(monkeypatch):
"""Set up test environment variables.
Dummy Neo4j credentials: the Neo4jConnection singleton requires them
at construction, but driver creation is lazy — nothing connects.
Without these, tests silently depend on the developer's local .env.
"""
monkeypatch.setenv("NEO4J_URI_BOLT", "bolt://127.0.0.1:7687")
monkeypatch.setenv("NEO4J_USERNAME", "neo4j")
monkeypatch.setenv("NEO4J_PASSWORD", "test-password")
@pytest.fixture(autouse=True)
def mock_logger(monkeypatch):
"""Automatically replace the production Logger with TestLogger for all tests."""