diff options
author | Vitiko <[email protected]> | 2023-01-19 00:21:21 -0400 |
---|---|---|
committer | Vitiko <[email protected]> | 2023-01-19 00:21:21 -0400 |
commit | be75d78b939ca8b798c50d9c95b5d8b98ada984d (patch) | |
tree | 78c968479360d2aba8a173dd7836825a4cf20877 /tests | |
parent | b08c8cf1a84017effe8daa4d4c07caefd6726c4e (diff) | |
download | bazarr-be75d78b939ca8b798c50d9c95b5d8b98ada984d.tar.gz bazarr-be75d78b939ca8b798c50d9c95b5d8b98ada984d.zip |
Embedded Subtitles provider: update filters
Avoid unknown language fallback is such language is already present
Diffstat (limited to 'tests')
-rw-r--r-- | tests/subliminal_patch/test_embeddedsubtitles.py | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/tests/subliminal_patch/test_embeddedsubtitles.py b/tests/subliminal_patch/test_embeddedsubtitles.py index ab0dc1c41..2c04aa377 100644 --- a/tests/subliminal_patch/test_embeddedsubtitles.py +++ b/tests/subliminal_patch/test_embeddedsubtitles.py @@ -126,8 +126,8 @@ def fake_streams(): @pytest.mark.parametrize("tags_", [{}, {"language": "und", "title": "Unknown"}]) -def test_list_subtitles_unknown_as_english(mocker, tags_): - with EmbeddedSubtitlesProvider(unknown_as_english=True): +def test_list_subtitles_unknown_as_english(mocker, tags_, video_single_language): + with EmbeddedSubtitlesProvider(unknown_as_english=True) as provider: fake = FFprobeSubtitleStream( {"index": 3, "codec_name": "subrip", "tags": tags_} ) @@ -135,9 +135,32 @@ def test_list_subtitles_unknown_as_english(mocker, tags_): "subliminal_patch.providers.embeddedsubtitles._MemoizedFFprobeVideoContainer.get_subtitles", return_value=[fake], ) - streams = _MemoizedFFprobeVideoContainer.get_subtitles("") - assert len(streams) == 1 - assert streams[0].language == Language.fromietf("en") + result = provider.list_subtitles( + video_single_language, {Language.fromalpha2("en")} + ) + assert len(result) == 1 + + +def test_list_subtitles_unknown_as_english_w_real_english_subtitles( + video_single_language, mocker +): + with EmbeddedSubtitlesProvider(unknown_as_english=True) as provider: + fakes = [ + FFprobeSubtitleStream( + {"index": 3, "codec_name": "subrip", "tags": {"language": "und"}} + ), + FFprobeSubtitleStream( + {"index": 2, "codec_name": "subrip", "tags": {"language": "eng"}} + ), + ] + mocker.patch( + "subliminal_patch.providers.embeddedsubtitles._MemoizedFFprobeVideoContainer.get_subtitles", + return_value=fakes, + ) + result = provider.list_subtitles( + video_single_language, {Language.fromalpha2("en")} + ) + assert len(result) == 1 @pytest.mark.parametrize("tags_", [{}, {"language": "und", "title": "Unknown"}]) |