From 1233026adc896055d73576e23e826cb6b8e3c5b2 Mon Sep 17 00:00:00 2001 From: Vitiko Date: Tue, 20 Dec 2022 17:22:49 -0400 Subject: Subtitrarinoi provider: add several improvements * Fix episode matches (#2018) * Use standard utils to download subtitles * Use standard utils to guess matches (partially implemented) --- tests/subliminal_patch/test_subtitrarinoi.py | 54 ++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 tests/subliminal_patch/test_subtitrarinoi.py (limited to 'tests') diff --git a/tests/subliminal_patch/test_subtitrarinoi.py b/tests/subliminal_patch/test_subtitrarinoi.py new file mode 100644 index 000000000..816e8db4f --- /dev/null +++ b/tests/subliminal_patch/test_subtitrarinoi.py @@ -0,0 +1,54 @@ +import pytest +from subliminal_patch.providers.subtitrarinoi import SubtitrarinoiProvider +from subliminal_patch.providers.subtitrarinoi import SubtitrarinoiSubtitle +from subzero.language import Language + +romanian = Language("ron") + + +def test_list_subtitles(episodes): + episode = episodes["breaking_bad_s01e01"] + with SubtitrarinoiProvider() as provider: + assert provider.list_subtitles(episode, [romanian]) + + +@pytest.fixture +def subtitrari_subtitle(): + yield SubtitrarinoiSubtitle( + romanian, + "https://www.subtitrari-noi.ro/7493-subtitrari noi.ro\ ", + 3, + "Sezonul 1 ep. 1-7 Sincronizari si pentru variantele HDTV x264 (Sincro atty)", + "Breaking Bad", + "tt0903747/", + "Alice", + "https://www.subtitrari-noi.ro/index.php?page=movie_details&act=1&id=7493", + 2008, + 4230, + True, + 1, + ) + + +@pytest.mark.parametrize("comment", ["season 01", "Sezonul 1 ep. 1-7", "S01"]) +def test_subtitle_get_matches_episode(subtitrari_subtitle, episodes, comment): + episode = episodes["breaking_bad_s01e01"] + episode.episode = 1 + subtitrari_subtitle.comments = comment + assert {"season", "episode", "series", "imdb_id"}.issubset( + subtitrari_subtitle.get_matches(episode) + ) + + +@pytest.mark.parametrize("comment", ["season 02", "Sezonul 2 ep. 1-7", "version 01"]) +def test_subtitle_get_matches_episode_false(subtitrari_subtitle, episodes, comment): + episode = episodes["breaking_bad_s01e01"] + episode.episode = 1 + subtitrari_subtitle.comments = comment + assert not {"season", "episode"}.issubset(subtitrari_subtitle.get_matches(episode)) + + +def test_provider_download_subtitle(subtitrari_subtitle): + with SubtitrarinoiProvider() as provider: + provider.download_subtitle(subtitrari_subtitle) + assert subtitrari_subtitle.is_valid() -- cgit v1.2.3