summaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorVitiko <[email protected]>2022-11-05 01:01:37 -0400
committerVitiko <[email protected]>2022-11-05 01:07:06 -0400
commit708fbfcd8ec0620647975be39a1f6acbbf08f767 (patch)
treeafff0ed015d15c2f8c6bede3724f997dad789bb7 /tests
parent0b8274ec3e12521f3bd99ccc00e90aca31713ca9 (diff)
downloadbazarr-708fbfcd8ec0620647975be39a1f6acbbf08f767.tar.gz
bazarr-708fbfcd8ec0620647975be39a1f6acbbf08f767.zip
Add support for configurable scores (movies and episodes)v1.1.3-beta.12
Currently only configurable via manual `data/config/config.ini` text edition. New configurable values are `series_scores` and `movie_scores`. For each config section, the sum of the config values (except hash) must be equal to the hash value plus one (1), otherwise default values will be used (notified via debug log). Hash values are not meant to be modified; the value is shown in `config.ini` for reference. Modifying hash values would imply breaking Bazarr's score logic.
Diffstat (limited to 'tests')
-rw-r--r--tests/bazarr/test_config.py10
-rw-r--r--tests/subliminal_patch/test_score.py36
-rw-r--r--tests/subliminal_patch/test_subtitle.py29
3 files changed, 75 insertions, 0 deletions
diff --git a/tests/bazarr/test_config.py b/tests/bazarr/test_config.py
new file mode 100644
index 000000000..4cd395427
--- /dev/null
+++ b/tests/bazarr/test_config.py
@@ -0,0 +1,10 @@
+from bazarr.app import config
+
+
+def test_get_settings():
+ assert isinstance(config.get_settings(), dict)
+
+
+def test_get_scores():
+ assert isinstance(config.get_scores()["movie"], dict)
+ assert isinstance(config.get_scores()["episode"], dict)
diff --git a/tests/subliminal_patch/test_score.py b/tests/subliminal_patch/test_score.py
new file mode 100644
index 000000000..1c885d096
--- /dev/null
+++ b/tests/subliminal_patch/test_score.py
@@ -0,0 +1,36 @@
+from subliminal_patch import score
+from subliminal_patch.providers.karagarga import KaragargaSubtitle
+
+
+# def __call__(self, matches, subtitle, video, hearing_impaired=None):
+
+
+def test_compute_score_set_var(movies, languages):
+ subtitle = KaragargaSubtitle(languages["en"], "", "", "")
+ score.compute_score({"hash"}, subtitle, movies["dune"])
+
+
+def test_compute_score_set_var_w_episode(episodes, languages):
+ subtitle = KaragargaSubtitle(languages["en"], "", "", "")
+ score.compute_score({"hash"}, subtitle, episodes["breaking_bad_s01e01"])
+
+
+def test_compute_score_defaults():
+ assert score.ComputeScore()._scores == score.DEFAULT_SCORES
+
+
+def test_compute_score_custom_invalid():
+ assert (
+ score.ComputeScore({"movie": {"hash": 120}, "episode": {"hash": 321}})._scores
+ == score.DEFAULT_SCORES
+ )
+
+
+def test_compute_score_custom_valid():
+ scores_copy = score.DEFAULT_SCORES.copy()
+ scores_copy["movie"]["release_group"] = 12
+ scores_copy["movie"]["source"] = 8
+
+ scores_ = score.ComputeScore(scores_copy)
+ assert scores_._scores["movie"]["release_group"] == 12
+ assert scores_._scores["movie"]["source"] == 8
diff --git a/tests/subliminal_patch/test_subtitle.py b/tests/subliminal_patch/test_subtitle.py
new file mode 100644
index 000000000..f0c7dabcf
--- /dev/null
+++ b/tests/subliminal_patch/test_subtitle.py
@@ -0,0 +1,29 @@
+from subliminal_patch import subtitle
+
+
+def test_guess_matches_w_edition_only_video(movies):
+ movie = movies["dune"]
+ movie.edition = "Director's Cut"
+ matches = subtitle.guess_matches(movie, {})
+ assert "edition" not in matches
+
+
+def test_guess_matches_w_edition_only_guess(movies):
+ movie = movies["dune"]
+ movie.edition = None
+ matches = subtitle.guess_matches(movie, {"edition": "Director's Cut"})
+ assert "edition" not in matches
+
+
+def test_guess_matches_w_edition_both(movies):
+ movie = movies["dune"]
+ movie.edition = "Director's Cut"
+ matches = subtitle.guess_matches(movie, {"edition": "Director's Cut"})
+ assert "edition" in matches
+
+
+def test_guess_matches_w_edition_both_empty(movies):
+ movie = movies["dune"]
+ movie.edition = None
+ matches = subtitle.guess_matches(movie, {})
+ assert "edition" in matches