summaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/tests/test_media_cache.py
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-08-29 15:12:32 +0200
committerChristophe Besson <cbesson@gmail.com>2026-08-29 15:12:32 +0200
commit5a88f8d7a0a35b0c75b0a56d0f6fce1d0a495c12 (patch)
treecbc0a8207885476cd0d331db399536c259ca4f80 /packages/meshbay-node/tests/test_media_cache.py
parentbe57cf9c3b499c8e59a94d13059f16f1456fcae1 (diff)
parent71b7a310ce938f072fe20f27eeeadd40685f1ad1 (diff)
downloadmeshbay-5a88f8d7a0a35b0c75b0a56d0f6fce1d0a495c12.tar.gz
Merge branch 'fix/videos-tmdb-matching'
Diffstat (limited to 'packages/meshbay-node/tests/test_media_cache.py')
-rw-r--r--packages/meshbay-node/tests/test_media_cache.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/packages/meshbay-node/tests/test_media_cache.py b/packages/meshbay-node/tests/test_media_cache.py
index e70ef43..4e65b24 100644
--- a/packages/meshbay-node/tests/test_media_cache.py
+++ b/packages/meshbay-node/tests/test_media_cache.py
@@ -71,6 +71,55 @@ async def test_prune_file_removes_thumb_and_mapping_but_not_shared_meta(cache):
assert await cache.get_tmdb_meta("555", "tv") == {"name": "A Show"}
+# ── auto-resolved matches vs manual "Fix match" corrections ─────────────────
+
+@pytest.mark.asyncio
+async def test_clear_tmdb_matches_drops_auto_matches_but_keeps_overrides(cache):
+ await cache.set_file_tmdb("auto1", "10", "movie")
+ await cache.set_file_tmdb("auto2", "20", "movie")
+ await cache.set_file_tmdb("fixed", "30", "movie")
+ await cache.mark_tmdb_override("fixed")
+
+ removed = await cache.clear_tmdb_matches(["auto1", "auto2", "fixed", "never-seen"])
+
+ assert removed == 2
+ assert await cache.get_file_tmdb("auto1") is None
+ assert await cache.get_file_tmdb("auto2") is None
+ assert await cache.get_file_tmdb("fixed") == ("30", "movie"), (
+ "a manual Fix match correction must survive ops.rematch_video")
+
+
+@pytest.mark.asyncio
+async def test_clear_tmdb_matches_empty_list_is_a_noop(cache):
+ assert await cache.clear_tmdb_matches([]) == 0
+
+
+@pytest.mark.asyncio
+async def test_clear_file_tmdb_drops_one_auto_match_but_keeps_an_override(cache):
+ await cache.set_file_tmdb("renamed", "10", "movie")
+ await cache.clear_file_tmdb("renamed")
+ assert await cache.get_file_tmdb("renamed") is None
+
+ await cache.set_file_tmdb("renamed-fixed", "11", "movie")
+ await cache.mark_tmdb_override("renamed-fixed")
+ await cache.clear_file_tmdb("renamed-fixed")
+ assert await cache.get_file_tmdb("renamed-fixed") == ("11", "movie")
+
+
+@pytest.mark.asyncio
+async def test_prune_file_also_clears_the_override_marker(cache):
+ await cache.set_file_tmdb("gone", "10", "movie")
+ await cache.mark_tmdb_override("gone")
+
+ await cache.prune_file("gone")
+
+ # the marker must not linger after the file leaves the index and then
+ # shield a later match on the same id from ops.rematch_video
+ assert await cache.get_file_tmdb("gone") is None
+ await cache.set_file_tmdb("gone", "99", "movie")
+ assert await cache.clear_tmdb_matches(["gone"]) == 1
+
+
# ── Music app (docs/musicbay.md §6) — file_mbid/mbid_meta ────────────────────
@pytest.mark.asyncio