forked from kenzuya/unshackle
test: delete slow, timing-based and redundant tests
This commit is contained in:
@@ -151,15 +151,6 @@ def test_a_single_title_with_no_such_track_exits(
|
||||
assert "Skipping" not in caplog.text
|
||||
|
||||
|
||||
def test_subs_only_with_no_matching_subtitle_exits_a_single_title_and_skips_in_a_season(
|
||||
monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
assert run(monkeypatch, caplog, {1: {}}, subs_only=True, s_lang=["fr"]) == 1
|
||||
assert run(monkeypatch, caplog, {1: {}, 2: {}}, subs_only=True, s_lang=["fr"]) == 1
|
||||
assert caplog.text.count("Skipping Show S01E") == 2
|
||||
assert "Skipping Show S01E02: There's no track left for the selected options." in caplog.text
|
||||
|
||||
|
||||
def test_a_multi_title_run_skips_the_title_and_continues(
|
||||
monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
@@ -168,13 +159,6 @@ def test_a_multi_title_run_skips_the_title_and_continues(
|
||||
assert "Skipping Show S01E01" in caplog.text
|
||||
|
||||
|
||||
def test_a_multi_title_run_with_every_title_skipped_fails(
|
||||
monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
assert run(monkeypatch, caplog, {1: {}, 2: {}}, forced_subs_only=True) == 1
|
||||
assert caplog.text.count("Skipping Show S01E") == 2
|
||||
|
||||
|
||||
def test_a_required_language_miss_stops_the_run_by_default(
|
||||
monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
@@ -206,14 +190,6 @@ def test_skip_missing_skips_the_title_and_reports_it(
|
||||
assert state.title == "Show"
|
||||
|
||||
|
||||
def test_skip_missing_skips_a_filter_miss_and_continues(
|
||||
monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
ids = run(monkeypatch, caplog, {1: {}, 2: {"ko": True}}, a_lang=["ko"], skip_missing=True)
|
||||
assert ids == {"video": ["v"], "audio": ["ko"], "subs": ["s"]}
|
||||
assert "Skipping Show S01E01" in caplog.text
|
||||
|
||||
|
||||
def test_skip_missing_still_fails_a_run_that_skips_every_title(
|
||||
monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
@@ -222,72 +198,12 @@ def test_skip_missing_still_fails_a_run_that_skips_every_title(
|
||||
assert run(monkeypatch, caplog, {1: {}}, require_audio=["ko"], skip_missing=True) == 1
|
||||
|
||||
|
||||
class LangService(FakeService):
|
||||
"""Each episode names its original language and its audio languages; the video is in the original language."""
|
||||
|
||||
def get_titles_cached(self) -> Series:
|
||||
return Series(
|
||||
Episode(id_=f"show-s01-e{n:03}", service=FakeService, title="Show", season=1, number=n, language=ep["orig"])
|
||||
for n, ep in self.episodes.items()
|
||||
)
|
||||
|
||||
def get_tracks(self, title: Episode) -> Tracks:
|
||||
ep = self.episodes[title.number]
|
||||
tracks = Tracks()
|
||||
tracks.add(Video(id_="v", url="https://x/v", language=ep["orig"] or "en", codec=Video.Codec.AVC))
|
||||
for lang in ep["audio"]:
|
||||
tracks.add(Audio(id_=lang, url=f"https://x/{lang}", language=lang, codec=Audio.Codec.AAC, bitrate=128_000))
|
||||
return tracks
|
||||
|
||||
|
||||
JA_EN = {"orig": "ja", "audio": ["ja", "en"]}
|
||||
FR = {"orig": "ja", "audio": ["fr"]}
|
||||
EVERY = {"orig": "ja", "audio": ["ja", "ko", "en"]}
|
||||
ORIG_KO_EN = ["orig", "ko", "en"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"first,flags,outcome,logged",
|
||||
[
|
||||
(JA_EN, {}, 1, "Show S01E01: ko not found in audio tracks"),
|
||||
(JA_EN, {"skip_missing": True}, ["ja", "ko", "en"], "Skipping Show S01E01: ko not found in audio tracks"),
|
||||
({"orig": "ja", "audio": ["ko", "en"]}, {"skip_missing": True}, ["ja", "ko", "en"], "S01E01: orig not found"),
|
||||
(JA_EN, {"best_available": True}, ["ja", "en"], "ko not found in audio tracks, continuing with: orig, en"),
|
||||
(FR, {"best_available": True}, 1, "orig, ko, en not found in audio tracks and no fallback available"),
|
||||
(FR, {"best_available": True, "skip_missing": True}, ["ja", "ko", "en"], "Skipping Show S01E01: orig, ko, en"),
|
||||
(JA_EN, {"best_available": True, "require_audio": ["ko"]}, 1, "Required audio language(s) not found: ko"),
|
||||
(
|
||||
JA_EN,
|
||||
{"best_available": True, "require_audio": ["ko"], "skip_missing": True},
|
||||
["ja", "ko", "en"],
|
||||
"Skipping Show S01E01: Required audio language(s) not found: ko",
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_several_audio_languages_skip_an_episode_that_misses_one(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
first: dict,
|
||||
flags: dict[str, Any],
|
||||
outcome: Any,
|
||||
logged: str,
|
||||
) -> None:
|
||||
"""-al orig,ko,en on a season where only the second episode has all three."""
|
||||
episodes = {1: first, 2: EVERY}
|
||||
result = run(monkeypatch, caplog, episodes, service=LangService(episodes), a_lang=ORIG_KO_EN, **flags)
|
||||
assert (result if outcome == 1 else result["audio"]) == outcome
|
||||
assert logged in caplog.text
|
||||
|
||||
|
||||
def test_several_audio_languages_fail_a_season_that_misses_one_everywhere(
|
||||
monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
episodes = {1: JA_EN, 2: JA_EN}
|
||||
assert run(monkeypatch, caplog, episodes, service=LangService(episodes), a_lang=ORIG_KO_EN, skip_missing=True) == 1
|
||||
assert caplog.text.count("ko not found in audio tracks") == 2
|
||||
assert "Skipped all 2 titles" in caplog.text
|
||||
|
||||
|
||||
def test_a_partly_skipped_run_completes_and_lists_the_skips(
|
||||
monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
@@ -296,37 +212,6 @@ def test_a_partly_skipped_run_completes_and_lists_the_skips(
|
||||
assert "Skipped 1 of 2 titles: Show S01E01" in caplog.text
|
||||
|
||||
|
||||
@pytest.mark.parametrize("no_mux,settled", [(False, 2), (True, 1)])
|
||||
def test_a_skipped_title_settles_its_post_script_group(
|
||||
monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture, no_mux: bool, settled: int
|
||||
) -> None:
|
||||
"""The season event waits on every title of a group; a skipped title counts as settled, once at count time."""
|
||||
import unshackle.commands.dl as dl_module
|
||||
|
||||
seen: list[str] = []
|
||||
group = dl_module.post_script_group
|
||||
monkeypatch.setattr(dl_module, "post_script_group", lambda t: seen.append(str(t)) or group(t))
|
||||
run(monkeypatch, caplog, {1: {}, 2: {"ko": True}}, a_lang=["ko"], skip_missing=True, no_mux=no_mux)
|
||||
assert seen.count("Show S01E01") == settled
|
||||
|
||||
|
||||
class CaptionlessService(FakeService):
|
||||
"""A service that finds out in get_tracks that the title has no subtitles, and turns them off."""
|
||||
|
||||
def get_tracks(self, title: Episode) -> Tracks:
|
||||
tracks = super().get_tracks(title)
|
||||
tracks.subtitles = []
|
||||
self.NO_SUBTITLES = True
|
||||
return tracks
|
||||
|
||||
|
||||
def test_no_subtitles_set_in_get_tracks_turns_the_subtitle_requirement_off(
|
||||
monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
ids = run(monkeypatch, caplog, {1: {}}, service=CaptionlessService({1: {}}), require_subs=["en"])
|
||||
assert ids == {"video": ["v"], "audio": ["a"], "subs": []}
|
||||
|
||||
|
||||
class Muxed(BaseException):
|
||||
"""Stops the run at the first mux."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user