Skip to content

Commit 37b001a

Browse files
committed
Reset lastgenre plugin config in fixtured tests
1 parent d192215 commit 37b001a

File tree

2 files changed

+21
-18
lines changed

2 files changed

+21
-18
lines changed

beetsplug/lastgenre/__init__.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -99,26 +99,28 @@ class LastGenrePlugin(plugins.BeetsPlugin):
9999
def __init__(self) -> None:
100100
super().__init__()
101101

102-
self.config.add(
103-
{
104-
"whitelist": True,
105-
"min_weight": 10,
106-
"count": 1,
107-
"fallback": None,
108-
"canonical": False,
109-
"cleanup_existing": False,
110-
"source": "album",
111-
"force": False,
112-
"keep_existing": False,
113-
"auto": True,
114-
"separator": ", ",
115-
"prefer_specific": False,
116-
"title_case": True,
117-
"pretend": False,
118-
}
119-
)
102+
self.config.add(LastGenrePlugin.default_configuration())
120103
self.setup()
121104

105+
@staticmethod
106+
def default_configuration() -> dict[str, Any]:
107+
return {
108+
"whitelist": True,
109+
"min_weight": 10,
110+
"count": 1,
111+
"fallback": None,
112+
"canonical": False,
113+
"cleanup_existing": False,
114+
"source": "album",
115+
"force": False,
116+
"keep_existing": False,
117+
"auto": True,
118+
"separator": ", ",
119+
"prefer_specific": False,
120+
"title_case": True,
121+
"pretend": False,
122+
}
123+
122124
def setup(self) -> None:
123125
"""Setup plugin from config options"""
124126
if self.config["auto"]:

test/plugins/test_lastgenre.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,7 @@ def mock_fetch_artist_genre(self, artist):
613613
# Initialize plugin instance and item
614614
plugin = lastgenre.LastGenrePlugin()
615615
# Configure
616+
plugin.config.set(lastgenre.LastGenrePlugin.default_configuration())
616617
plugin.config.set(config_values)
617618
plugin.setup() # Loads default whitelist and canonicalization tree
618619
item = _common.item()

0 commit comments

Comments
 (0)