diff options
Diffstat (limited to 'packages/meshbay-node/tests/test_media_cache.py')
| -rw-r--r-- | packages/meshbay-node/tests/test_media_cache.py | 49 |
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 |