forked from kenzuya/unshackle
fix(providers): match a later season's year and TVDB translated names in metadata searches
This commit is contained in:
@@ -154,7 +154,8 @@ def test_search_picks_the_closest_title_not_the_first(monkeypatch: pytest.Monkey
|
||||
|
||||
|
||||
def test_search_rejects_a_title_that_is_not_a_close_match(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
p, _ = _provider(monkeypatch, [edges(node(imdb_id="tt999", text="Something Else Entirely"))])
|
||||
other = node(imdb_id="tt999", text="Something Else Entirely")
|
||||
p, _ = _provider(monkeypatch, [edges(other), edges(other)])
|
||||
assert p.search("The Last of Us", 2023, "tv") is None
|
||||
|
||||
|
||||
@@ -165,8 +166,47 @@ def test_search_survives_a_null_language_block(monkeypatch: pytest.MonkeyPatch)
|
||||
|
||||
|
||||
def test_search_returns_none_when_nothing_comes_back(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
p, _ = _provider(monkeypatch, [edges()])
|
||||
p, session = _provider(monkeypatch, [edges(), edges()])
|
||||
assert p.search("The Last of Us", 2023, "tv") is None
|
||||
assert len(session.gets) == 2
|
||||
|
||||
|
||||
def test_a_miss_in_the_year_retries_with_any_earlier_start(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
p, session = _provider(monkeypatch, [NOT_FOUND, edges(), NOT_FOUND, edges(node())])
|
||||
result = p.search("The Last of Us", 2025, "tv")
|
||||
assert result is not None and result.external_ids.imdb_id == "tt3581920"
|
||||
assert 'start: "2025-01-01", end: "2025-12-31"' in session.posts[0]["query"]
|
||||
assert 'releaseDateRange: {end: "2025-12-31"}' in session.posts[1]["query"]
|
||||
|
||||
|
||||
def test_the_wider_search_misses_on_two_titles_of_the_same_name(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
older, newer = node(imdb_id="tt1", year=1997), node(imdb_id="tt2", year=2016)
|
||||
p, _ = _provider(monkeypatch, [edges(node(imdb_id="tt9", text="OTHER")), edges(older, newer)])
|
||||
assert p.search("The Last of Us", 2017, "tv") is None
|
||||
|
||||
|
||||
def test_the_year_search_keeps_the_first_of_two_titles_of_the_same_name(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
p, _ = _provider(monkeypatch, [edges(node(imdb_id="tt1"), node(imdb_id="tt2"))])
|
||||
result = p.search("The Last of Us", 2023, "tv")
|
||||
assert result is not None and result.external_ids.imdb_id == "tt1"
|
||||
|
||||
|
||||
def test_a_trailing_number_that_is_not_the_year_stays_in_the_search_term(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
p, session = _provider(monkeypatch, [NOT_FOUND, edges(node(text="EXAMPLE 2049"))])
|
||||
assert p.search("EXAMPLE 2049", 2017, "movie") is not None
|
||||
assert 'searchTerm: "EXAMPLE 2049"' in session.posts[0]["query"]
|
||||
|
||||
|
||||
def test_a_hit_in_the_year_does_not_retry(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
p, session = _provider(monkeypatch, [edges(node())])
|
||||
assert p.search("The Last of Us", 2023, "tv") is not None
|
||||
assert len(session.gets) == 1
|
||||
|
||||
|
||||
def test_search_term_drops_a_year_suffix(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
p, session = _provider(monkeypatch, [NOT_FOUND, edges(node())])
|
||||
assert p.search("The Last of Us (2023)", 2023, "tv") is not None
|
||||
assert 'searchTerm: "The Last of Us"' in session.posts[0]["query"]
|
||||
|
||||
|
||||
def test_escape_graphql_closes_the_string_injection() -> None:
|
||||
|
||||
Reference in New Issue
Block a user