From 45d5f0360b5010af4b2f4e648b9bb76284fb361d Mon Sep 17 00:00:00 2001 From: Phillip Tarrant Date: Fri, 10 Jul 2026 08:31:42 -0500 Subject: [PATCH] test(api): keep test_endpoints hermetic after /dm/narrate wiring MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit /dm/narrate now makes a real Ollama call (Task 7). The role-endpoint loop tests in test_endpoints.py had no mock, so every default pytest run was silently hitting a live Ollama instance on localhost:11434 — breaking the hermetic-suite constraint. Add an autouse fixture that stubs narrate.ollama_client.chat and narrate.call_log.record so all five endpoints stay hermetic; assertions (200 on valid, 422 on invalid) are unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) --- api/tests/test_endpoints.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/api/tests/test_endpoints.py b/api/tests/test_endpoints.py index b7db5ee..b3f6d70 100644 --- a/api/tests/test_endpoints.py +++ b/api/tests/test_endpoints.py @@ -1,8 +1,10 @@ import json from pathlib import Path +import pytest from fastapi.testclient import TestClient +import app.narrate as narrate from app.main import app client = TestClient(app) @@ -14,6 +16,15 @@ ROLE_ENDPOINTS = [ ] +@pytest.fixture(autouse=True) +def _stub_narrate_model_call(monkeypatch): + # /dm/narrate is wired to a real Ollama call (Task 7). These tests exercise + # canon-log validation across ALL role endpoints, not model behavior, so + # stub the model boundary — keeps the default suite hermetic (no network). + monkeypatch.setattr(narrate.ollama_client, "chat", lambda *a, **k: "stubbed prose") + monkeypatch.setattr(narrate.call_log, "record", lambda **kw: None) + + def test_health_ok(): assert client.get("/health").json() == {"status": "ok"}