forked from beetbox/beets
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_config.py
More file actions
52 lines (43 loc) · 1.31 KB
/
test_config.py
File metadata and controls
52 lines (43 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import pytest
from beets.util.config import UnknownPairError, sanitize_choices, sanitize_pairs
@pytest.mark.parametrize(
"input_choices, valid_choices, expected",
[
(["A", "Z"], ("A", "B"), ["A"]),
(["A", "A"], ("A"), ["A"]),
(["D", "*", "A"], ("A", "B", "C", "D"), ["D", "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"),
]
def test_sanitize_pairs_unknown_key():
with pytest.raises(UnknownPairError):
sanitize_pairs(
[("bar", "foo")], [("key", "value")], raise_on_unknown=True
)
def test_sanitize_pairs_unknown_key_wildcard_value():
with pytest.raises(UnknownPairError):
sanitize_pairs(
[("foo", "*")], [("key", "value")], raise_on_unknown=True
)