diff options
author | morpheus65535 <[email protected]> | 2021-12-24 10:01:12 -0500 |
---|---|---|
committer | morpheus65535 <[email protected]> | 2021-12-24 10:01:12 -0500 |
commit | 896239b34c6cb545062416816c542760950020f8 (patch) | |
tree | 4a7e25cc62581a84c48d9229e71894d2c5589bf2 /tests/subliminal_patch/test_addic7ed.py | |
parent | 10c317573292f3534cdc861f13e8489fa299fd5d (diff) | |
parent | 5d8897f675eed5a9ec0d5b289b37e82741ae33dd (diff) | |
download | bazarr-896239b34c6cb545062416816c542760950020f8.tar.gz bazarr-896239b34c6cb545062416816c542760950020f8.zip |
Merge remote-tracking branch 'origin/development' into developmentv1.0.2-beta.12
Diffstat (limited to 'tests/subliminal_patch/test_addic7ed.py')
-rw-r--r-- | tests/subliminal_patch/test_addic7ed.py | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/tests/subliminal_patch/test_addic7ed.py b/tests/subliminal_patch/test_addic7ed.py new file mode 100644 index 000000000..f0f47e447 --- /dev/null +++ b/tests/subliminal_patch/test_addic7ed.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python3 + +import os +import pytest +import datetime +import tempfile + +import subliminal +from subliminal_patch.providers.addic7ed import Addic7edProvider +from subliminal_patch.providers.addic7ed import Addic7edSubtitle +from dogpile.cache.region import register_backend as register_cache_backend +from subzero.language import Language + + +_ENV_VARS = ( + "ANTICAPTCHA_CLASS", + "ANTICAPTCHA_ACCOUNT_KEY", + "ADDIC7ED_USERNAME", + "ADDIC7ED_PASSWORD", +) + + +def _can_run(): + for env_var in _ENV_VARS: + if not os.environ.get(env_var): + return True + + return False + + +pytestmark = pytest.mark.skipif( + _can_run(), reason=f"Some environment variables not set: {_ENV_VARS}" +) + + [email protected](scope="session") +def region(): + register_cache_backend( + "subzero.cache.file", "subzero.cache_backends.file", "SZFileBackend" + ) + subliminal.region.configure( + "subzero.cache.file", + expiration_time=datetime.timedelta(days=30), + arguments={"appname": "sz_cache", "app_cache_dir": tempfile.gettempdir()}, + ) + subliminal.region.backend.sync() + + +def test_list_subtitles_episode(region, episodes): + item = episodes["breaking_bad_s01e01"] + language = Language("eng") + with Addic7edProvider( + os.environ["ADDIC7ED_USERNAME"], os.environ["ADDIC7ED_PASSWORD"] + ) as provider: + subtitles = provider.list_subtitles(item, {language}) + assert len(subtitles) == 6 + + subliminal.region.backend.sync() + + +def test_list_subtitles_movie(region, movies): + item = movies["dune"] + language = Language("eng") + with Addic7edProvider( + os.environ["ADDIC7ED_USERNAME"], os.environ["ADDIC7ED_PASSWORD"] + ) as provider: + subtitles = provider.list_subtitles(item, {language}) + assert len(subtitles) == 2 + + subliminal.region.backend.sync() |