mirror of
https://github.com/MrSleeps/jellyfin-scene-search.git
synced 2026-11-17 23:41:28 +00:00
Test route-specific caption resume selection
This commit is contained in:
@@ -63,9 +63,10 @@ class CaptionSelectionTests(unittest.TestCase):
|
||||
"""
|
||||
INSERT INTO frames (
|
||||
id, media_id, frame_number, timestamp_ms, thumb_path,
|
||||
embedding_f16, caption, caption_model, route_policy
|
||||
embedding_f16, caption, caption_model,
|
||||
caption_route, route_policy
|
||||
)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
(
|
||||
"done",
|
||||
@@ -76,6 +77,7 @@ class CaptionSelectionTests(unittest.TestCase):
|
||||
b"\x00\x00",
|
||||
"already captioned",
|
||||
"general-model",
|
||||
"general",
|
||||
policy,
|
||||
),
|
||||
)
|
||||
@@ -125,6 +127,85 @@ class CaptionSelectionTests(unittest.TestCase):
|
||||
|
||||
self.assertEqual([row["id"] for row in rows], ["resume-me"])
|
||||
|
||||
def test_resume_recaptions_when_saved_route_and_caption_model_disagree(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
db_path = Path(tmp) / "scenes.sqlite3"
|
||||
init_db(db_path)
|
||||
|
||||
fake_settings = SimpleNamespace(
|
||||
db_path=db_path,
|
||||
caption_general_model="general-model",
|
||||
caption_specialist_model="specialist-model",
|
||||
caption_router_enabled=True,
|
||||
caption_router_model="router-model",
|
||||
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()
|
||||
with connect(db_path) as con:
|
||||
con.execute(
|
||||
"""
|
||||
INSERT INTO media (
|
||||
id, source_path, title, content_sha256, size_bytes,
|
||||
mtime_ns, interval_ms, model_id, embedding_dim,
|
||||
source_kind, jellyfin_item_id, jellyfin_library_id
|
||||
)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
(
|
||||
"media-a",
|
||||
"jellyfin://media-a",
|
||||
"Movie",
|
||||
"hash",
|
||||
0,
|
||||
0,
|
||||
10000,
|
||||
"embed-model",
|
||||
1,
|
||||
"jellyfin",
|
||||
"media-a",
|
||||
"lib-a",
|
||||
),
|
||||
)
|
||||
con.execute(
|
||||
"""
|
||||
INSERT INTO frames (
|
||||
id, media_id, frame_number, timestamp_ms, thumb_path,
|
||||
embedding_f16, caption, caption_model,
|
||||
caption_route, route_policy
|
||||
)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
(
|
||||
"wrong-model",
|
||||
"media-a",
|
||||
0,
|
||||
0,
|
||||
"/tmp/frame.jpg",
|
||||
b"\x00\x00",
|
||||
"old general caption",
|
||||
"general-model",
|
||||
"specialist",
|
||||
policy,
|
||||
),
|
||||
)
|
||||
|
||||
args = SimpleNamespace(
|
||||
force=False,
|
||||
media_id=None,
|
||||
title=None,
|
||||
limit=None,
|
||||
library_ids=["lib-a"],
|
||||
)
|
||||
rows = _select_caption_rows(args, only_needing_caption=True)
|
||||
|
||||
self.assertEqual([row["id"] for row in rows], ["wrong-model"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user