Files
julian 2fb947e908 test(vision): fix stub-mode tests; close the testing-gap wiki note
The two failing apps/vision smoke tests assumed stub mode but the local .env sets
VISION_RECOGNIZER=fast_alpr (real-model work, 2026-06-19), so the app built the real
recognizer: /health reported "fast_alpr" not "stub", and /analyze on garbage bytes
422'd (real decode reject) instead of returning the empty stub contract.

Fix is test isolation: a conftest autouse fixture pins VISION_RECOGNIZER=stub for the
session (an OS env var overrides the .env in pydantic-settings), restoring it after.
vision 7/7.

Updates wiki/concepts/booth-console.md (the "no automated tests" Open note now reflects
the coverage that landed) and appends wiki/log.md.

Full workspace: shared 87, server 75, devices 18, web 17, vision 7 = 204 tests across
8 turbo test tasks, 0 failures; build/lint 14/14.

Claude-Session: https://claude.ai/code/session_01Xcm6ikLgGoCxxHrxtjkk5V
2026-06-21 16:25:21 +02:00

29 lines
943 B
Python

"""Shared test fixtures.
The stub-mode smoke tests must be deterministic regardless of the developer's local
apps/vision/.env (which may set VISION_RECOGNIZER=fast_alpr for real-model work). An OS
environment variable takes precedence over the .env file in pydantic-settings, so we
force stub mode for the whole test session before the app's lifespan builds the
recognizer. Tests that exercise the real recognizer set their own override explicitly.
"""
from __future__ import annotations
import os
import pytest
@pytest.fixture(autouse=True)
def _force_stub_recognizer() -> None:
"""Pin the recognizer to the model-free stub for every test (overrides .env)."""
prev = os.environ.get("VISION_RECOGNIZER")
os.environ["VISION_RECOGNIZER"] = "stub"
try:
yield
finally:
if prev is None:
os.environ.pop("VISION_RECOGNIZER", None)
else:
os.environ["VISION_RECOGNIZER"] = prev