Private
Public Access
0
0

feat(test): clean_baseline marker resets controller state before test

This commit is contained in:
2026-06-09 16:40:18 -04:00
parent afc8600800
commit 7b87bbf5ec
3 changed files with 50 additions and 0 deletions
+1
View File
@@ -46,6 +46,7 @@ markers = [
"clean_install: clean install verification (opt-in via RUN_CLEAN_INSTALL_TEST=1)",
"docker: docker build and run test (opt-in via RUN_DOCKER_TEST=1)",
"live: marks tests as live visualization tests (not in CI by default)",
"clean_baseline: opt-in marker that resets controller state via /api/reset_session before the test starts (FR5, Phase 6 of test_infrastructure_hardening_20260609)",
]
[tool.mypy]
+15
View File
@@ -653,6 +653,21 @@ def _check_live_gui_health(request, live_gui) -> Generator[None, None, None]:
handle.ensure_alive()
yield
@pytest.fixture(autouse=True)
def _reset_clean_baseline(request, live_gui) -> Generator[None, None, None]:
"""[SDM: tests/conftest.py:_reset_clean_baseline] [C: tests marked with @pytest.mark.clean_baseline]"""
if request.node.get_closest_marker("clean_baseline"):
try:
from src.api_hook_client import ApiHookClient
client = ApiHookClient()
if client.wait_for_server(timeout=5):
client.reset_session()
time.sleep(0.2)
except Exception:
pass
yield
@pytest.fixture
def live_gui_workspace(live_gui) -> Path:
"""[SDM: tests/conftest.py:live_gui_workspace] [C: tests/test_rag_phase4_*.py, tests/test_saved_presets_sim.py, etc.]"""
+34
View File
@@ -0,0 +1,34 @@
"""Tests for the clean_baseline marker (Phase 6, FR5)."""
import pytest
import time
def test_clean_baseline_marker_registered() -> None:
"""The clean_baseline marker is registered in pyproject.toml."""
# This test will fail if the marker is not registered.
# We use pytest.mark.clean_baseline as a sentinel.
@pytest.mark.clean_baseline
def dummy() -> None:
pass
assert hasattr(dummy, "pytestmark")
@pytest.mark.clean_baseline
def test_clean_baseline_ai_input_empty_at_start(live_gui) -> None:
"""A test marked with clean_baseline starts with empty ai_input."""
handle = live_gui
client = handle.api_client if hasattr(handle, "api_client") else None
if client is None:
# Fall back to creating a client
from src.api_hook_client import ApiHookClient
client = ApiHookClient()
assert client.wait_for_server(timeout=15)
value = client.get_value("ai_input")
assert value == "", f"Expected empty ai_input at start of clean_baseline test, got {value!r}"
@pytest.mark.clean_baseline
def test_clean_baseline_does_not_break_normal_tests(live_gui) -> None:
"""A test marked with clean_baseline still runs normally."""
handle = live_gui
assert handle.is_alive()