|
| 1 | +import pytest |
| 2 | + |
| 3 | +from beets.autotag.match import _parse_search_terms_with_fallbacks |
| 4 | + |
| 5 | + |
| 6 | +class TestSearchTermHandling: |
| 7 | + @pytest.mark.parametrize( |
| 8 | + "input_pairs, expected", |
| 9 | + [ |
| 10 | + ( |
| 11 | + (("A", "F1"), ("B", "F2")), |
| 12 | + ("A", "B"), |
| 13 | + ), |
| 14 | + ( |
| 15 | + (("", "F1"), ("B", "F2")), |
| 16 | + ("", "B"), |
| 17 | + ), |
| 18 | + ( |
| 19 | + (("", "F1"), ("", "F2")), |
| 20 | + ("F1", "F2"), |
| 21 | + ), |
| 22 | + ( |
| 23 | + (("A", "F1"), (None, "F2")), |
| 24 | + ("A", ""), |
| 25 | + ), |
| 26 | + ( |
| 27 | + ((None, "F1"), (None, "F2")), |
| 28 | + ("F1", "F2"), |
| 29 | + ), |
| 30 | + ], |
| 31 | + ) |
| 32 | + def test_search_parsing(self, input_pairs, expected): |
| 33 | + result = _parse_search_terms_with_fallbacks(*input_pairs) |
| 34 | + assert result == expected |
| 35 | + |
| 36 | + # Should also apply for the reversed order of inputs |
| 37 | + reversed_pairs = tuple(reversed(input_pairs)) |
| 38 | + reversed_expected = tuple(reversed(expected)) |
| 39 | + reversed_result = _parse_search_terms_with_fallbacks(*reversed_pairs) |
| 40 | + assert reversed_result == reversed_expected |
0 commit comments