Test sanitize_pairs

This commit is contained in:
Šarūnas Nejus 2025-05-25 14:01:29 +01:00
parent 318a840af2
commit 0da6192a4a
No known key found for this signature in database
GPG key ID: DD28F6704DBE3435

View file

@ -1,15 +1,38 @@
import unittest import pytest
from beets.util.config import sanitize_choices from beets.util.config import sanitize_choices, sanitize_pairs
class HelpersTest(unittest.TestCase): @pytest.mark.parametrize(
def test_sanitize_choices(self): "input_choices, valid_choices, expected",
assert sanitize_choices(["A", "Z"], ("A", "B")) == ["A"] [
assert sanitize_choices(["A", "A"], ("A")) == ["A"] (["A", "Z"], ("A", "B"), ["A"]),
assert sanitize_choices(["D", "*", "A"], ("A", "B", "C", "D")) == [ (["A", "A"], ("A"), ["A"]),
"D", (["D", "*", "A"], ("A", "B", "C", "D"), ["D", "B", "C", "A"]),
"B", ],
"C", )
"A", def test_sanitize_choices(input_choices, valid_choices, expected):
] assert sanitize_choices(input_choices, valid_choices) == expected
def test_sanitize_pairs():
assert sanitize_pairs(
[
("foo", "baz bar"),
("foo", "baz bar"),
("key", "*"),
("*", "*"),
("discard", "bye"),
],
[
("foo", "bar"),
("foo", "baz"),
("foo", "foobar"),
("key", "value"),
],
) == [
("foo", "baz"),
("foo", "bar"),
("key", "value"),
("foo", "foobar"),
]