mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 08:39:17 +01:00
Test sanitize_pairs
This commit is contained in:
parent
318a840af2
commit
0da6192a4a
1 changed files with 35 additions and 12 deletions
|
|
@ -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):
|
||||
def test_sanitize_choices(self):
|
||||
assert sanitize_choices(["A", "Z"], ("A", "B")) == ["A"]
|
||||
assert sanitize_choices(["A", "A"], ("A")) == ["A"]
|
||||
assert sanitize_choices(["D", "*", "A"], ("A", "B", "C", "D")) == [
|
||||
"D",
|
||||
"B",
|
||||
"C",
|
||||
"A",
|
||||
@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"),
|
||||
]
|
||||
|
|
|
|||
Loading…
Reference in a new issue