Self-hosted AI workspace.
Python
fix(tests): make archived session filter test multipart-independent
Alexandre Teixeira5d9242005745
diff --git a/tests/test_archived_sessions_model_filter.py b/tests/test_archived_sessions_model_filter.pyindex 921b62d62..bd2153e07 100644--- a/tests/test_archived_sessions_model_filter.py+++ b/tests/test_archived_sessions_model_filter.py@@ -6,7 +6,9 @@ silently DROPPED "gpt-4o" (contains but does not end with the value), andover-matched models that merely share the suffix. The sibling name filteralready uses a wildcard-escaped contains match."""+import sysimport tempfile+import typesimport uuidimport pytest@@ -34,11 +36,32 @@ def _route(router, path, method="GET"):raise AssertionError(f"route not found: {path}")+def _stub_multipart_if_missing(monkeypatch):+ """Satisfy FastAPI's optional python-multipart probe.++ setup_session_routes() registers form-based routes we don't exercise here.+ When FastAPI analyzes their Form() params at registration time it calls+ ensure_multipart_is_installed(), which raises RuntimeError if neither+ python-multipart nor multipart is importable. This archived-session model+ filter test must not depend on that optional package, so inject a minimal+ stub (only when it's genuinely absent) to let route setup proceed.+ """+ try:+ import python_multipart # noqa: F401+ return+ except ImportError:+ pass+ stub = types.ModuleType("python_multipart")+ stub.__version__ = "0.0.20" # FastAPI asserts __version__ > "0.0.12"+ monkeypatch.setitem(sys.modules, "python_multipart", stub)++@pytest.fixturedef archived_endpoint(monkeypatch):import routes.session_routes as srfrom unittest.mock import MagicMock+ _stub_multipart_if_missing(monkeypatch)monkeypatch.setattr(sr, "SessionLocal", _TS)monkeypatch.setattr(sr, "effective_user", lambda request: "alice")router = sr.setup_session_routes(MagicMock(), {})