Skip to content

Commit 0da6192

Browse files
committed
Test sanitize_pairs
1 parent 318a840 commit 0da6192

File tree

1 file changed

+35
-12
lines changed

1 file changed

+35
-12
lines changed

test/util/test_config.py

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,38 @@
1-
import unittest
1+
import pytest
22

3-
from beets.util.config import sanitize_choices
3+
from beets.util.config import sanitize_choices, sanitize_pairs
44

55

6-
class HelpersTest(unittest.TestCase):
7-
def test_sanitize_choices(self):
8-
assert sanitize_choices(["A", "Z"], ("A", "B")) == ["A"]
9-
assert sanitize_choices(["A", "A"], ("A")) == ["A"]
10-
assert sanitize_choices(["D", "*", "A"], ("A", "B", "C", "D")) == [
11-
"D",
12-
"B",
13-
"C",
14-
"A",
15-
]
6+
@pytest.mark.parametrize(
7+
"input_choices, valid_choices, expected",
8+
[
9+
(["A", "Z"], ("A", "B"), ["A"]),
10+
(["A", "A"], ("A"), ["A"]),
11+
(["D", "*", "A"], ("A", "B", "C", "D"), ["D", "B", "C", "A"]),
12+
],
13+
)
14+
def test_sanitize_choices(input_choices, valid_choices, expected):
15+
assert sanitize_choices(input_choices, valid_choices) == expected
16+
17+
18+
def test_sanitize_pairs():
19+
assert sanitize_pairs(
20+
[
21+
("foo", "baz bar"),
22+
("foo", "baz bar"),
23+
("key", "*"),
24+
("*", "*"),
25+
("discard", "bye"),
26+
],
27+
[
28+
("foo", "bar"),
29+
("foo", "baz"),
30+
("foo", "foobar"),
31+
("key", "value"),
32+
],
33+
) == [
34+
("foo", "baz"),
35+
("foo", "bar"),
36+
("key", "value"),
37+
("foo", "foobar"),
38+
]

0 commit comments

Comments
 (0)