aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/bazarr/test_all_import.py.to_be_reworked (renamed from tests/bazarr/test_all_import.py)0
-rw-r--r--tests/bazarr/test_logging_filters.py15
-rw-r--r--tests/subliminal_patch/test_embeddedsubtitles.py19
-rw-r--r--tests/subliminal_patch/test_subdl.py36
-rw-r--r--tests/subliminal_patch/test_subf2m.py33
-rw-r--r--tests/subliminal_patch/test_subscene.py50
6 files changed, 97 insertions, 56 deletions
diff --git a/tests/bazarr/test_all_import.py b/tests/bazarr/test_all_import.py.to_be_reworked
index 1fd1feee5..1fd1feee5 100644
--- a/tests/bazarr/test_all_import.py
+++ b/tests/bazarr/test_all_import.py.to_be_reworked
diff --git a/tests/bazarr/test_logging_filters.py b/tests/bazarr/test_logging_filters.py
new file mode 100644
index 000000000..bf01979e7
--- /dev/null
+++ b/tests/bazarr/test_logging_filters.py
@@ -0,0 +1,15 @@
+import logging
+
+from bazarr.app.logger import UnwantedWaitressMessageFilter
+
+def test_true_for_bazarr():
+ record = logging.LogRecord("", logging.INFO, "", 0, "a message from BAZARR for logging", (), None)
+ assert UnwantedWaitressMessageFilter().filter(record)
+
+def test_false_below_error():
+ record = logging.LogRecord("", logging.INFO, "", 0, "", (), None)
+ assert not UnwantedWaitressMessageFilter().filter(record)
+
+def test_true_above_error():
+ record = logging.LogRecord("", logging.CRITICAL, "", 0, "", (), None)
+ assert UnwantedWaitressMessageFilter().filter(record)
diff --git a/tests/subliminal_patch/test_embeddedsubtitles.py b/tests/subliminal_patch/test_embeddedsubtitles.py
index b7bfaa0a8..7326a368b 100644
--- a/tests/subliminal_patch/test_embeddedsubtitles.py
+++ b/tests/subliminal_patch/test_embeddedsubtitles.py
@@ -107,6 +107,13 @@ def fake_streams():
"tags": {"language": "eng", "title": "English"},
}
),
+ "tg": FFprobeSubtitleStream(
+ {
+ "index": 3,
+ "codec_name": "subrip",
+ "tags": {"language": "fil", "title": "Filipino"},
+ }
+ ),
"es_hi": FFprobeSubtitleStream(
{
"index": 3,
@@ -192,6 +199,18 @@ def test_list_subtitles_hi_fallback_one_stream(
assert subs[0].hearing_impaired == False
+def test_list_subtitles_custom_language_from_fese(
+ video_single_language, fake_streams, mocker
+):
+ with EmbeddedSubtitlesProvider(hi_fallback=True) as provider:
+ language = Language("tgl", "PH")
+ mocker.patch(
+ "subliminal_patch.providers.embeddedsubtitles._MemoizedFFprobeVideoContainer.get_subtitles",
+ return_value=[fake_streams["tg"]],
+ )
+ assert provider.list_subtitles(video_single_language, {language})
+
+
def test_list_subtitles_hi_fallback_multiple_streams(
video_single_language, fake_streams, mocker
):
diff --git a/tests/subliminal_patch/test_subdl.py b/tests/subliminal_patch/test_subdl.py
new file mode 100644
index 000000000..47fe7577d
--- /dev/null
+++ b/tests/subliminal_patch/test_subdl.py
@@ -0,0 +1,36 @@
+import os
+
+import pytest
+from subliminal_patch.providers.subdl import SubdlProvider
+from subliminal_patch.providers.subdl import SubdlSubtitle
+
+
[email protected](scope="session")
+def provider():
+ with SubdlProvider(os.environ["SUBDL_TOKEN"]) as provider:
+ yield provider
+
+
+def test_list_subtitles_movie(provider, movies, languages):
+ for sub in provider.list_subtitles(movies["dune"], {languages["en"]}):
+ assert sub.language == languages["en"]
+
+
+def test_download_subtitle(provider, languages):
+ data = {
+ "language": languages["en"],
+ "forced": False,
+ "hearing_impaired": False,
+ "page_link": "https://subdl.com/s/info/ebC6BrLCOC",
+ "download_link": "/subtitle/2808552-2770424.zip",
+ "file_id": "SUBDL::dune-2021-2770424.zip",
+ "release_names": ["Dune Part 1 WebDl"],
+ "uploader": "makoto77",
+ "season": 0,
+ "episode": None,
+ }
+
+ sub = SubdlSubtitle(**data)
+ provider.download_subtitle(sub)
+
+ assert sub.is_valid()
diff --git a/tests/subliminal_patch/test_subf2m.py b/tests/subliminal_patch/test_subf2m.py
index e8369d2fa..b8901179b 100644
--- a/tests/subliminal_patch/test_subf2m.py
+++ b/tests/subliminal_patch/test_subf2m.py
@@ -184,15 +184,36 @@ def test_download_subtitle_episode(provider, subtitle_episode):
assert subtitle_episode.is_valid()
-def test_download_subtitle_episode_with_title(provider):
+ "language,page_link,release_info,episode_number,episode_title",
+ [
+ (
+ "en",
+ "https://subf2m.co/subtitles/courage-the-cowardly-dog/english/2232402",
+ "Season 3 complete.",
+ 13,
+ "Feast of the Bullfrogs",
+ ),
+ (
+ "en",
+ "https://subf2m.co/subtitles/rick-and-morty-sixth-season/english/3060783",
+ "Used Subtitle Tools to convert from SUP to SRT, then ran the cleaner to remove HI. Grabbed subs from Rick.and.Morty.S06.1080p.BluRay.x264-STORiES.",
+ 7,
+ "Full Meta Jackrick",
+ ),
+ ],
+)
+def test_download_subtitle_episode_with_title(
+ provider, language, page_link, release_info, episode_number, episode_title
+):
sub = Subf2mSubtitle(
- Language.fromalpha2("en"),
- "https://subf2m.co/subtitles/courage-the-cowardly-dog/english/2232402",
- "Season 3 complete.",
- 13,
+ Language.fromalpha2(language),
+ page_link,
+ release_info,
+ episode_number,
)
- sub.episode_title = "Feast of the Bullfrogs"
+ sub.episode_title = episode_title
provider.download_subtitle(sub)
assert sub.is_valid()
diff --git a/tests/subliminal_patch/test_subscene.py b/tests/subliminal_patch/test_subscene.py
deleted file mode 100644
index 72063aae3..000000000
--- a/tests/subliminal_patch/test_subscene.py
+++ /dev/null
@@ -1,50 +0,0 @@
-from subliminal_patch.providers import subscene_cloudscraper as subscene
-
-
-def test_provider_scraper_call():
- with subscene.SubsceneProvider() as provider:
- result = provider._scraper_call(
- "https://subscene.com/subtitles/breaking-bad-fifth-season"
- )
- assert result.status_code == 200
-
-
-def test_provider_gen_results():
- with subscene.SubsceneProvider() as provider:
- assert list(provider._gen_results("Breaking Bad"))
-
-
-def test_provider_search_movie():
- with subscene.SubsceneProvider() as provider:
- result = provider._search_movie("Taxi Driver", 1976)
- assert result == "/subtitles/taxi-driver"
-
-
-def test_provider_find_movie_subtitles(languages):
- with subscene.SubsceneProvider() as provider:
- result = provider._find_movie_subtitles(
- "/subtitles/taxi-driver", languages["en"]
- )
- assert result
-
-
-def test_provider_search_tv_show_season():
- with subscene.SubsceneProvider() as provider:
- result = provider._search_tv_show_season("The Wire", 1)
- assert result == "/subtitles/the-wire--first-season"
-
-
-def test_provider_find_episode_subtitles(languages):
- with subscene.SubsceneProvider() as provider:
- result = provider._find_episode_subtitles(
- "/subtitles/the-wire--first-season", 1, 1, languages["en"]
- )
- assert result
-
-
-def test_provider_download_subtitle(languages):
- path = "https://subscene.com/subtitles/the-wire--first-season/english/115904"
- subtitle = subscene.SubsceneSubtitle(languages["en"], path, "", 1)
- with subscene.SubsceneProvider() as provider:
- provider.download_subtitle(subtitle)
- assert subtitle.is_valid()