From 8dee1133ff799b12496add4383951a2426208857 Mon Sep 17 00:00:00 2001 From: Sleeps Date: Wed, 7 Oct 2026 13:24:01 +0100 Subject: [PATCH] Add global specialist caption override --- tests/test_route_reuse.py | 47 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/tests/test_route_reuse.py b/tests/test_route_reuse.py index c317183..4fb391b 100644 --- a/tests/test_route_reuse.py +++ b/tests/test_route_reuse.py @@ -1,10 +1,13 @@ from __future__ import annotations +import tempfile import unittest +from pathlib import Path from types import SimpleNamespace from unittest.mock import patch from scene_search.cli import _route_policy, _route_rows +from scene_search.database import init_db class SavedRouteReuseTests(unittest.TestCase): @@ -12,6 +15,7 @@ class SavedRouteReuseTests(unittest.TestCase): fake_settings = SimpleNamespace( caption_general_model="general-model", caption_specialist_model="specialist-model", + caption_force_specialist=False, caption_router_enabled=True, caption_router_model="router-model", caption_router_device="cuda", @@ -48,6 +52,49 @@ class SavedRouteReuseTests(unittest.TestCase): self.assertAlmostEqual(routed[0][2], 0.91) self.assertEqual(routed[0][3], "score") + def test_global_specialist_override_skips_classifier(self) -> None: + fake_settings = SimpleNamespace( + db_path=Path(self._testMethodName + ".sqlite3"), + caption_general_model="general-model", + caption_specialist_model="specialist-model", + caption_force_specialist=True, + caption_router_enabled=True, + caption_router_model="router-model", + caption_router_device="cuda", + caption_router_batch_size=32, + caption_router_threshold=0.5, + caption_router_context_seconds=6, + jellyfin_force_specialist_tag="scene-search:specialist", + jellyfin_force_general_tag="scene-search:general", + jellyfin_specialist_tags=(), + ) + + with tempfile.TemporaryDirectory() as tmp: + fake_settings.db_path = Path(tmp) / "scenes.sqlite3" + init_db(fake_settings.db_path) + row = { + "id": "frame-1", + "media_id": "media-1", + "timestamp_ms": 10000, + "caption_route": None, + "caption_route_reason": None, + "route_score": None, + "route_model": None, + "route_policy": None, + "jellyfin_tags": "[]", + } + + with patch("scene_search.cli.settings", fake_settings): + with patch( + "scene_search.cli.ExplicitContentRouter", + side_effect=AssertionError("classifier should not be loaded"), + ): + routed, missing = _route_rows([row]) + + self.assertEqual(missing, 0) + self.assertEqual(routed[0][1], "specialist") + self.assertEqual(routed[0][3], "global-specialist") + if __name__ == "__main__": unittest.main()