mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-14 13:05:09 +00:00
feat(naming): add audio_contain_all language tag condition
An empty audio_contain_all or subs_contain_all list now never matches; before this, an empty subs_contain_all list matched every release.
This commit is contained in:
@@ -26,6 +26,8 @@ language_tags:
|
||||
rules:
|
||||
- audio: no
|
||||
tag: NORDIC
|
||||
- audio_contain_all: [no, da]
|
||||
tag: NORDIC2
|
||||
update_checks: no
|
||||
"""
|
||||
|
||||
@@ -57,6 +59,10 @@ def test_a_no_rule_tags_a_norwegian_track(tmp_path: Path) -> None:
|
||||
assert evaluate_language_tag(rules, [Language.get("no")], []) == "NORDIC"
|
||||
|
||||
|
||||
def test_a_no_entry_survives_in_an_audio_contain_all_list(tmp_path: Path) -> None:
|
||||
assert _load(tmp_path).language_tags["rules"][1]["audio_contain_all"] == ["no", "da"]
|
||||
|
||||
|
||||
def test_tag_rules_keep_their_own_booleans(tmp_path: Path) -> None:
|
||||
"""tag_rules matches text and warns about a bare bool itself."""
|
||||
path = tmp_path / "unshackle.yaml"
|
||||
|
||||
@@ -31,6 +31,23 @@ def test_subs_contain_all_needs_every_entry() -> None:
|
||||
assert evaluate_language_tag(rules, JA, EN_ES) == ""
|
||||
|
||||
|
||||
def test_audio_contain_all_tags_a_release_with_every_listed_language() -> None:
|
||||
rules = [
|
||||
{"audio_contain_all": ["fr-FR", "fr-CA"], "tag": "VF2"},
|
||||
{"audio": "fr-CA", "tag": "VFQ"},
|
||||
{"audio": "fr-FR", "tag": "VFF"},
|
||||
]
|
||||
fr_fr, fr_ca, en = Language.get("fr-FR"), Language.get("fr-CA"), Language.get("en-US")
|
||||
assert evaluate_language_tag(rules, [en, fr_fr, fr_ca], []) == "VF2"
|
||||
assert evaluate_language_tag(rules, [en, fr_ca], []) == "VFQ"
|
||||
assert evaluate_language_tag(rules, [en, fr_fr], []) == "VFF"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("condition", ["audio_contain_all", "subs_contain_all"])
|
||||
def test_an_empty_contain_all_list_matches_nothing(condition) -> None:
|
||||
assert evaluate_language_tag([{condition: [], "tag": "ALL"}], JA, EN_ES) == ""
|
||||
|
||||
|
||||
@pytest.mark.parametrize("bad", ["japanese", 1, [["ja"]], {"ja": 1}])
|
||||
def test_an_invalid_rule_value_is_no_match_not_a_crash(bad, caplog) -> None:
|
||||
rules = [{"audio": bad, "tag": "BAD"}, {"audio": "ja", "tag": "OK"}]
|
||||
|
||||
Reference in New Issue
Block a user