mirror of
https://github.com/beetbox/beets.git
synced 2026-03-19 11:54:47 +01:00
Fixed imports for all tests and added a bit of stricter type checking.
This commit is contained in:
parent
5fe8431a65
commit
178e27f11f
6 changed files with 34 additions and 14 deletions
|
|
@ -8,7 +8,7 @@ from typing import TYPE_CHECKING, Any
|
|||
from jellyfish import levenshtein_distance
|
||||
from unidecode import unidecode
|
||||
|
||||
from beets import config, plugins
|
||||
from beets import config, metadata_plugins
|
||||
from beets.util import as_string, cached_classproperty, get_most_common_tags
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
|
@ -409,7 +409,7 @@ def track_distance(
|
|||
dist.add_expr("medium", item.disc != track_info.medium)
|
||||
|
||||
# Plugins.
|
||||
dist.update(plugins.track_distance(item, track_info))
|
||||
dist.update(metadata_plugins.track_distance(item, track_info))
|
||||
|
||||
return dist
|
||||
|
||||
|
|
@ -526,6 +526,6 @@ def distance(
|
|||
dist.add("unmatched_tracks", 1.0)
|
||||
|
||||
# Plugins.
|
||||
dist.update(plugins.album_distance(items, album_info, mapping))
|
||||
dist.update(metadata_plugins.album_distance(items, album_info, mapping))
|
||||
|
||||
return dist
|
||||
|
|
|
|||
|
|
@ -799,10 +799,12 @@ class AutotagStub:
|
|||
|
||||
def install(self):
|
||||
self.patchers = [
|
||||
patch("beets.plugins.album_for_id", lambda *_: None),
|
||||
patch("beets.plugins.track_for_id", lambda *_: None),
|
||||
patch("beets.plugins.candidates", self.candidates),
|
||||
patch("beets.plugins.item_candidates", self.item_candidates),
|
||||
patch("beets.metadata_plugins.album_for_id", lambda *_: None),
|
||||
patch("beets.metadata_plugins.track_for_id", lambda *_: None),
|
||||
patch("beets.metadata_plugins.candidates", self.candidates),
|
||||
patch(
|
||||
"beets.metadata_plugins.item_candidates", self.item_candidates
|
||||
),
|
||||
]
|
||||
for p in self.patchers:
|
||||
p.start()
|
||||
|
|
|
|||
|
|
@ -49,3 +49,8 @@ disallow_untyped_decorators = true
|
|||
disallow_any_generics = true
|
||||
check_untyped_defs = true
|
||||
allow_redefinition = true
|
||||
|
||||
[[mypy-beets.metadata_plugins]]
|
||||
disallow_untyped_decorators = true
|
||||
disallow_any_generics = true
|
||||
check_untyped_defs = true
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class MbsyncCliTest(PluginTestCase):
|
|||
plugin = "mbsync"
|
||||
|
||||
@patch(
|
||||
"beets.plugins.album_for_id",
|
||||
"beets.metadata_plugins.album_for_id",
|
||||
Mock(
|
||||
side_effect=lambda *_: AlbumInfo(
|
||||
album_id="album id",
|
||||
|
|
@ -33,7 +33,7 @@ class MbsyncCliTest(PluginTestCase):
|
|||
),
|
||||
)
|
||||
@patch(
|
||||
"beets.plugins.track_for_id",
|
||||
"beets.metadata_plugins.track_for_id",
|
||||
Mock(
|
||||
side_effect=lambda *_: TrackInfo(
|
||||
track_id="singleton id", title="new title"
|
||||
|
|
|
|||
|
|
@ -913,7 +913,9 @@ def album_candidates_mock(*args, **kwargs):
|
|||
)
|
||||
|
||||
|
||||
@patch("beets.plugins.candidates", Mock(side_effect=album_candidates_mock))
|
||||
@patch(
|
||||
"beets.metadata_plugins.candidates", Mock(side_effect=album_candidates_mock)
|
||||
)
|
||||
class ImportDuplicateAlbumTest(PluginMixin, ImportTestCase):
|
||||
plugin = "musicbrainz"
|
||||
|
||||
|
|
@ -1031,7 +1033,10 @@ def item_candidates_mock(*args, **kwargs):
|
|||
)
|
||||
|
||||
|
||||
@patch("beets.plugins.item_candidates", Mock(side_effect=item_candidates_mock))
|
||||
@patch(
|
||||
"beets.metadata_plugins.item_candidates",
|
||||
Mock(side_effect=item_candidates_mock),
|
||||
)
|
||||
class ImportDuplicateSingletonTest(ImportTestCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
|
@ -1567,8 +1572,14 @@ def mocked_get_track_by_id(id_):
|
|||
)
|
||||
|
||||
|
||||
@patch("beets.plugins.track_for_id", Mock(side_effect=mocked_get_track_by_id))
|
||||
@patch("beets.plugins.album_for_id", Mock(side_effect=mocked_get_album_by_id))
|
||||
@patch(
|
||||
"beets.metadata_plugins.track_for_id",
|
||||
Mock(side_effect=mocked_get_track_by_id),
|
||||
)
|
||||
@patch(
|
||||
"beets.metadata_plugins.album_for_id",
|
||||
Mock(side_effect=mocked_get_album_by_id),
|
||||
)
|
||||
class ImportIdTest(ImportTestCase):
|
||||
ID_RELEASE_0 = "00000000-0000-0000-0000-000000000000"
|
||||
ID_RELEASE_1 = "11111111-1111-1111-1111-111111111111"
|
||||
|
|
|
|||
|
|
@ -1024,7 +1024,9 @@ class ConfigTest(TestPluginTestCase):
|
|||
file.write("plugins: test")
|
||||
|
||||
self.run_command("--config", self.cli_config_path, "plugin", lib=None)
|
||||
assert plugins.find_plugins()[0].is_test_plugin
|
||||
plugs = plugins.find_plugins()
|
||||
assert len(plugs) == 1
|
||||
assert plugs[0].is_test_plugin
|
||||
self.unload_plugins()
|
||||
|
||||
def test_beetsdir_config(self):
|
||||
|
|
|
|||
Loading…
Reference in a new issue