diff --git a/musync/__init__.py b/musync/__init__.py index e69de29..60716d9 100644 --- a/musync/__init__.py +++ b/musync/__init__.py @@ -0,0 +1,3 @@ +from pathlib import Path + +ROOT_DIR = Path(__file__).parent.parent.resolve() diff --git a/musync/common/__init__.py b/musync/common/__init__.py new file mode 100644 index 0000000..36b0e44 --- /dev/null +++ b/musync/common/__init__.py @@ -0,0 +1,2 @@ +from .session import Session +from .sync_manager import SyncManager diff --git a/musync/entity/__init__.py b/musync/common/entity/__init__.py similarity index 100% rename from musync/entity/__init__.py rename to musync/common/entity/__init__.py diff --git a/musync/entity/artist.py b/musync/common/entity/artist.py similarity index 93% rename from musync/entity/artist.py rename to musync/common/entity/artist.py index a70394e..b6ba5be 100644 --- a/musync/entity/artist.py +++ b/musync/common/entity/artist.py @@ -4,7 +4,7 @@ import tidalapi as tidal -from musync.entity.origin import Origin +from musync.common.entity.origin import Origin @dataclass(frozen=True, slots=True) diff --git a/musync/entity/origin.py b/musync/common/entity/origin.py similarity index 100% rename from musync/entity/origin.py rename to musync/common/entity/origin.py diff --git a/musync/entity/playlist.py b/musync/common/entity/playlist.py similarity index 95% rename from musync/entity/playlist.py rename to musync/common/entity/playlist.py index 5ff7077..9a6ca74 100644 --- a/musync/entity/playlist.py +++ b/musync/common/entity/playlist.py @@ -4,7 +4,7 @@ import tidalapi as tidal -from musync.entity.origin import Origin +from musync.common.entity.origin import Origin @dataclass(frozen=True, slots=True) diff --git a/musync/entity/track.py b/musync/common/entity/track.py similarity index 97% rename from musync/entity/track.py rename to musync/common/entity/track.py index 7b7ea49..8ecd050 100644 --- a/musync/entity/track.py +++ b/musync/common/entity/track.py @@ -8,8 +8,8 @@ import pytz import tidalapi -from musync.entity.origin import Origin -from musync.entity.utils import normalize_str +from musync.common.entity.origin import Origin +from musync.common.entity.utils import normalize_str @dataclass(frozen=True, slots=True) diff --git a/musync/entity/user.py b/musync/common/entity/user.py similarity index 93% rename from musync/entity/user.py rename to musync/common/entity/user.py index e02025c..9a8ebdf 100644 --- a/musync/entity/user.py +++ b/musync/common/entity/user.py @@ -4,7 +4,7 @@ import tidalapi as tidal -from musync.entity.origin import Origin +from musync.common.entity.origin import Origin @dataclass(frozen=True, slots=True) diff --git a/musync/entity/utils.py b/musync/common/entity/utils.py similarity index 100% rename from musync/entity/utils.py rename to musync/common/entity/utils.py diff --git a/musync/error.py b/musync/common/error.py similarity index 100% rename from musync/error.py rename to musync/common/error.py diff --git a/musync/session.py b/musync/common/session.py similarity index 92% rename from musync/session.py rename to musync/common/session.py index 1205eff..2f69b90 100644 --- a/musync/session.py +++ b/musync/common/session.py @@ -4,7 +4,7 @@ import spotipy import tidalapi -from musync.entity import Playlist, Track, User +from musync.common.entity import Playlist, Track, User class Session(ABC): diff --git a/musync/sync_manager.py b/musync/common/sync_manager.py similarity index 96% rename from musync/sync_manager.py rename to musync/common/sync_manager.py index 3e7837d..c099d11 100644 --- a/musync/sync_manager.py +++ b/musync/common/sync_manager.py @@ -1,7 +1,7 @@ import warnings -from musync.entity import Playlist, Track -from musync.error import MissingPrivilegesError, TrackNotFoundWarning +from musync.common.entity import Playlist, Track +from musync.common.error import MissingPrivilegesError, TrackNotFoundWarning from musync.spotify import SpotifySession from musync.tidal import TidalSession diff --git a/musync/spotify/session.py b/musync/spotify/session.py index c31f81f..c846163 100644 --- a/musync/spotify/session.py +++ b/musync/spotify/session.py @@ -4,8 +4,8 @@ import spotipy from dotenv import load_dotenv -from musync.entity import Artist, Origin, Playlist, Track, User -from musync.session import Session +from musync.common.entity import Artist, Origin, Playlist, Track, User +from musync.common import Session load_dotenv() diff --git a/musync/tidal/session.py b/musync/tidal/session.py index 1a54779..d6d13c8 100644 --- a/musync/tidal/session.py +++ b/musync/tidal/session.py @@ -1,20 +1,18 @@ -from pathlib import Path from typing import Iterable import tidalapi -from musync.entity import Artist, Origin, Playlist, Track, User -from musync.error import IncompatibleEntityError, MissingPrivilegesError -from musync.session import Session - -TIDAL_DIR = Path(__file__).parent.parent.parent.resolve() +from musync import ROOT_DIR +from musync.common.entity import Artist, Origin, Playlist, Track, User +from musync.common.error import IncompatibleEntityError, MissingPrivilegesError +from musync.common.session import Session class TidalSession(Session): _client: tidalapi.Session def __init__(self) -> None: - session_file = TIDAL_DIR / "tidal-session-oauth.json" + session_file = ROOT_DIR / "tidal-session-oauth.json" self._client = tidalapi.Session() self._client.login_session_file(session_file) diff --git a/tests/integrationtests/spotify/test_session.py b/tests/integrationtests/spotify/test_session.py index e4878bc..3369165 100644 --- a/tests/integrationtests/spotify/test_session.py +++ b/tests/integrationtests/spotify/test_session.py @@ -3,9 +3,9 @@ import pytest -from musync.entity import Origin, Playlist, Track, User +from musync.common.entity import Origin, Playlist, Track, User from musync.spotify import SpotifySession -from tests.unittests.entity import DATA_DIR +from tests.unittests.common.entity import DATA_DIR @pytest.fixture diff --git a/tests/integrationtests/test_sync_manager.py b/tests/integrationtests/test_sync_manager.py index 097db82..af2228a 100644 --- a/tests/integrationtests/test_sync_manager.py +++ b/tests/integrationtests/test_sync_manager.py @@ -1,8 +1,8 @@ import pytest -from musync.entity import Playlist, Track +from musync.common import SyncManager +from musync.common.entity import Playlist, Track from musync.spotify import SpotifySession -from musync.sync_manager import SyncManager from musync.tidal import TidalSession diff --git a/tests/integrationtests/tidal/test_session.py b/tests/integrationtests/tidal/test_session.py index aac807b..ca70bcb 100644 --- a/tests/integrationtests/tidal/test_session.py +++ b/tests/integrationtests/tidal/test_session.py @@ -3,9 +3,9 @@ import pytest -from musync.entity import Origin, Playlist, Track, User +from musync.common.entity import Origin, Playlist, Track, User from musync.tidal import TidalSession -from tests.unittests.entity import DATA_DIR +from tests.unittests.common.entity import DATA_DIR @pytest.fixture diff --git a/tests/unittests/common/__init__.py b/tests/unittests/common/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/unittests/entity/__init__.py b/tests/unittests/common/entity/__init__.py similarity index 100% rename from tests/unittests/entity/__init__.py rename to tests/unittests/common/entity/__init__.py diff --git a/tests/unittests/entity/data/test_artist_spotify.pkl b/tests/unittests/common/entity/data/test_artist_spotify.pkl similarity index 100% rename from tests/unittests/entity/data/test_artist_spotify.pkl rename to tests/unittests/common/entity/data/test_artist_spotify.pkl diff --git a/tests/unittests/entity/data/test_artist_tidal.pkl b/tests/unittests/common/entity/data/test_artist_tidal.pkl similarity index 100% rename from tests/unittests/entity/data/test_artist_tidal.pkl rename to tests/unittests/common/entity/data/test_artist_tidal.pkl diff --git a/tests/unittests/entity/data/test_playlist_spotify.pkl b/tests/unittests/common/entity/data/test_playlist_spotify.pkl similarity index 100% rename from tests/unittests/entity/data/test_playlist_spotify.pkl rename to tests/unittests/common/entity/data/test_playlist_spotify.pkl diff --git a/tests/unittests/entity/data/test_playlist_tidal.pkl b/tests/unittests/common/entity/data/test_playlist_tidal.pkl similarity index 100% rename from tests/unittests/entity/data/test_playlist_tidal.pkl rename to tests/unittests/common/entity/data/test_playlist_tidal.pkl diff --git a/tests/unittests/entity/data/test_track_spotify.pkl b/tests/unittests/common/entity/data/test_track_spotify.pkl similarity index 100% rename from tests/unittests/entity/data/test_track_spotify.pkl rename to tests/unittests/common/entity/data/test_track_spotify.pkl diff --git a/tests/unittests/entity/data/test_track_spotify_alternative.pkl b/tests/unittests/common/entity/data/test_track_spotify_alternative.pkl similarity index 100% rename from tests/unittests/entity/data/test_track_spotify_alternative.pkl rename to tests/unittests/common/entity/data/test_track_spotify_alternative.pkl diff --git a/tests/unittests/entity/data/test_track_tidal.pkl b/tests/unittests/common/entity/data/test_track_tidal.pkl similarity index 100% rename from tests/unittests/entity/data/test_track_tidal.pkl rename to tests/unittests/common/entity/data/test_track_tidal.pkl diff --git a/tests/unittests/entity/data/test_user_spotify.pkl b/tests/unittests/common/entity/data/test_user_spotify.pkl similarity index 100% rename from tests/unittests/entity/data/test_user_spotify.pkl rename to tests/unittests/common/entity/data/test_user_spotify.pkl diff --git a/tests/unittests/entity/data/test_user_tidal.pkl b/tests/unittests/common/entity/data/test_user_tidal.pkl similarity index 100% rename from tests/unittests/entity/data/test_user_tidal.pkl rename to tests/unittests/common/entity/data/test_user_tidal.pkl diff --git a/tests/unittests/entity/test_artist.py b/tests/unittests/common/entity/test_artist.py similarity index 88% rename from tests/unittests/entity/test_artist.py rename to tests/unittests/common/entity/test_artist.py index e53ba79..0e6931e 100644 --- a/tests/unittests/entity/test_artist.py +++ b/tests/unittests/common/entity/test_artist.py @@ -2,8 +2,8 @@ import pytest -from musync.entity import Artist, Origin -from tests.unittests.entity import DATA_DIR +from musync.common.entity import Artist, Origin +from tests.unittests.common.entity import DATA_DIR @pytest.fixture diff --git a/tests/unittests/entity/test_playlist.py b/tests/unittests/common/entity/test_playlist.py similarity index 90% rename from tests/unittests/entity/test_playlist.py rename to tests/unittests/common/entity/test_playlist.py index f3fbf59..f2e350a 100644 --- a/tests/unittests/entity/test_playlist.py +++ b/tests/unittests/common/entity/test_playlist.py @@ -2,8 +2,8 @@ import pytest -from musync.entity import Origin, Playlist -from tests.unittests.entity import DATA_DIR +from musync.common.entity import Origin, Playlist +from tests.unittests.common.entity import DATA_DIR @pytest.fixture diff --git a/tests/unittests/entity/test_track.py b/tests/unittests/common/entity/test_track.py similarity index 96% rename from tests/unittests/entity/test_track.py rename to tests/unittests/common/entity/test_track.py index 180885e..b7b6e9c 100644 --- a/tests/unittests/entity/test_track.py +++ b/tests/unittests/common/entity/test_track.py @@ -5,8 +5,8 @@ import pytest import pytz -from musync.entity import Origin, Track -from tests.unittests.entity import DATA_DIR +from musync.common.entity import Origin, Track +from tests.unittests.common.entity import DATA_DIR @pytest.fixture( diff --git a/tests/unittests/entity/test_user.py b/tests/unittests/common/entity/test_user.py similarity index 87% rename from tests/unittests/entity/test_user.py rename to tests/unittests/common/entity/test_user.py index f334fdf..2772467 100644 --- a/tests/unittests/entity/test_user.py +++ b/tests/unittests/common/entity/test_user.py @@ -2,8 +2,8 @@ import pytest -from musync.entity import Origin, User -from tests.unittests.entity import DATA_DIR +from musync.common.entity import Origin, User +from tests.unittests.common.entity import DATA_DIR @pytest.fixture diff --git a/tests/unittests/test_root_dir.py b/tests/unittests/test_root_dir.py new file mode 100644 index 0000000..1f61de8 --- /dev/null +++ b/tests/unittests/test_root_dir.py @@ -0,0 +1,6 @@ +from musync import ROOT_DIR + + +def test_root_dir(): + musync_dir = ROOT_DIR / "musync" + assert musync_dir.exists()