forked from kenzuya/unshackle
test: delete slow, timing-based and redundant tests
This commit is contained in:
@@ -114,11 +114,6 @@ def test_no_ids_searches(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
assert calls and calls[0][:3] == ("Futurama", 1999, "tv")
|
||||
|
||||
|
||||
def test_no_ids_and_no_title_returns_none(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
patch_providers(monkeypatch, {})
|
||||
assert providers.resolve_by_ids(kind="tv") is None
|
||||
|
||||
|
||||
def test_per_kind_order_puts_tvdb_first_for_tv(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
monkeypatch.setattr(config, "metadata_providers", {"tv": ["tvdb", "tmdb", "imdb", "omdb"]})
|
||||
tvdb = FakeProvider("tvdb", MetadataResult(title="Futurama", year=1999, kind="tv"))
|
||||
@@ -158,15 +153,6 @@ def test_an_anilist_id_reaches_the_anilist_provider(monkeypatch: pytest.MonkeyPa
|
||||
assert tmdb.asked == []
|
||||
|
||||
|
||||
def test_a_supplied_anilist_id_survives_a_provider_miss(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
patch_providers(monkeypatch, {})
|
||||
|
||||
result = providers.resolve_by_ids(anilist_id="21", title="One Piece", kind="tv")
|
||||
|
||||
assert result is not None
|
||||
assert result.external_ids.anilist_id == 21
|
||||
|
||||
|
||||
def test_a_mal_reference_carries_only_what_the_lookup_answered(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
anilist = FakeProvider("anilist", MetadataResult(title="One Piece", external_ids=ExternalIds(anilist_id=21)))
|
||||
patch_providers(monkeypatch, {"anilist": anilist})
|
||||
@@ -178,15 +164,6 @@ def test_a_mal_reference_carries_only_what_the_lookup_answered(monkeypatch: pyte
|
||||
assert result.external_ids.anilist_id == 21
|
||||
|
||||
|
||||
def test_a_mal_reference_that_misses_leaves_no_anilist_id(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
patch_providers(monkeypatch, {})
|
||||
|
||||
result = providers.resolve_by_ids(anilist_id="mal:21", title="One Piece", kind="tv")
|
||||
|
||||
assert result is not None
|
||||
assert result.external_ids.anilist_id is None
|
||||
|
||||
|
||||
def test_anilist_combines_with_a_western_id(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
tmdb = FakeProvider("tmdb", MetadataResult(title="One Piece", year=1999, kind="tv"))
|
||||
anilist = FakeProvider("anilist", MetadataResult(title="One Piece", external_ids=ExternalIds(anilist_id=21)))
|
||||
@@ -205,11 +182,6 @@ def test_anime_puts_anilist_first_with_the_rest_behind_it() -> None:
|
||||
assert ordered[1:] == [name for name in providers.DEFAULT_ORDER if name != "anilist"]
|
||||
|
||||
|
||||
def test_without_the_hint_anilist_stays_last() -> None:
|
||||
assert [cls.NAME for cls in providers.provider_order("tv")] == list(providers.DEFAULT_ORDER)
|
||||
assert providers.DEFAULT_ORDER[-1] == "anilist"
|
||||
|
||||
|
||||
def test_the_hint_cannot_add_a_provider_the_config_left_out(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
monkeypatch.setattr(config, "metadata_providers", ["tmdb", "tvdb"])
|
||||
assert [cls.NAME for cls in providers.provider_order("tv", anime=True)] == ["tmdb", "tvdb"]
|
||||
@@ -230,26 +202,11 @@ def test_an_anime_hint_falls_through_to_the_normal_order_on_a_miss(monkeypatch:
|
||||
assert imdb.asked == ["tt0388629"]
|
||||
|
||||
|
||||
def test_the_anime_hint_reaches_search(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
calls: list[dict] = []
|
||||
monkeypatch.setattr(providers, "search_metadata", lambda *a, **kw: calls.append({"args": a}) or None)
|
||||
patch_providers(monkeypatch, {})
|
||||
|
||||
providers.resolve_by_ids(title="One Piece", year=1999, kind="tv", anime=True)
|
||||
|
||||
assert calls and calls[0]["args"][-1] is True
|
||||
|
||||
|
||||
def test_the_service_provider_goes_first_with_the_rest_behind_it() -> None:
|
||||
ordered = [cls.NAME for cls in providers.provider_order("movie", prefer="tmdb")]
|
||||
assert ordered == ["tmdb", *(name for name in providers.DEFAULT_ORDER if name != "tmdb")]
|
||||
|
||||
|
||||
def test_the_service_provider_cannot_add_one_the_config_left_out(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
monkeypatch.setattr(config, "metadata_providers", ["imdb"])
|
||||
assert [cls.NAME for cls in providers.provider_order("movie", prefer="tmdb")] == ["imdb"]
|
||||
|
||||
|
||||
def test_the_service_provider_goes_before_anilist_on_an_anime_title() -> None:
|
||||
ordered = [cls.NAME for cls in providers.provider_order("tv", anime=True, prefer="tmdb")]
|
||||
assert ordered[:2] == ["tmdb", "anilist"]
|
||||
@@ -373,19 +330,6 @@ def test_an_anilist_match_takes_the_mapped_western_ids(
|
||||
assert hit.external_ids == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"ids",
|
||||
[ExternalIds("tt1", 5, "tv", 7, 21), ExternalIds(imdb_id="tt1"), ExternalIds()],
|
||||
ids=["all-western-ids", "not-anilist", "no-ids"],
|
||||
)
|
||||
def test_the_map_is_not_read_without_need(anime_map: list[bool], ids: ExternalIds) -> None:
|
||||
before = ExternalIds(**vars(ids))
|
||||
|
||||
providers.fill_anime_ids(MetadataResult(kind="tv", external_ids=ids), "tv")
|
||||
|
||||
assert (anime_map, ids) == ([], before)
|
||||
|
||||
|
||||
def test_a_supplied_anilist_id_takes_the_mapped_western_ids(
|
||||
monkeypatch: pytest.MonkeyPatch, anime_map: list[bool]
|
||||
) -> None:
|
||||
@@ -397,43 +341,11 @@ def test_a_supplied_anilist_id_takes_the_mapped_western_ids(
|
||||
assert result.external_ids == ExternalIds("tt0388629", 37854, "tv", 81797, 21)
|
||||
|
||||
|
||||
def test_the_tagging_lookup_fills_the_rest_without_a_tmdb_key(
|
||||
monkeypatch: pytest.MonkeyPatch, anime_map: list[bool]
|
||||
) -> None:
|
||||
patch_providers(monkeypatch, {"anilist": FakeProvider("anilist", anilist_hit())})
|
||||
|
||||
result = providers.resolve_by_ids(37854, anilist_id=21, kind="tv")
|
||||
|
||||
assert result is not None
|
||||
assert result.external_ids == ExternalIds("tt0388629", 37854, "tv", 81797, 21)
|
||||
|
||||
|
||||
def test_a_supplied_western_id_wins_over_the_map(monkeypatch: pytest.MonkeyPatch, anime_map: list[bool]) -> None:
|
||||
patch_providers(monkeypatch, {"anilist": FakeProvider("anilist", anilist_hit())})
|
||||
|
||||
result = providers.resolve_by_ids(tvdb_id=1, anilist_id=21, kind="tv")
|
||||
|
||||
assert result is not None
|
||||
assert result.external_ids == ExternalIds(tvdb_id=1, anilist_id=21)
|
||||
|
||||
|
||||
class SearchHit(FakeProvider):
|
||||
def search(self, title: str, year: int | None, kind: str) -> MetadataResult | None:
|
||||
return self._result
|
||||
|
||||
|
||||
def test_a_search_hit_on_anilist_takes_the_mapped_western_ids(
|
||||
monkeypatch: pytest.MonkeyPatch, anime_map: list[bool]
|
||||
) -> None:
|
||||
monkeypatch.setattr(config, "disable_metadata", False)
|
||||
monkeypatch.setattr(providers, "provider_order", lambda *a: [lambda: SearchHit("anilist", anilist_hit())])
|
||||
|
||||
result = search_metadata("One Piece", None, "tv")
|
||||
|
||||
assert result is not None
|
||||
assert result.external_ids == ExternalIds("tt0388629", 37854, "tv", 81797, 21)
|
||||
|
||||
|
||||
def western_hit(language: str | None = "ja", kind: str = "tv", **ids: Any) -> MetadataResult:
|
||||
ids = {"tmdb_id": 37854, "tmdb_kind": kind, **ids}
|
||||
return MetadataResult(title="One Piece", kind=kind, original_language=language, external_ids=ExternalIds(**ids))
|
||||
@@ -520,14 +432,3 @@ def test_a_search_hit_on_tmdb_takes_the_mapped_anilist_id(
|
||||
|
||||
assert result is not None
|
||||
assert result.external_ids == ExternalIds(None, 37854, "tv", None, 21)
|
||||
|
||||
|
||||
def test_the_tagging_search_picks_the_anilist_entry_of_the_season(
|
||||
monkeypatch: pytest.MonkeyPatch, anime_map: list[bool]
|
||||
) -> None:
|
||||
monkeypatch.setattr(providers, "search_metadata", lambda *a, **kw: western_hit(tmdb_id=1429))
|
||||
|
||||
result = providers.resolve_by_ids(title="EXAMPLE", kind="tv", season=2)
|
||||
|
||||
assert result is not None
|
||||
assert result.external_ids.anilist_id == 20958
|
||||
|
||||
Reference in New Issue
Block a user