aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/tests/test_tmdb_override_policy.py
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-node/tests/test_tmdb_override_policy.py')
-rw-r--r--packages/meshbay-node/tests/test_tmdb_override_policy.py68
1 files changed, 68 insertions, 0 deletions
diff --git a/packages/meshbay-node/tests/test_tmdb_override_policy.py b/packages/meshbay-node/tests/test_tmdb_override_policy.py
index c2f28e6..0717a0c 100644
--- a/packages/meshbay-node/tests/test_tmdb_override_policy.py
+++ b/packages/meshbay-node/tests/test_tmdb_override_policy.py
@@ -195,6 +195,74 @@ async def test_override_updates_every_entry_sharing_the_display_title(tmp_path):
await media_cache.close()
+async def test_movie_override_touches_only_the_one_file(tmp_path):
+ """
+ guessit gives a whole franchise the same display_title (every
+ "<franchise>.-.<year>.-.<subtitle>.mkv" parses to the franchise name),
+ so fanning a *movie* override out by display_title corrected the wrong
+ films (found live, 2026-08-29). A movie override applies to its own
+ file_id only; a show override still fans out (test above).
+ """
+ session = _session(tmp_path, "op", operator="op")
+ index = session._ctx["index"]
+ m1 = IndexEntry(id="b" * 64, name="Some.Agent.42.-.2008.-.Second.Errand.mkv",
+ path="movies", size=1, type="video", added_at=0,
+ display_title="Some Agent 42")
+ m2 = IndexEntry(id="c" * 64, name="Some.Agent.42.-.2012.-.Third.Errand.mkv",
+ path="movies", size=1, type="video", added_at=0,
+ display_title="Some Agent 42")
+ index.add_entry(m1)
+ index.add_entry(m2)
+
+ media_cache = MediaCache(db_path=tmp_path / "media_cache.db")
+ await media_cache.open()
+ try:
+ session._ctx["media_cache"] = media_cache
+ session._ctx["tmdb_client"] = None
+ session._verify_admin_sig = lambda transcript, sig: _true()
+ session._peer_registry = lambda: {}
+
+ await session._admin_exec_tmdb_override(
+ {"subject": f"file_id={m1.id},tmdb_id=302,media_type=movie"},
+ b"transcript", b"sig")
+
+ assert await media_cache.get_file_tmdb(m1.id) == ("302", "movie")
+ assert await media_cache.get_file_tmdb(m2.id) is None, (
+ "a movie override must not fan out to another film sharing the "
+ "parsed franchise display_title")
+ # the corrected file is also shielded from a later ops.rematch_video
+ assert await media_cache.clear_tmdb_matches([m1.id, m2.id]) == 0
+ finally:
+ await media_cache.close()
+
+
+async def test_show_override_fans_out_and_marks_every_corrected_file(tmp_path):
+ session = _session(tmp_path, "op", operator="op")
+ index = session._ctx["index"]
+ s1 = _entry("shared/S1", "s01e01.mkv", "Some Show")
+ s2 = _entry("shared/S2", "s02e01.mkv", "Some Show")
+ index.add_entry(s1)
+ index.add_entry(s2)
+
+ media_cache = MediaCache(db_path=tmp_path / "media_cache.db")
+ await media_cache.open()
+ try:
+ session._ctx["media_cache"] = media_cache
+ session._ctx["tmdb_client"] = None
+ session._verify_admin_sig = lambda transcript, sig: _true()
+ session._peer_registry = lambda: {}
+
+ await session._admin_exec_tmdb_override(
+ {"subject": f"file_id={s1.id},tmdb_id=2255,media_type=tv"},
+ b"transcript", b"sig")
+
+ assert await media_cache.get_file_tmdb(s2.id) == ("2255", "tv") # fan-out
+ # both episodes are marked, so ops.rematch_video spares the correction
+ assert await media_cache.clear_tmdb_matches([s1.id, s2.id]) == 0
+ finally:
+ await media_cache.close()
+
+
class _FakeTmdbClient:
"""Just enough for _tmdb_build_meta to run end to end — a fixed,
deterministic response, not a search stub (the override already has a