| 1 |
"""Tests for the 'the' plugin""" |
| 2 |
|
| 3 |
from typing import ClassVar |
| 4 |
|
| 5 |
from beets import config |
| 6 |
from beets.test.helper import PluginTestHelper |
| 7 |
from beetsplug.the import FORMAT, PATTERN_A, PATTERN_THE, ThePlugin |
| 8 |
|
| 9 |
|
| 10 |
class TestThePlugin(PluginTestHelper): |
| 11 |
plugin: ClassVar[str] = "the" |
| 12 |
|
| 13 |
def test_unthe_with_default_patterns(self): |
| 14 |
assert ThePlugin().unthe("", PATTERN_THE) == "" |
| 15 |
assert ( |
| 16 |
ThePlugin().unthe("The Something", PATTERN_THE) == "Something, The" |
| 17 |
) |
| 18 |
assert ThePlugin().unthe("The The", PATTERN_THE) == "The, The" |
| 19 |
assert ThePlugin().unthe("The The", PATTERN_THE) == "The, The" |
| 20 |
assert ThePlugin().unthe("The The X", PATTERN_THE) == "The X, The" |
| 21 |
assert ThePlugin().unthe("the The", PATTERN_THE) == "The, the" |
| 22 |
assert ( |
| 23 |
ThePlugin().unthe("Protected The", PATTERN_THE) == "Protected The" |
| 24 |
) |
| 25 |
assert ThePlugin().unthe("A Boy", PATTERN_A) == "Boy, A" |
| 26 |
assert ThePlugin().unthe("a girl", PATTERN_A) == "girl, a" |
| 27 |
assert ThePlugin().unthe("An Apple", PATTERN_A) == "Apple, An" |
| 28 |
assert ThePlugin().unthe("An A Thing", PATTERN_A) == "A Thing, An" |
| 29 |
assert ThePlugin().unthe("the An Arse", PATTERN_A) == "the An Arse" |
| 30 |
assert ( |
| 31 |
ThePlugin().unthe("TET - Travailleur", PATTERN_THE) |
| 32 |
== "TET - Travailleur" |
| 33 |
) |
| 34 |
|
| 35 |
def test_unthe_with_strip(self): |
| 36 |
config["the"]["strip"] = True |
| 37 |
assert ThePlugin().unthe("The Something", PATTERN_THE) == "Something" |
| 38 |
assert ThePlugin().unthe("An A", PATTERN_A) == "A" |
| 39 |
|
| 40 |
def test_template_function_with_defaults(self): |
| 41 |
ThePlugin().patterns = [PATTERN_THE, PATTERN_A] |
| 42 |
assert ThePlugin().the_template_func("The The") == "The, The" |
| 43 |
assert ThePlugin().the_template_func("An A") == "A, An" |
| 44 |
|
| 45 |
def test_custom_pattern(self): |
| 46 |
config["the"]["patterns"] = ["^test\\s"] |
| 47 |
config["the"]["format"] = FORMAT |
| 48 |
assert ThePlugin().the_template_func("test passed") == "passed, test" |
| 49 |
|
| 50 |
def test_custom_format(self): |
| 51 |
config["the"]["patterns"] = [PATTERN_THE, PATTERN_A] |
| 52 |
config["the"]["format"] = "{1} ({0})" |
| 53 |
assert ThePlugin().the_template_func("The A") == "The (A)" |