summaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/tests/test_tmdb.py
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-08-29 16:07:03 +0200
committerChristophe Besson <cbesson@gmail.com>2026-08-29 16:07:03 +0200
commit78eef92bfa3513a81ac64d4377f8300c533aaa6c (patch)
treee056e6b4fceca76ab67586548f0aa6ed80f925bc /packages/meshbay-node/tests/test_tmdb.py
parent236e5e811355212945b89c4f7a99df5c837e97c7 (diff)
parent4d167e9f958d26c1db920274974ae446426928e3 (diff)
downloadmeshbay-78eef92bfa3513a81ac64d4377f8300c533aaa6c.tar.gz
Merge branch 'feat/videos-matching-v8-v13'
Diffstat (limited to 'packages/meshbay-node/tests/test_tmdb.py')
-rw-r--r--packages/meshbay-node/tests/test_tmdb.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/packages/meshbay-node/tests/test_tmdb.py b/packages/meshbay-node/tests/test_tmdb.py
index fcbc2a2..ab452ce 100644
--- a/packages/meshbay-node/tests/test_tmdb.py
+++ b/packages/meshbay-node/tests/test_tmdb.py
@@ -40,6 +40,59 @@ async def test_search_movie_returns_top_result_and_confidence():
await client.close()
+# ── §10.1/V9: year-exact preference, only when the top hit is weak ──────────
+
+@pytest.mark.asyncio
+async def test_year_exact_result_wins_when_the_top_hit_is_low_confidence():
+ # results[0] is TMDB's popularity #1 but a poor textual match for the
+ # query; results[2] is the exact requested year.
+ body = {"results": [
+ {"id": 1, "title": "Franchise vs. The Doctor", "release_date": "1962-10-05"},
+ {"id": 2, "title": "Franchise: Goldfinger", "release_date": "1964-09-17"},
+ {"id": 3, "title": "Second Errand", "release_date": "2002-11-20"},
+ ]}
+ client = TmdbClient(
+ roster=FakeRoster(),
+ transport=httpx.MockTransport(_handler({"search/movie": body})),
+ )
+ result, _ = await client.search_movie("The Franchise", 2002)
+
+ assert result["id"] == 3
+ await client.close()
+
+
+@pytest.mark.asyncio
+async def test_year_is_ignored_when_the_top_hit_is_already_confident():
+ body = {"results": [
+ {"id": 1, "title": "The Franchise", "release_date": "1999-01-01"},
+ {"id": 2, "title": "Unrelated", "release_date": "2002-01-01"},
+ ]}
+ client = TmdbClient(
+ roster=FakeRoster(),
+ transport=httpx.MockTransport(_handler({"search/movie": body})),
+ )
+ result, ratio = await client.search_movie("The Franchise", 2002)
+
+ assert result["id"] == 1 and ratio > 0.9
+ await client.close()
+
+
+@pytest.mark.asyncio
+async def test_no_year_match_leaves_the_top_result_in_place():
+ body = {"results": [
+ {"id": 1, "title": "Something Else Entirely", "release_date": "1990-01-01"},
+ {"id": 2, "title": "Also Not It", "release_date": "1991-01-01"},
+ ]}
+ client = TmdbClient(
+ roster=FakeRoster(),
+ transport=httpx.MockTransport(_handler({"search/movie": body})),
+ )
+ result, _ = await client.search_movie("The Franchise", 2002)
+
+ assert result["id"] == 1
+ await client.close()
+
+
@pytest.mark.asyncio
async def test_search_tv_returns_top_result():
body = {"results": [{"id": 7, "name": "Some Show"}]}