From d3d756d5f49dab27baad42b7ccc5b547a03a726d Mon Sep 17 00:00:00 2001 From: Jacob Pavlock Date: Wed, 14 Dec 2022 09:01:00 -0800 Subject: [PATCH] refactor!: remove plugin sub-directory and package Now, rather than having to import an api function as `moe.plugins.add.add_item`, it's just `moe.add.add_item`. --- README.rst | 4 +- docs/developers/api/core.rst | 42 +++++++++---------- docs/developers/api/hooks.cli.rst | 2 +- docs/developers/api/hooks.core.rst | 8 ++-- docs/developers/writing_plugins.rst | 4 +- docs/plugins/move.rst | 2 +- moe/{plugins => }/add/__init__.py | 0 moe/{plugins => }/add/add_cli.py | 10 ++--- moe/{plugins => }/add/add_core.py | 2 +- moe/config.py | 24 +++++------ moe/{plugins => }/duplicate/__init__.py | 0 moe/{plugins => }/duplicate/dup_cli.py | 2 +- moe/{plugins => }/duplicate/dup_core.py | 2 +- moe/{plugins => }/edit/__init__.py | 0 moe/{plugins => }/edit/edit_cli.py | 2 +- moe/{plugins => }/edit/edit_core.py | 0 moe/library/track.py | 2 +- moe/{plugins => }/list.py | 0 moe/{plugins => }/moe_import/__init__.py | 0 moe/{plugins => }/moe_import/import_cli.py | 4 +- moe/{plugins => }/moe_import/import_core.py | 2 +- moe/{plugins => }/move/__init__.py | 0 moe/{plugins => }/move/move_cli.py | 2 +- moe/{plugins => }/move/move_core.py | 2 +- moe/{plugins => }/musicbrainz/__init__.py | 0 moe/{plugins => }/musicbrainz/mb_cli.py | 6 +-- moe/{plugins => }/musicbrainz/mb_core.py | 2 +- moe/plugins/__init__.py | 1 - moe/{plugins => }/read/__init__.py | 0 moe/{plugins => }/read/read_cli.py | 2 +- moe/{plugins => }/read/read_core.py | 0 moe/{plugins => }/remove/__init__.py | 0 moe/{plugins => }/remove/rm_cli.py | 2 +- moe/{plugins => }/remove/rm_core.py | 0 moe/{plugins => }/sync/__init__.py | 0 moe/{plugins => }/sync/sync_cli.py | 2 +- moe/{plugins => }/sync/sync_core.py | 0 moe/{plugins => }/write.py | 2 +- tests/{plugins => }/add/test_add_cli.py | 10 ++--- tests/{plugins => }/add/test_add_core.py | 16 +++---- tests/conftest.py | 4 +- tests/{plugins => }/duplicate/test_dup_cli.py | 4 +- .../{plugins => }/duplicate/test_dup_core.py | 6 +-- tests/{plugins => }/edit/__init__.py | 0 tests/{plugins => }/edit/test_edit_cli.py | 6 +-- tests/{plugins => }/edit/test_edit_core.py | 2 +- tests/{plugins => }/import/test_import_cli.py | 27 ++++++------ .../{plugins => }/import/test_import_core.py | 11 +++-- tests/library/test_album.py | 2 +- tests/library/test_track.py | 2 +- tests/{plugins => }/move/test_move_cli.py | 4 +- tests/{plugins => }/move/test_move_core.py | 12 +++--- tests/{plugins => }/musicbrainz/__init__.py | 0 .../musicbrainz/resources/__init__.py | 0 .../musicbrainz/resources/collection.py | 0 .../musicbrainz/resources/full_release.py | 0 .../musicbrainz/resources/min_release.py | 0 .../musicbrainz/resources/multi_disc.py | 0 .../{plugins => }/musicbrainz/test_mb_cli.py | 18 ++++---- .../{plugins => }/musicbrainz/test_mb_core.py | 6 +-- tests/plugins/__init__.py | 1 - tests/{plugins => }/read/test_read_cli.py | 6 +-- tests/{plugins => }/read/test_read_core.py | 2 +- tests/{plugins => }/remove/__init__.py | 0 tests/{plugins => }/remove/test_rm_cli.py | 4 +- tests/{plugins => }/remove/test_rm_core.py | 2 +- tests/{plugins => }/sync/test_sync_cli.py | 6 +-- tests/{plugins => }/sync/test_sync_core.py | 2 +- tests/test_config.py | 2 +- tests/{plugins => }/test_list.py | 2 +- tests/{plugins => }/test_write.py | 4 +- 71 files changed, 144 insertions(+), 150 deletions(-) rename moe/{plugins => }/add/__init__.py (100%) rename moe/{plugins => }/add/add_cli.py (93%) rename moe/{plugins => }/add/add_core.py (97%) rename moe/{plugins => }/duplicate/__init__.py (100%) rename moe/{plugins => }/duplicate/dup_cli.py (99%) rename moe/{plugins => }/duplicate/dup_core.py (99%) rename moe/{plugins => }/edit/__init__.py (100%) rename moe/{plugins => }/edit/edit_cli.py (98%) rename moe/{plugins => }/edit/edit_core.py (100%) rename moe/{plugins => }/list.py (100%) rename moe/{plugins => }/moe_import/__init__.py (100%) rename moe/{plugins => }/moe_import/import_cli.py (99%) rename moe/{plugins => }/moe_import/import_core.py (98%) rename moe/{plugins => }/move/__init__.py (100%) rename moe/{plugins => }/move/move_cli.py (98%) rename moe/{plugins => }/move/move_core.py (99%) rename moe/{plugins => }/musicbrainz/__init__.py (100%) rename moe/{plugins => }/musicbrainz/mb_cli.py (95%) rename moe/{plugins => }/musicbrainz/mb_core.py (99%) delete mode 100644 moe/plugins/__init__.py rename moe/{plugins => }/read/__init__.py (100%) rename moe/{plugins => }/read/read_cli.py (97%) rename moe/{plugins => }/read/read_core.py (100%) rename moe/{plugins => }/remove/__init__.py (100%) rename moe/{plugins => }/remove/rm_cli.py (96%) rename moe/{plugins => }/remove/rm_core.py (100%) rename moe/{plugins => }/sync/__init__.py (100%) rename moe/{plugins => }/sync/sync_cli.py (95%) rename moe/{plugins => }/sync/sync_core.py (100%) rename moe/{plugins => }/write.py (98%) rename tests/{plugins => }/add/test_add_cli.py (94%) rename tests/{plugins => }/add/test_add_core.py (93%) rename tests/{plugins => }/duplicate/test_dup_cli.py (97%) rename tests/{plugins => }/duplicate/test_dup_core.py (97%) rename tests/{plugins => }/edit/__init__.py (100%) rename tests/{plugins => }/edit/test_edit_cli.py (96%) rename tests/{plugins => }/edit/test_edit_core.py (98%) rename tests/{plugins => }/import/test_import_cli.py (92%) rename tests/{plugins => }/import/test_import_core.py (91%) rename tests/{plugins => }/move/test_move_cli.py (93%) rename tests/{plugins => }/move/test_move_core.py (97%) rename tests/{plugins => }/musicbrainz/__init__.py (100%) rename tests/{plugins => }/musicbrainz/resources/__init__.py (100%) rename tests/{plugins => }/musicbrainz/resources/collection.py (100%) rename tests/{plugins => }/musicbrainz/resources/full_release.py (100%) rename tests/{plugins => }/musicbrainz/resources/min_release.py (100%) rename tests/{plugins => }/musicbrainz/resources/multi_disc.py (100%) rename tests/{plugins => }/musicbrainz/test_mb_cli.py (87%) rename tests/{plugins => }/musicbrainz/test_mb_core.py (99%) delete mode 100644 tests/plugins/__init__.py rename tests/{plugins => }/read/test_read_cli.py (94%) rename tests/{plugins => }/read/test_read_core.py (97%) rename tests/{plugins => }/remove/__init__.py (100%) rename tests/{plugins => }/remove/test_rm_cli.py (94%) rename tests/{plugins => }/remove/test_rm_core.py (99%) rename tests/{plugins => }/sync/test_sync_cli.py (85%) rename tests/{plugins => }/sync/test_sync_core.py (96%) rename tests/{plugins => }/test_list.py (98%) rename tests/{plugins => }/test_write.py (98%) diff --git a/README.rst b/README.rst index f54bf9ab..50ca4551 100644 --- a/README.rst +++ b/README.rst @@ -22,10 +22,10 @@ Finally, although a lot of Moe's functionality exists around the idea of operati import argparse import pathlib - import moe.plugins.musicbrainz as moe_mb + import moe.musicbrainz as moe_mb from moe.config import Config, ConfigValidationError from moe.library import Album - from moe.plugins.write import write_tags + from moe.write import write_tags def main(): diff --git a/docs/developers/api/core.rst b/docs/developers/api/core.rst index dacb238e..6eab91b6 100644 --- a/docs/developers/api/core.rst +++ b/docs/developers/api/core.rst @@ -44,75 +44,75 @@ Query Plugins ======= -``moe.plugins`` +``moe`` Add --- -``moe.plugins.add`` +``moe.add`` -.. automodule:: moe.plugins.add +.. automodule:: moe.add :members: Duplicate --------- -``moe.plugins.duplicate`` +``moe.duplicate`` -.. automodule:: moe.plugins.duplicate +.. automodule:: moe.duplicate :members: Edit ---- -``moe.plugins.edit`` +``moe.edit`` -.. automodule:: moe.plugins.edit +.. automodule:: moe.edit :members: Import ------ -``moe.plugins.moe_import`` +``moe.moe_import`` -.. automodule:: moe.plugins.moe_import +.. automodule:: moe.moe_import :members: :exclude-members: match_value_pct Move ---- -``moe.plugins.move`` +``moe.move`` -.. automodule:: moe.plugins.move +.. automodule:: moe.move :members: Musicbrainz ----------- -``moe.plugins.musicbrainz`` +``moe.musicbrainz`` -.. automodule:: moe.plugins.musicbrainz +.. automodule:: moe.musicbrainz :members: Read ---- -``moe.plugins.read`` +``moe.read`` -.. automodule:: moe.plugins.read +.. automodule:: moe.read :members: Remove ------ -``moe.plugins.remove`` +``moe.remove`` -.. automodule:: moe.plugins.remove +.. automodule:: moe.remove :members: Sync ---- -``moe.plugins.sync`` +``moe.sync`` -.. automodule:: moe.plugins.sync +.. automodule:: moe.sync :members: Write ----- -``moe.plugins.write`` +``moe.write`` -.. automodule:: moe.plugins.write +.. automodule:: moe.write :members: diff --git a/docs/developers/api/hooks.cli.rst b/docs/developers/api/hooks.cli.rst index 3a1e8614..41124d0d 100644 --- a/docs/developers/api/hooks.cli.rst +++ b/docs/developers/api/hooks.cli.rst @@ -15,5 +15,5 @@ Plugins Import ------ -.. autoclass:: moe.plugins.moe_import.import_cli.Hooks +.. autoclass:: moe.moe_import.import_cli.Hooks :members: diff --git a/docs/developers/api/hooks.core.rst b/docs/developers/api/hooks.core.rst index 4a47a4e1..fa8a9fe5 100644 --- a/docs/developers/api/hooks.core.rst +++ b/docs/developers/api/hooks.core.rst @@ -42,20 +42,20 @@ Plugins Add --- -.. autoclass:: moe.plugins.add.add_core.Hooks +.. autoclass:: moe.add.add_core.Hooks :members: Import ------ -.. autoclass:: moe.plugins.moe_import.import_core.Hooks +.. autoclass:: moe.moe_import.import_core.Hooks :members: Move ---- -.. autoclass:: moe.plugins.move.move_core.Hooks +.. autoclass:: moe.move.move_core.Hooks :members: Write ----- -.. autoclass:: moe.plugins.write.Hooks +.. autoclass:: moe.write.Hooks :members: diff --git a/docs/developers/writing_plugins.rst b/docs/developers/writing_plugins.rst index c39c1248..c5da75b8 100644 --- a/docs/developers/writing_plugins.rst +++ b/docs/developers/writing_plugins.rst @@ -36,13 +36,13 @@ If you'd like to make your plugin available on pip, there are a few required ste .. note:: It's encouraged that the actual name of your plugin module or package not include the ``moe_`` prefix. The prefix is only necessary for the name of your project on PyPI. -#. Include the `entry_point group `_ ``moe.plugins`` in your ``setup.py`` or ``pyproject.toml``. +#. Include the `entry_point group `_ ``moe`` in your ``setup.py`` or ``pyproject.toml``. * For example, if using *poetry*, include the following in your ``pyproject.toml``. .. code:: toml - [tool.poetry.plugins."moe.plugins"] + [tool.poetry.plugins."moe"] "" = "" .. seealso:: diff --git a/docs/plugins/move.rst b/docs/plugins/move.rst index 96da5b9e..f3403c0e 100644 --- a/docs/plugins/move.rst +++ b/docs/plugins/move.rst @@ -45,7 +45,7 @@ Custom Path Template Functions ============================== Moe allows plugins to create custom path template functions that can be called within the path templates. The function called in the default ``extra_path`` template, ``e_unique``, is an example of a custom path template function. The following custom template functions are included in the move plugin: -.. autofunction:: moe.plugins.move.move_core.e_unique +.. autofunction:: moe.move.move_core.e_unique .. tip:: - For any path formatting changes, run ``moe move -n`` for a dry-run to avoid any unexpected results. diff --git a/moe/plugins/add/__init__.py b/moe/add/__init__.py similarity index 100% rename from moe/plugins/add/__init__.py rename to moe/add/__init__.py diff --git a/moe/plugins/add/add_cli.py b/moe/add/add_cli.py similarity index 93% rename from moe/plugins/add/add_cli.py rename to moe/add/add_cli.py index 9f937326..7e7d5c80 100644 --- a/moe/plugins/add/add_cli.py +++ b/moe/add/add_cli.py @@ -6,10 +6,10 @@ from typing import Optional, cast import moe +import moe.add import moe.cli +from moe.add.add_core import AddError from moe.library import Album, AlbumError, Extra, Track, TrackError -from moe.plugins import add as moe_add -from moe.plugins.add.add_core import AddError from moe.util.cli import PromptChoice from moe.util.cli.query import cli_query @@ -110,15 +110,15 @@ def _add_path(path: Path, album: Optional[Album]): """ if path.is_file(): try: - moe_add.add_item(Track.from_file(path, album=album)) + moe.add.add_item(Track.from_file(path, album=album)) except TrackError: if not album: raise AddError( f"An album query is required to add an extra. [{path=!r}]" ) from None - moe_add.add_item(Extra(album, path)) + moe.add.add_item(Extra(album, path)) elif path.is_dir(): - moe_add.add_item(Album.from_dir(path)) + moe.add.add_item(Album.from_dir(path)) else: raise AddError(f"Path not found. [{path=}]") diff --git a/moe/plugins/add/add_core.py b/moe/add/add_core.py similarity index 97% rename from moe/plugins/add/add_core.py rename to moe/add/add_core.py index d51eeb71..c9687e7d 100644 --- a/moe/plugins/add/add_core.py +++ b/moe/add/add_core.py @@ -48,7 +48,7 @@ def pre_add(item: LibItem): @moe.hookimpl def add_hooks(pm: pluggy.manager.PluginManager): """Registers `add` hookspecs to Moe.""" - from moe.plugins.add.add_core import Hooks + from moe.add.add_core import Hooks pm.add_hookspecs(Hooks) diff --git a/moe/config.py b/moe/config.py index 9e1139f6..e885f4ef 100644 --- a/moe/config.py +++ b/moe/config.py @@ -38,18 +38,18 @@ log = logging.getLogger("moe.config") DEFAULT_PLUGINS = { - "add": "moe.plugins.add", + "add": "moe.add", "cli": "moe.cli", - "duplicate": "moe.plugins.duplicate", - "edit": "moe.plugins.edit", - "import": "moe.plugins.moe_import", - "list": "moe.plugins.list", - "move": "moe.plugins.move", - "musicbrainz": "moe.plugins.musicbrainz", - "read": "moe.plugins.read", - "sync": "moe.plugins.sync", - "remove": "moe.plugins.remove", - "write": "moe.plugins.write", + "duplicate": "moe.duplicate", + "edit": "moe.edit", + "import": "moe.moe_import", + "list": "moe.list", + "move": "moe.move", + "musicbrainz": "moe.musicbrainz", + "read": "moe.read", + "sync": "moe.sync", + "remove": "moe.remove", + "write": "moe.write", } CORE_PLUGINS = { "config": "moe.config", @@ -99,7 +99,7 @@ def add_hooks(pm: pluggy.manager.PluginManager): Example: .. code:: python - from moe.plugins.add import Hooks + from moe.add import Hooks pm.add_hookspecs(Hooks) """ diff --git a/moe/plugins/duplicate/__init__.py b/moe/duplicate/__init__.py similarity index 100% rename from moe/plugins/duplicate/__init__.py rename to moe/duplicate/__init__.py diff --git a/moe/plugins/duplicate/dup_cli.py b/moe/duplicate/dup_cli.py similarity index 99% rename from moe/plugins/duplicate/dup_cli.py rename to moe/duplicate/dup_cli.py index d6ce70de..df1175f4 100644 --- a/moe/plugins/duplicate/dup_cli.py +++ b/moe/duplicate/dup_cli.py @@ -14,7 +14,7 @@ import moe.cli from moe.cli import console from moe.library import Album, Extra, LibItem, Track -from moe.plugins.remove import remove_item +from moe.remove import remove_item from moe.util.cli import PromptChoice, choice_prompt log = logging.getLogger("moe.cli.dup") diff --git a/moe/plugins/duplicate/dup_core.py b/moe/duplicate/dup_core.py similarity index 99% rename from moe/plugins/duplicate/dup_core.py rename to moe/duplicate/dup_core.py index 12c54395..8f4e2493 100644 --- a/moe/plugins/duplicate/dup_core.py +++ b/moe/duplicate/dup_core.py @@ -31,7 +31,7 @@ def resolve_dup_items(item_a: LibItem, item_b: LibItem): 1. The field(s) triggering the duplicate detection is altered on one or both of the items so that they are no longer duplicates. 2. One of the items is removed from the library entirely using - :meth:`~moe.plugins.remove.remove_item`. + :meth:`~moe.remove.remove_item`. Important: Duplicates are determined by each item's diff --git a/moe/plugins/edit/__init__.py b/moe/edit/__init__.py similarity index 100% rename from moe/plugins/edit/__init__.py rename to moe/edit/__init__.py diff --git a/moe/plugins/edit/edit_cli.py b/moe/edit/edit_cli.py similarity index 98% rename from moe/plugins/edit/edit_cli.py rename to moe/edit/edit_cli.py index 3e9d54cf..e2aed169 100644 --- a/moe/plugins/edit/edit_cli.py +++ b/moe/edit/edit_cli.py @@ -5,7 +5,7 @@ import moe import moe.cli -from moe.plugins import edit +from moe import edit from moe.util.cli import cli_query, query_parser log = logging.getLogger("moe.cli.edit") diff --git a/moe/plugins/edit/edit_core.py b/moe/edit/edit_core.py similarity index 100% rename from moe/plugins/edit/edit_core.py rename to moe/edit/edit_core.py diff --git a/moe/library/track.py b/moe/library/track.py index 02225c6b..f1d5d61a 100644 --- a/moe/library/track.py +++ b/moe/library/track.py @@ -89,7 +89,7 @@ def read_custom_tags( See Also: * :ref:`Album and track fields ` * `Mediafile docs `_ - * The :meth:`~moe.plugins.write.Hooks.write_custom_tags` hook for writing + * The :meth:`~moe.write.Hooks.write_custom_tags` hook for writing tags. """ diff --git a/moe/plugins/list.py b/moe/list.py similarity index 100% rename from moe/plugins/list.py rename to moe/list.py diff --git a/moe/plugins/moe_import/__init__.py b/moe/moe_import/__init__.py similarity index 100% rename from moe/plugins/moe_import/__init__.py rename to moe/moe_import/__init__.py diff --git a/moe/plugins/moe_import/import_cli.py b/moe/moe_import/import_cli.py similarity index 99% rename from moe/plugins/moe_import/import_cli.py rename to moe/moe_import/import_cli.py index 3147c4b6..a6f953d8 100644 --- a/moe/plugins/moe_import/import_cli.py +++ b/moe/moe_import/import_cli.py @@ -16,7 +16,7 @@ from moe import config from moe.cli import console from moe.library import Album, MetaAlbum, MetaTrack -from moe.plugins.moe_import.import_core import CandidateAlbum +from moe.moe_import.import_core import CandidateAlbum from moe.util.cli import PromptChoice, choice_prompt from moe.util.core import get_matching_tracks @@ -84,7 +84,7 @@ def add_import_prompt_choice(prompt_choices: list[PromptChoice]): @moe.hookimpl def add_hooks(pm: pluggy.manager.PluginManager): """Registers `import` cli hookspecs to Moe.""" - from moe.plugins.moe_import.import_cli import Hooks + from moe.moe_import.import_cli import Hooks pm.add_hookspecs(Hooks) diff --git a/moe/plugins/moe_import/import_core.py b/moe/moe_import/import_core.py similarity index 98% rename from moe/plugins/moe_import/import_core.py rename to moe/moe_import/import_core.py index eb6e1df5..ea143c6f 100644 --- a/moe/plugins/moe_import/import_core.py +++ b/moe/moe_import/import_core.py @@ -91,7 +91,7 @@ def process_candidates(new_album: Album, candidates: list[CandidateAlbum]): @moe.hookimpl def add_hooks(pm: pluggy.manager.PluginManager): """Registers `import` core hookspecs to Moe.""" - from moe.plugins.moe_import.import_core import Hooks + from moe.moe_import.import_core import Hooks pm.add_hookspecs(Hooks) diff --git a/moe/plugins/move/__init__.py b/moe/move/__init__.py similarity index 100% rename from moe/plugins/move/__init__.py rename to moe/move/__init__.py diff --git a/moe/plugins/move/move_cli.py b/moe/move/move_cli.py similarity index 98% rename from moe/plugins/move/move_cli.py rename to moe/move/move_cli.py index ae26f178..32ec0070 100644 --- a/moe/plugins/move/move_cli.py +++ b/moe/move/move_cli.py @@ -7,8 +7,8 @@ import sqlalchemy.orm import moe +from moe import move as moe_move from moe.library import Album -from moe.plugins import move as moe_move from moe.util.cli import cli_query log = logging.getLogger("moe.cli.move") diff --git a/moe/plugins/move/move_core.py b/moe/move/move_core.py similarity index 99% rename from moe/plugins/move/move_core.py rename to moe/move/move_core.py index 8819d2c9..18883d44 100644 --- a/moe/plugins/move/move_core.py +++ b/moe/move/move_core.py @@ -40,7 +40,7 @@ def create_path_template_func() -> list[Callable]: # type: ignore @moe.hookimpl def add_hooks(pm: pluggy.manager.PluginManager): """Registers `add` hookspecs to Moe.""" - from moe.plugins.move.move_core import Hooks + from moe.move.move_core import Hooks pm.add_hookspecs(Hooks) diff --git a/moe/plugins/musicbrainz/__init__.py b/moe/musicbrainz/__init__.py similarity index 100% rename from moe/plugins/musicbrainz/__init__.py rename to moe/musicbrainz/__init__.py diff --git a/moe/plugins/musicbrainz/mb_cli.py b/moe/musicbrainz/mb_cli.py similarity index 95% rename from moe/plugins/musicbrainz/mb_cli.py rename to moe/musicbrainz/mb_cli.py index a5f740da..827dffa8 100644 --- a/moe/plugins/musicbrainz/mb_cli.py +++ b/moe/musicbrainz/mb_cli.py @@ -15,10 +15,10 @@ import moe import moe.cli +from moe import moe_import +from moe import musicbrainz as moe_mb from moe.library import Album, Extra, Track -from moe.plugins import moe_import -from moe.plugins import musicbrainz as moe_mb -from moe.plugins.moe_import.import_core import CandidateAlbum +from moe.moe_import.import_core import CandidateAlbum from moe.util.cli import PromptChoice, cli_query, query_parser __all__: list[str] = [] diff --git a/moe/plugins/musicbrainz/mb_core.py b/moe/musicbrainz/mb_core.py similarity index 99% rename from moe/plugins/musicbrainz/mb_core.py rename to moe/musicbrainz/mb_core.py index adb69a85..811c22fd 100644 --- a/moe/plugins/musicbrainz/mb_core.py +++ b/moe/musicbrainz/mb_core.py @@ -27,7 +27,7 @@ import moe from moe import config from moe.library import Album, LibItem, MetaAlbum, MetaTrack, Track -from moe.plugins.moe_import.import_core import CandidateAlbum +from moe.moe_import.import_core import CandidateAlbum from moe.util.core import match __all__ = [ diff --git a/moe/plugins/__init__.py b/moe/plugins/__init__.py deleted file mode 100644 index 5c693de0..00000000 --- a/moe/plugins/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Internal plugins.""" diff --git a/moe/plugins/read/__init__.py b/moe/read/__init__.py similarity index 100% rename from moe/plugins/read/__init__.py rename to moe/read/__init__.py diff --git a/moe/plugins/read/read_cli.py b/moe/read/read_cli.py similarity index 97% rename from moe/plugins/read/read_cli.py rename to moe/read/read_cli.py index 03e01ca7..0e5b50fb 100644 --- a/moe/plugins/read/read_cli.py +++ b/moe/read/read_cli.py @@ -5,7 +5,7 @@ import moe import moe.cli -from moe.plugins import read, remove +from moe import read, remove from moe.util.cli import cli_query, query_parser log = logging.getLogger("moe.cli.read") diff --git a/moe/plugins/read/read_core.py b/moe/read/read_core.py similarity index 100% rename from moe/plugins/read/read_core.py rename to moe/read/read_core.py diff --git a/moe/plugins/remove/__init__.py b/moe/remove/__init__.py similarity index 100% rename from moe/plugins/remove/__init__.py rename to moe/remove/__init__.py diff --git a/moe/plugins/remove/rm_cli.py b/moe/remove/rm_cli.py similarity index 96% rename from moe/plugins/remove/rm_cli.py rename to moe/remove/rm_cli.py index f876c8ac..3e9ac54f 100644 --- a/moe/plugins/remove/rm_cli.py +++ b/moe/remove/rm_cli.py @@ -9,7 +9,7 @@ import moe import moe.cli -from moe.plugins import remove as moe_rm +from moe import remove as moe_rm from moe.util.cli import cli_query, query_parser __all__: list[str] = [] diff --git a/moe/plugins/remove/rm_core.py b/moe/remove/rm_core.py similarity index 100% rename from moe/plugins/remove/rm_core.py rename to moe/remove/rm_core.py diff --git a/moe/plugins/sync/__init__.py b/moe/sync/__init__.py similarity index 100% rename from moe/plugins/sync/__init__.py rename to moe/sync/__init__.py diff --git a/moe/plugins/sync/sync_cli.py b/moe/sync/sync_cli.py similarity index 95% rename from moe/plugins/sync/sync_cli.py rename to moe/sync/sync_cli.py index 07dc6a0c..4ce6bdab 100644 --- a/moe/plugins/sync/sync_cli.py +++ b/moe/sync/sync_cli.py @@ -5,7 +5,7 @@ import moe import moe.cli -from moe.plugins import sync as moe_sync +from moe import sync as moe_sync from moe.util.cli import cli_query, query_parser log = logging.getLogger("moe.cli.sync") diff --git a/moe/plugins/sync/sync_core.py b/moe/sync/sync_core.py similarity index 100% rename from moe/plugins/sync/sync_core.py rename to moe/sync/sync_core.py diff --git a/moe/plugins/write.py b/moe/write.py similarity index 98% rename from moe/plugins/write.py rename to moe/write.py index 3a52b2c6..7b8d3332 100644 --- a/moe/plugins/write.py +++ b/moe/write.py @@ -47,7 +47,7 @@ def write_custom_tags(track: Track): @moe.hookimpl def add_hooks(pm: pluggy.manager.PluginManager): """Registers `write` hookspecs to Moe.""" - from moe.plugins.write import Hooks + from moe.write import Hooks pm.add_hookspecs(Hooks) diff --git a/tests/plugins/add/test_add_cli.py b/tests/add/test_add_cli.py similarity index 94% rename from tests/plugins/add/test_add_cli.py rename to tests/add/test_add_cli.py index 3b343a38..754ddd9c 100644 --- a/tests/plugins/add/test_add_cli.py +++ b/tests/add/test_add_cli.py @@ -9,9 +9,9 @@ import moe import moe.cli from moe import config +from moe.add import add_cli from moe.library import Album, Track -from moe.plugins.add import add_cli -from moe.plugins.moe_import.import_core import CandidateAlbum +from moe.moe_import.import_core import CandidateAlbum from moe.util.cli import PromptChoice from tests.conftest import album_factory, extra_factory, track_factory @@ -19,7 +19,7 @@ @pytest.fixture def mock_add() -> Iterator[FunctionType]: """Mock the `add_item()` api call.""" - with patch("moe.plugins.add.add_item", autospec=True) as mock_add: + with patch("moe.add.add_item", autospec=True) as mock_add: yield mock_add @@ -32,7 +32,7 @@ def mock_query() -> Iterator[FunctionType]: Yields: Mock query """ - with patch("moe.plugins.add.add_cli.cli_query", autospec=True) as mock_query: + with patch("moe.add.add_cli.cli_query", autospec=True) as mock_query: yield mock_query @@ -75,7 +75,7 @@ def test_skip_item(self, tmp_config): mock_choice = PromptChoice("mock", "m", add_cli._skip_import) with patch( - "moe.plugins.moe_import.import_cli.choice_prompt", + "moe.moe_import.import_cli.choice_prompt", return_value=mock_choice, autospec=True, ): diff --git a/tests/plugins/add/test_add_core.py b/tests/add/test_add_core.py similarity index 93% rename from tests/plugins/add/test_add_core.py rename to tests/add/test_add_core.py index 0f797d9d..be4911f9 100644 --- a/tests/plugins/add/test_add_core.py +++ b/tests/add/test_add_core.py @@ -3,10 +3,10 @@ import pytest import moe +import moe.add from moe import config from moe.config import ExtraPlugin from moe.library import Album, Extra, LibItem, Track -from moe.plugins import add from tests.conftest import album_factory, extra_factory, track_factory @@ -34,7 +34,7 @@ class TestAddItem: def test_track(self, tmp_session): """We can add tracks to the library.""" track = track_factory() - add.add_item(track) + moe.add.add_item(track) assert tmp_session.query(Track).one() == track @@ -42,7 +42,7 @@ def test_track(self, tmp_session): def test_album(self, tmp_session): """We can add albums to the library.""" album = album_factory() - add.add_item(album) + moe.add.add_item(album) assert tmp_session.query(Album).one() == album @@ -50,7 +50,7 @@ def test_album(self, tmp_session): def test_extra(self, tmp_session): """We can add extras to the library.""" extra = extra_factory() - add.add_item(extra) + moe.add.add_item(extra) assert tmp_session.query(Extra).one() == extra @@ -62,7 +62,7 @@ def test_hooks(self, tmp_config, tmp_session): tmp_db=True, ) - add.add_item(track_factory()) + moe.add.add_item(track_factory()) db_track = tmp_session.query(Track).one() assert db_track.title == "pre_add" @@ -76,7 +76,7 @@ def test_duplicate_list_fields_album(self, tmp_session): track1.genre = "pop" track2.genre = "pop" - add.add_item(album) + moe.add.add_item(album) db_tracks = tmp_session.query(Track).all() for track in db_tracks: @@ -88,8 +88,8 @@ def test_duplicate_list_field_tracks(self, tmp_session): track1 = track_factory(genres={"pop"}) track2 = track_factory(genres={"pop"}) - add.add_item(track1) - add.add_item(track2) + moe.add.add_item(track1) + moe.add.add_item(track2) db_tracks = tmp_session.query(Track).all() for track in db_tracks: diff --git a/tests/conftest.py b/tests/conftest.py index 9667619b..7097b0db 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -13,10 +13,10 @@ import sqlalchemy.exc import sqlalchemy.orm +import moe.write from moe import config from moe.config import Config, ExtraPlugin, MoeSession, session_factory from moe.library import Album, Extra, Track -from moe.plugins import write as moe_write __all__ = ["album_factory", "extra_factory", "track_factory"] @@ -200,7 +200,7 @@ def track_factory( if exists: track.path.parent.mkdir(parents=True, exist_ok=True) shutil.copyfile(EMPTY_MP3_FILE, track.path) - moe_write.write_tags(track) + moe.write.write_tags(track) return track diff --git a/tests/plugins/duplicate/test_dup_cli.py b/tests/duplicate/test_dup_cli.py similarity index 97% rename from tests/plugins/duplicate/test_dup_cli.py rename to tests/duplicate/test_dup_cli.py index 57d1f5ff..f3397822 100644 --- a/tests/plugins/duplicate/test_dup_cli.py +++ b/tests/duplicate/test_dup_cli.py @@ -7,8 +7,8 @@ from moe import config from moe.cli import console +from moe.duplicate import dup_cli from moe.library import Track -from moe.plugins.duplicate import dup_cli from tests.conftest import album_factory, extra_factory, track_factory @@ -28,7 +28,7 @@ def test_choices_called(self): track_b = track_factory() with patch( - "moe.plugins.duplicate.dup_cli.choice_prompt", + "moe.duplicate.dup_cli.choice_prompt", autospec=True, ) as mock_prompt_choice: config.CONFIG.pm.hook.resolve_dup_items(item_a=track_a, item_b=track_b) diff --git a/tests/plugins/duplicate/test_dup_core.py b/tests/duplicate/test_dup_core.py similarity index 97% rename from tests/plugins/duplicate/test_dup_core.py rename to tests/duplicate/test_dup_core.py index ab88f693..25f9b68b 100644 --- a/tests/plugins/duplicate/test_dup_core.py +++ b/tests/duplicate/test_dup_core.py @@ -5,9 +5,9 @@ import pytest import moe +from moe import remove from moe.config import ExtraPlugin, MoeSession from moe.library import Album, Extra, Track -from moe.plugins.remove import remove_item from tests.conftest import album_factory, extra_factory, track_factory @@ -20,9 +20,9 @@ def resolve_dup_items(item_a, item_b): """Resolve duplicates.""" if isinstance(item_a, (Track, Album)): if item_a.title == "remove me": - remove_item(item_a) + remove.remove_item(item_a) if item_b.title == "remove me": - remove_item(item_b) + remove.remove_item(item_b) if item_a.title == "change me": dest = item_a.path.parent / "new.mp3" shutil.copyfile(item_a.path, dest) diff --git a/tests/plugins/edit/__init__.py b/tests/edit/__init__.py similarity index 100% rename from tests/plugins/edit/__init__.py rename to tests/edit/__init__.py diff --git a/tests/plugins/edit/test_edit_cli.py b/tests/edit/test_edit_cli.py similarity index 96% rename from tests/plugins/edit/test_edit_cli.py rename to tests/edit/test_edit_cli.py index a5e4c938..23de80d5 100644 --- a/tests/plugins/edit/test_edit_cli.py +++ b/tests/edit/test_edit_cli.py @@ -8,14 +8,14 @@ import moe.cli from moe import config -from moe.plugins.edit import EditError +from moe.edit import EditError from tests.conftest import album_factory, extra_factory, track_factory @pytest.fixture def mock_edit() -> Iterator[FunctionType]: """Mock the `edit_item()` api call.""" - with patch("moe.plugins.edit.edit_item", autospec=True) as mock_edit: + with patch("moe.edit.edit_item", autospec=True) as mock_edit: yield mock_edit @@ -28,7 +28,7 @@ def mock_query() -> Iterator[FunctionType]: Yields: Mock query """ - with patch("moe.plugins.edit.edit_cli.cli_query", autospec=True) as mock_query: + with patch("moe.edit.edit_cli.cli_query", autospec=True) as mock_query: yield mock_query diff --git a/tests/plugins/edit/test_edit_core.py b/tests/edit/test_edit_core.py similarity index 98% rename from tests/plugins/edit/test_edit_core.py rename to tests/edit/test_edit_core.py index bc69041c..34027a29 100644 --- a/tests/plugins/edit/test_edit_core.py +++ b/tests/edit/test_edit_core.py @@ -4,7 +4,7 @@ import pytest -from moe.plugins import edit +from moe import edit from tests.conftest import album_factory, track_factory diff --git a/tests/plugins/import/test_import_cli.py b/tests/import/test_import_cli.py similarity index 92% rename from tests/plugins/import/test_import_cli.py rename to tests/import/test_import_cli.py index e7304995..bfecb225 100644 --- a/tests/plugins/import/test_import_cli.py +++ b/tests/import/test_import_cli.py @@ -7,11 +7,10 @@ import moe import moe.cli -from moe import config +from moe import config, moe_import from moe.cli import console from moe.config import ExtraPlugin -from moe.plugins import moe_import -from moe.plugins.moe_import.import_core import CandidateAlbum +from moe.moe_import.import_core import CandidateAlbum from moe.util.cli import PromptChoice from tests.conftest import album_factory, extra_factory, track_factory @@ -35,7 +34,7 @@ def test_multi_disc_album(self, tmp_config, tmp_session): mock_choice = PromptChoice("mock", "m", moe_import.import_cli._apply_changes) with patch( - "moe.plugins.moe_import.import_cli.choice_prompt", + "moe.moe_import.import_cli.choice_prompt", return_value=mock_choice, autospec=True, ): @@ -80,7 +79,7 @@ def test_add_import_prompt_choice(self, tmp_config): extra_plugins=[ExtraPlugin(ImportPlugin, "import_plugin")], ) with patch( - "moe.plugins.moe_import.import_cli.choice_prompt", + "moe.moe_import.import_cli.choice_prompt", return_value=ImportPlugin.test_choice, autospec=True, ): @@ -99,7 +98,7 @@ def test_process_candidates(self): mock_candidates = [Mock()] with patch( - "moe.plugins.moe_import.import_cli.candidate_prompt", autospec=True + "moe.moe_import.import_cli.candidate_prompt", autospec=True ) as mock_candidate_prompt: config.CONFIG.pm.hook.process_candidates( new_album=mock_new_album, @@ -111,7 +110,7 @@ def test_process_candidates(self): def test_abort_import(self): """Raise SystemExit if the import is aborted.""" with patch( - "moe.plugins.moe_import.import_cli.candidate_prompt", + "moe.moe_import.import_cli.candidate_prompt", side_effect=moe_import.import_cli.AbortImport, autospec=True, ): @@ -125,7 +124,7 @@ def test_abort_import(self): def test_process_no_candidates(self): """Don't display the import prompt if there are no candidates to process.""" with patch( - "moe.plugins.moe_import.import_cli.candidate_prompt", autospec=True + "moe.moe_import.import_cli.candidate_prompt", autospec=True ) as mock_import_prompt: config.CONFIG.pm.hook.process_candidates(new_album=Mock(), candidates=[]) @@ -166,7 +165,7 @@ def test_apply_tracks(self): mock_choice = PromptChoice("mock", "m", moe_import.import_cli._apply_changes) with patch( - "moe.plugins.moe_import.import_cli.choice_prompt", + "moe.moe_import.import_cli.choice_prompt", return_value=mock_choice, autospec=True, ): @@ -199,12 +198,12 @@ def test_apply_diff_get_track(self): (album.get_track(2), candidate.album.get_track(1)), ] with patch( - "moe.plugins.moe_import.import_cli.get_matching_tracks", + "moe.moe_import.import_cli.get_matching_tracks", return_value=mock_matches, autospec=True, ): with patch( - "moe.plugins.moe_import.import_cli.choice_prompt", + "moe.moe_import.import_cli.choice_prompt", return_value=mock_choice, autospec=True, ): @@ -231,7 +230,7 @@ def test_apply_extras(self): mock_choice = PromptChoice("mock", "m", moe_import.import_cli._apply_changes) with patch( - "moe.plugins.moe_import.import_cli.choice_prompt", + "moe.moe_import.import_cli.choice_prompt", return_value=mock_choice, autospec=True, ): @@ -256,7 +255,7 @@ def test_apply_fields(self): mock_choice = PromptChoice("mock", "m", moe_import.import_cli._apply_changes) with patch( - "moe.plugins.moe_import.import_cli.choice_prompt", + "moe.moe_import.import_cli.choice_prompt", return_value=mock_choice, autospec=True, ): @@ -278,7 +277,7 @@ def test_abort(self): mock_choice = PromptChoice("mock", "m", moe_import.import_cli._abort_changes) with patch( - "moe.plugins.moe_import.import_cli.choice_prompt", + "moe.moe_import.import_cli.choice_prompt", return_value=mock_choice, autospec=True, ): diff --git a/tests/plugins/import/test_import_core.py b/tests/import/test_import_core.py similarity index 91% rename from tests/plugins/import/test_import_core.py rename to tests/import/test_import_core.py index a4c96e98..c9d330b6 100644 --- a/tests/plugins/import/test_import_core.py +++ b/tests/import/test_import_core.py @@ -4,11 +4,10 @@ from unittest.mock import patch import moe -from moe import config +from moe import config, moe_import from moe.config import ExtraPlugin from moe.library import Album -from moe.plugins import moe_import -from moe.plugins.moe_import import CandidateAlbum +from moe.moe_import import CandidateAlbum from tests.conftest import album_factory, extra_factory, track_factory @@ -76,7 +75,7 @@ def test_pre_add_album(self, tmp_config): config = tmp_config("default_plugins = ['add', 'import']") with patch( - "moe.plugins.moe_import.import_core.import_album", autospec=True + "moe.moe_import.import_core.import_album", autospec=True ) as mock_import: config.pm.hook.pre_add(item=album) @@ -88,7 +87,7 @@ def test_pre_add_track(self, tmp_config): tmp_config("default_plugins = ['add', 'import']") with patch( - "moe.plugins.moe_import.import_core.import_album", autospec=True + "moe.moe_import.import_core.import_album", autospec=True ) as mock_import: config.CONFIG.pm.hook.pre_add(item=track) @@ -100,7 +99,7 @@ def test_pre_add_extra(self, tmp_config): tmp_config("default_plugins = ['add', 'import']") with patch( - "moe.plugins.moe_import.import_core.import_album", autospec=True + "moe.moe_import.import_core.import_album", autospec=True ) as mock_import: config.CONFIG.pm.hook.pre_add(item=extra) diff --git a/tests/library/test_album.py b/tests/library/test_album.py index c130b07f..70edbd3a 100644 --- a/tests/library/test_album.py +++ b/tests/library/test_album.py @@ -8,9 +8,9 @@ import moe from moe import config +from moe import write as moe_write from moe.config import ExtraPlugin from moe.library import Album, AlbumError, Extra, MetaAlbum, MetaTrack, Track -from moe.plugins import write as moe_write from tests.conftest import album_factory, track_factory diff --git a/tests/library/test_track.py b/tests/library/test_track.py index d0e7ed00..02dec40e 100644 --- a/tests/library/test_track.py +++ b/tests/library/test_track.py @@ -3,7 +3,7 @@ import pytest import moe -import moe.plugins.write as moe_write +import moe.write as moe_write from moe.config import ExtraPlugin from moe.library import MetaTrack, Track, TrackError from moe.library.album import MetaAlbum diff --git a/tests/plugins/move/test_move_cli.py b/tests/move/test_move_cli.py similarity index 93% rename from tests/plugins/move/test_move_cli.py rename to tests/move/test_move_cli.py index 5add82e2..c46c2e32 100644 --- a/tests/plugins/move/test_move_cli.py +++ b/tests/move/test_move_cli.py @@ -14,7 +14,7 @@ @pytest.fixture def mock_move(): """Mock the `move_item()` api call.""" - with patch("moe.plugins.move.move_item", autospec=True) as mock_edit: + with patch("moe.move.move_item", autospec=True) as mock_edit: yield mock_edit @@ -27,7 +27,7 @@ def mock_query() -> Iterator[FunctionType]: Yields: Mock query """ - with patch("moe.plugins.move.move_cli.cli_query", autospec=True) as mock_query: + with patch("moe.move.move_cli.cli_query", autospec=True) as mock_query: yield mock_query diff --git a/tests/plugins/move/test_move_core.py b/tests/move/test_move_core.py similarity index 97% rename from tests/plugins/move/test_move_core.py rename to tests/move/test_move_core.py index df8345c7..514b2c54 100644 --- a/tests/plugins/move/test_move_core.py +++ b/tests/move/test_move_core.py @@ -6,7 +6,7 @@ import moe from moe import config -from moe.plugins import move as moe_move +from moe import move as moe_move from tests.conftest import album_factory, extra_factory, track_factory @@ -19,7 +19,7 @@ def _tmp_move_config(tmp_config): @pytest.fixture def mock_copy(): """Mock the `move_item()` api call.""" - with patch("moe.plugins.move.move_core.copy_item", autospec=True) as mock_copy: + with patch("moe.move.move_core.copy_item", autospec=True) as mock_copy: yield mock_copy @@ -251,7 +251,7 @@ def test_same_des(self, tmp_path): extra = extra_factory(path=tmp_path / "in my place.mp3", exists=True) og_path = extra.path - with patch("moe.plugins.move.move_core.fmt_item_path", return_value=extra.path): + with patch("moe.move.move_core.fmt_item_path", return_value=extra.path): moe_move.copy_item(extra) assert extra.path == og_path @@ -283,7 +283,7 @@ def test_same_des(self, tmp_path): track = track_factory(path=tmp_path / "in my place.txt", exists=True) og_path = track.path - with patch("moe.plugins.move.move_core.fmt_item_path", return_value=track.path): + with patch("moe.move.move_core.fmt_item_path", return_value=track.path): moe_move.copy_item(track) assert track.path == og_path @@ -403,7 +403,7 @@ def test_same_des(self, tmp_path): extra = extra_factory(path=tmp_path / "in my place.txt", exists=True) og_path = extra.path - with patch("moe.plugins.move.move_core.fmt_item_path", return_value=extra.path): + with patch("moe.move.move_core.fmt_item_path", return_value=extra.path): moe_move.move_item(extra) assert extra.path == og_path @@ -435,7 +435,7 @@ def test_same_des(self, tmp_path): track = track_factory(path=tmp_path / "in my place.mp3", exists=True) og_path = track.path - with patch("moe.plugins.move.move_core.fmt_item_path", return_value=track.path): + with patch("moe.move.move_core.fmt_item_path", return_value=track.path): moe_move.move_item(track) assert track.path == og_path diff --git a/tests/plugins/musicbrainz/__init__.py b/tests/musicbrainz/__init__.py similarity index 100% rename from tests/plugins/musicbrainz/__init__.py rename to tests/musicbrainz/__init__.py diff --git a/tests/plugins/musicbrainz/resources/__init__.py b/tests/musicbrainz/resources/__init__.py similarity index 100% rename from tests/plugins/musicbrainz/resources/__init__.py rename to tests/musicbrainz/resources/__init__.py diff --git a/tests/plugins/musicbrainz/resources/collection.py b/tests/musicbrainz/resources/collection.py similarity index 100% rename from tests/plugins/musicbrainz/resources/collection.py rename to tests/musicbrainz/resources/collection.py diff --git a/tests/plugins/musicbrainz/resources/full_release.py b/tests/musicbrainz/resources/full_release.py similarity index 100% rename from tests/plugins/musicbrainz/resources/full_release.py rename to tests/musicbrainz/resources/full_release.py diff --git a/tests/plugins/musicbrainz/resources/min_release.py b/tests/musicbrainz/resources/min_release.py similarity index 100% rename from tests/plugins/musicbrainz/resources/min_release.py rename to tests/musicbrainz/resources/min_release.py diff --git a/tests/plugins/musicbrainz/resources/multi_disc.py b/tests/musicbrainz/resources/multi_disc.py similarity index 100% rename from tests/plugins/musicbrainz/resources/multi_disc.py rename to tests/musicbrainz/resources/multi_disc.py diff --git a/tests/plugins/musicbrainz/test_mb_cli.py b/tests/musicbrainz/test_mb_cli.py similarity index 87% rename from tests/plugins/musicbrainz/test_mb_cli.py rename to tests/musicbrainz/test_mb_cli.py index a3538e36..4e9023ba 100644 --- a/tests/plugins/musicbrainz/test_mb_cli.py +++ b/tests/musicbrainz/test_mb_cli.py @@ -21,7 +21,7 @@ def mock_query() -> Iterator[FunctionType]: Yields: Mock query """ - with patch("moe.plugins.musicbrainz.mb_cli.cli_query", autospec=True) as mock_query: + with patch("moe.musicbrainz.mb_cli.cli_query", autospec=True) as mock_query: yield mock_query @@ -43,7 +43,7 @@ def test_track(self, mock_query): mock_query.return_value = [track] with patch( - "moe.plugins.musicbrainz.mb_cli.moe_mb.set_collection", autospec=True + "moe.musicbrainz.mb_cli.moe_mb.set_collection", autospec=True ) as mock_set: moe.cli.main(cli_args) @@ -58,7 +58,7 @@ def test_extra(self, mock_query): mock_query.return_value = [extra] with patch( - "moe.plugins.musicbrainz.mb_cli.moe_mb.set_collection", autospec=True + "moe.musicbrainz.mb_cli.moe_mb.set_collection", autospec=True ) as mock_set: moe.cli.main(cli_args) @@ -72,7 +72,7 @@ def test_album(self, mock_query): mock_query.return_value = [album] with patch( - "moe.plugins.musicbrainz.mb_cli.moe_mb.set_collection", autospec=True + "moe.musicbrainz.mb_cli.moe_mb.set_collection", autospec=True ) as mock_set: moe.cli.main(cli_args) @@ -87,7 +87,7 @@ def test_remove(self, mock_query): mock_query.return_value = [track] with patch( - "moe.plugins.musicbrainz.mb_cli.moe_mb.rm_releases_from_collection", + "moe.musicbrainz.mb_cli.moe_mb.rm_releases_from_collection", autospec=True, ) as mock_rm: moe.cli.main(cli_args) @@ -102,7 +102,7 @@ def test_add(self, mock_query): mock_query.return_value = [track] with patch( - "moe.plugins.musicbrainz.mb_cli.moe_mb.add_releases_to_collection", + "moe.musicbrainz.mb_cli.moe_mb.add_releases_to_collection", autospec=True, ) as mock_add: moe.cli.main(cli_args) @@ -141,16 +141,16 @@ def test_enter_id(self, tmp_config): mock_album = Mock() with patch( - "moe.plugins.musicbrainz.mb_cli.questionary.text", + "moe.musicbrainz.mb_cli.questionary.text", **{"return_value.ask.return_value": "new id"} ): with patch( - "moe.plugins.musicbrainz.mb_cli.moe_mb.get_candidate_by_id", + "moe.musicbrainz.mb_cli.moe_mb.get_candidate_by_id", return_value=mock_album, autospec=True, ) as mock_get_candidate: with patch( - "moe.plugins.musicbrainz.mb_cli.moe_import.import_prompt", + "moe.musicbrainz.mb_cli.moe_import.import_prompt", autospec=True, ) as mock_prompt: prompt_choices[0].func(old_album, new_album) diff --git a/tests/plugins/musicbrainz/test_mb_core.py b/tests/musicbrainz/test_mb_core.py similarity index 99% rename from tests/plugins/musicbrainz/test_mb_core.py rename to tests/musicbrainz/test_mb_core.py index d9f7b0b0..a6266fc2 100644 --- a/tests/plugins/musicbrainz/test_mb_core.py +++ b/tests/musicbrainz/test_mb_core.py @@ -6,12 +6,12 @@ import pytest -import tests.plugins.musicbrainz.resources as mb_rsrc +import tests.musicbrainz.resources as mb_rsrc from moe import config +from moe import musicbrainz as moe_mb from moe.config import ConfigValidationError from moe.library import Track -from moe.plugins import musicbrainz as moe_mb -from moe.plugins.musicbrainz.mb_core import MBAuthError +from moe.musicbrainz.mb_core import MBAuthError from tests.conftest import album_factory, track_factory diff --git a/tests/plugins/__init__.py b/tests/plugins/__init__.py deleted file mode 100644 index ebc866f2..00000000 --- a/tests/plugins/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Test plugins.""" diff --git a/tests/plugins/read/test_read_cli.py b/tests/read/test_read_cli.py similarity index 94% rename from tests/plugins/read/test_read_cli.py rename to tests/read/test_read_cli.py index 9bbb5027..b23e2dae 100644 --- a/tests/plugins/read/test_read_cli.py +++ b/tests/read/test_read_cli.py @@ -13,7 +13,7 @@ @pytest.fixture def mock_read(): """Mock the `read_item()` api call.""" - with patch("moe.plugins.read.read_item", autospec=True) as mock_read: + with patch("moe.read.read_item", autospec=True) as mock_read: yield mock_read @@ -26,7 +26,7 @@ def mock_query() -> Iterator[FunctionType]: Yields: Mock query """ - with patch("moe.plugins.read.read_cli.cli_query", autospec=True) as mock_query: + with patch("moe.read.read_cli.cli_query", autospec=True) as mock_query: yield mock_query @@ -105,7 +105,7 @@ def test_rm_item(self, mock_query, mock_read): mock_query.return_value = [track] mock_read.side_effect = FileNotFoundError - with patch("moe.plugins.read.read_cli.remove.remove_item") as mock_rm: + with patch("moe.read.read_cli.remove.remove_item") as mock_rm: moe.cli.main(cli_args) mock_rm.assert_called_once_with(track) diff --git a/tests/plugins/read/test_read_core.py b/tests/read/test_read_core.py similarity index 97% rename from tests/plugins/read/test_read_core.py rename to tests/read/test_read_core.py index 25f7c8d5..8953b071 100644 --- a/tests/plugins/read/test_read_core.py +++ b/tests/read/test_read_core.py @@ -2,8 +2,8 @@ import pytest +from moe import read from moe.library import Album, Track -from moe.plugins import read from tests.conftest import album_factory, track_factory diff --git a/tests/plugins/remove/__init__.py b/tests/remove/__init__.py similarity index 100% rename from tests/plugins/remove/__init__.py rename to tests/remove/__init__.py diff --git a/tests/plugins/remove/test_rm_cli.py b/tests/remove/test_rm_cli.py similarity index 94% rename from tests/plugins/remove/test_rm_cli.py rename to tests/remove/test_rm_cli.py index 00a52d34..7f7d3717 100644 --- a/tests/plugins/remove/test_rm_cli.py +++ b/tests/remove/test_rm_cli.py @@ -13,7 +13,7 @@ @pytest.fixture def mock_rm(): """Mock the `remove_item()` api call.""" - with patch("moe.plugins.remove.remove_item", autospec=True) as mock_rm: + with patch("moe.remove.remove_item", autospec=True) as mock_rm: yield mock_rm @@ -26,7 +26,7 @@ def mock_query() -> Iterator[FunctionType]: Yields: Mock query """ - with patch("moe.plugins.remove.rm_cli.cli_query", autospec=True) as mock_query: + with patch("moe.remove.rm_cli.cli_query", autospec=True) as mock_query: yield mock_query diff --git a/tests/plugins/remove/test_rm_core.py b/tests/remove/test_rm_core.py similarity index 99% rename from tests/plugins/remove/test_rm_core.py rename to tests/remove/test_rm_core.py index 7aa537f5..e03f7a0a 100644 --- a/tests/plugins/remove/test_rm_core.py +++ b/tests/remove/test_rm_core.py @@ -6,9 +6,9 @@ import sqlalchemy.orm import moe +from moe import remove as moe_rm from moe.config import ExtraPlugin, MoeSession from moe.library import Album, Extra, Track -from moe.plugins import remove as moe_rm from tests.conftest import album_factory, extra_factory, track_factory diff --git a/tests/plugins/sync/test_sync_cli.py b/tests/sync/test_sync_cli.py similarity index 85% rename from tests/plugins/sync/test_sync_cli.py rename to tests/sync/test_sync_cli.py index 511e89d8..72d1b809 100644 --- a/tests/plugins/sync/test_sync_cli.py +++ b/tests/sync/test_sync_cli.py @@ -12,9 +12,7 @@ @pytest.fixture def mock_sync(): """Mock the `sync_item()` api call.""" - with patch( - "moe.plugins.sync.sync_cli.moe_sync.sync_item", autospec=True - ) as mock_sync: + with patch("moe.sync.sync_cli.moe_sync.sync_item", autospec=True) as mock_sync: yield mock_sync @@ -27,7 +25,7 @@ def mock_query(): Yields: Mock query """ - with patch("moe.plugins.sync.sync_cli.cli_query", autospec=True) as mock_query: + with patch("moe.sync.sync_cli.cli_query", autospec=True) as mock_query: yield mock_query diff --git a/tests/plugins/sync/test_sync_core.py b/tests/sync/test_sync_core.py similarity index 96% rename from tests/plugins/sync/test_sync_core.py rename to tests/sync/test_sync_core.py index 9de6ea7d..7fffaf5f 100644 --- a/tests/plugins/sync/test_sync_core.py +++ b/tests/sync/test_sync_core.py @@ -2,9 +2,9 @@ import moe from moe import config +from moe import sync as moe_sync from moe.config import ExtraPlugin from moe.library import Track -from moe.plugins import sync as moe_sync from tests.conftest import track_factory diff --git a/tests/test_config.py b/tests/test_config.py index 05240576..343f059c 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -93,7 +93,7 @@ def test_register_local_user_plugins(self, tmp_config, tmp_path_factory): plugin_dir = config_dir / "plugins" plugin_dir.mkdir() - list_path = Path(__file__).resolve().parent.parent / "moe/plugins/list.py" + list_path = Path(__file__).resolve().parent.parent / "moe/list.py" shutil.copyfile(list_path, plugin_dir / "my_list.py") tmp_config(settings="enable_plugins = ['my_list']", config_dir=config_dir) diff --git a/tests/plugins/test_list.py b/tests/test_list.py similarity index 98% rename from tests/plugins/test_list.py rename to tests/test_list.py index 2acaaf65..e2999b33 100644 --- a/tests/plugins/test_list.py +++ b/tests/test_list.py @@ -19,7 +19,7 @@ def mock_query() -> Iterator[FunctionType]: Yields: Mock query """ - with patch("moe.plugins.list.cli_query", autospec=True) as mock_query: + with patch("moe.list.cli_query", autospec=True) as mock_query: yield mock_query diff --git a/tests/plugins/test_write.py b/tests/test_write.py similarity index 98% rename from tests/plugins/test_write.py rename to tests/test_write.py index b1937394..896c7188 100644 --- a/tests/plugins/test_write.py +++ b/tests/test_write.py @@ -8,15 +8,15 @@ import moe from moe import config +from moe import write as moe_write from moe.library import Track -from moe.plugins import write as moe_write from tests.conftest import album_factory, extra_factory, track_factory @pytest.fixture def mock_write(): """Mock the `write_tags` api call.""" - with patch("moe.plugins.write.write_tags", autospec=True) as mock_edit: + with patch("moe.write.write_tags", autospec=True) as mock_edit: yield mock_edit