diff options
author | Vitiko <[email protected]> | 2022-10-03 20:44:31 -0400 |
---|---|---|
committer | Vitiko <[email protected]> | 2022-10-03 20:44:31 -0400 |
commit | 571ffbccf8544224bc63c9e51688be6310fb05e3 (patch) | |
tree | f66fcd64fbd67b41990e030304dca082dc8f6d45 /tests | |
parent | 0cd89ea0f01746e0a86835fc6400aa9ca2e8db71 (diff) | |
download | bazarr-571ffbccf8544224bc63c9e51688be6310fb05e3.tar.gz bazarr-571ffbccf8544224bc63c9e51688be6310fb05e3.zip |
Fix provider pool updates
Diffstat (limited to 'tests')
-rw-r--r-- | tests/subliminal_patch/test_core.py | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/subliminal_patch/test_core.py b/tests/subliminal_patch/test_core.py index 17451ccdf..d6481ee16 100644 --- a/tests/subliminal_patch/test_core.py +++ b/tests/subliminal_patch/test_core.py @@ -1,5 +1,7 @@ from pathlib import Path +import pytest + from subliminal_patch import core @@ -17,3 +19,54 @@ def test_scan_video_episode(tmpdir): result = core.scan_video(str(video_path)) assert isinstance(result, core.Episode) + + +def pool_instance(): + yield core.SZProviderPool({"argenteam"}, {}) + + +def test_pool_update_w_nothing(pool_instance): + pool_instance.update({}, {}, [], {}) + assert pool_instance.providers == set() + assert pool_instance.discarded_providers == set() + + +def test_pool_update_w_multiple_providers(pool_instance): + assert pool_instance.providers == {"argenteam"} + pool_instance.update({"argenteam", "subdivx", "subf2m"}, {}, [], {}) + assert pool_instance.providers == {"argenteam", "subdivx", "subf2m"} + + +def test_pool_update_discarded_providers(pool_instance): + assert pool_instance.providers == {"argenteam"} + + # Provider was discarded internally + pool_instance.discarded_providers = {"argenteam"} + + assert pool_instance.discarded_providers == {"argenteam"} + + # Provider is set to be used again + pool_instance.update({"subdivx", "argenteam"}, {}, [], {}) + + assert pool_instance.providers == {"argenteam", "subdivx"} + + # Provider should disappear from discarded providers + assert pool_instance.discarded_providers == set() + + +def test_pool_update_discarded_providers_2(pool_instance): + assert pool_instance.providers == {"argenteam"} + + # Provider was discarded internally + pool_instance.discarded_providers = {"argenteam"} + + assert pool_instance.discarded_providers == {"argenteam"} + + # Provider is not set to be used again + pool_instance.update({"subdivx"}, {}, [], {}) + + assert pool_instance.providers == {"subdivx"} + + # Provider should not disappear from discarded providers + assert pool_instance.discarded_providers == {"argenteam"} |