test(api): keep test_endpoints hermetic after /dm/narrate wiring
/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) <noreply@anthropic.com>
This commit is contained in:
@@ -1,8 +1,10 @@
|
|||||||
import json
|
import json
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
import pytest
|
||||||
from fastapi.testclient import TestClient
|
from fastapi.testclient import TestClient
|
||||||
|
|
||||||
|
import app.narrate as narrate
|
||||||
from app.main import app
|
from app.main import app
|
||||||
|
|
||||||
client = TestClient(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():
|
def test_health_ok():
|
||||||
assert client.get("/health").json() == {"status": "ok"}
|
assert client.get("/health").json() == {"status": "ok"}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user