diff --git a/tests/test_route_reuse.py b/tests/test_route_reuse.py new file mode 100644 index 0000000..c317183 --- /dev/null +++ b/tests/test_route_reuse.py @@ -0,0 +1,53 @@ +from __future__ import annotations + +import unittest +from types import SimpleNamespace +from unittest.mock import patch + +from scene_search.cli import _route_policy, _route_rows + + +class SavedRouteReuseTests(unittest.TestCase): + def test_current_saved_route_skips_classifier(self) -> None: + fake_settings = SimpleNamespace( + caption_general_model="general-model", + caption_specialist_model="specialist-model", + 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 patch("scene_search.cli.settings", fake_settings): + policy = _route_policy() + row = { + "id": "frame-1", + "media_id": "media-1", + "timestamp_ms": 10000, + "caption_route": "specialist", + "caption_route_reason": "score", + "route_score": 0.91, + "route_model": "router-model", + "route_policy": policy, + } + + 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(len(routed), 1) + self.assertEqual(routed[0][1], "specialist") + self.assertAlmostEqual(routed[0][2], 0.91) + self.assertEqual(routed[0][3], "score") + + +if __name__ == "__main__": + unittest.main()