diff options
author | vitiko98 <[email protected]> | 2022-06-29 00:07:18 -0400 |
---|---|---|
committer | vitiko98 <[email protected]> | 2022-06-29 00:07:18 -0400 |
commit | d2b40bd781a2b116e3cd32d4aded3d666b2105dd (patch) | |
tree | 7597e34fed0c8efd849d182f49e26b375b1c42af /tests | |
parent | 5fab67bca0e43cc914bab667faf955a248fa41dd (diff) | |
download | bazarr-d2b40bd781a2b116e3cd32d4aded3d666b2105dd.tar.gz bazarr-d2b40bd781a2b116e3cd32d4aded3d666b2105dd.zip |
Add Karagarga.in providerv1.0.5-beta.38
Diffstat (limited to 'tests')
-rw-r--r-- | tests/bazarr/app/test_get_providers.py | 8 | ||||
-rw-r--r-- | tests/subliminal_patch/test_karagarga.py | 74 |
2 files changed, 82 insertions, 0 deletions
diff --git a/tests/bazarr/app/test_get_providers.py b/tests/bazarr/app/test_get_providers.py index 20e1f1a62..3b28da186 100644 --- a/tests/bazarr/app/test_get_providers.py +++ b/tests/bazarr/app/test_get_providers.py @@ -34,3 +34,11 @@ def test_get_providers_auth_embeddedsubtitles(): assert isinstance(item["ffprobe_path"], str) assert isinstance(item["ffmpeg_path"], str) assert isinstance(item["timeout"], str) + + +def test_get_providers_auth_karagarga(): + item = get_providers.get_providers_auth()["karagarga"] + assert item["username"] is not None + assert item["password"] is not None + assert item["f_username"] is not None + assert item["f_password"] is not None diff --git a/tests/subliminal_patch/test_karagarga.py b/tests/subliminal_patch/test_karagarga.py new file mode 100644 index 000000000..c3790447b --- /dev/null +++ b/tests/subliminal_patch/test_karagarga.py @@ -0,0 +1,74 @@ +import os +import tempfile + +import pytest +from subliminal.cache import region +from subliminal_patch.providers.karagarga import ConfigurationError +from subliminal_patch.providers.karagarga import KaragargaProvider +from subliminal_patch.providers.karagarga import KaragargaSubtitle +from subliminal_patch.providers.karagarga import Language + +_USER = os.environ.get("KARAGARGA_USER") +_PASSWORD = os.environ.get("KARAGARGA_PASSWORD") + +# TODO: maybe move this region to subliminal_patch's conftest.py + +region.configure( + "dogpile.cache.dbm", + arguments={ + "filename": os.path.join(tempfile.gettempdir(), "subliminal_patch_tests.db") + }, +) + +pytestmark = pytest.mark.skipif( + _USER is None or _PASSWORD is None, + reason="KARAGARGA_USER KARAGARGA_PASSWORD env vars not provided", +) + + [email protected](scope="module") +def provider(): + with KaragargaProvider(_USER, _PASSWORD) as provider: + yield provider + + +def test_init_raises_configuration_error(): + with pytest.raises(ConfigurationError): + assert KaragargaProvider("", "") + + +def test_login(provider): + assert provider + + + "title,year,expected_subs_len", + [("Paradise", 2009, 2), ("Her Way", 2021, 2), ("Batrachian's Ballad", 2016, 1)], +) +def test_search_movie(provider, title, year, expected_subs_len): + subtitles = provider._search_movie(title, year) + assert len(subtitles) >= expected_subs_len + + +def test_list_subtitles(provider, movies): + item = list(movies.values())[0] + item.title = "Paradise" + item.year = 2009 + + assert provider.list_subtitles(item, {Language.fromietf("en")}) + + +def test_download_subtitle(provider): + subtitle = KaragargaSubtitle( + Language.fromietf("en"), + "https://forum.karagarga.in/index.php?app=core&module=attach§ion=attach&attach_id=49324", + "foo", + 1, + ) + provider.download_subtitle(subtitle) + assert subtitle.is_valid() + + +def test_subtitle_get_matches(movies): + subtitle = KaragargaSubtitle(Language.fromietf("en"), "foo", "Foo.2019", 0) + assert {"title", "year"}.issubset(subtitle.get_matches(movies["inexistent"])) |