Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cofiem committed Jan 12, 2025
1 parent e9e7bb8 commit b09da40
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 15 deletions.
4 changes: 3 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
support
.coverage
Dockerfile
http_cache.sqlite
http_cache.sqlite
.env*
_version.py
6 changes: 6 additions & 0 deletions .github/workflows/test-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ jobs:
- name: Install hatch
run: pipx install hatch

- name: Prepare for tests
run: |
echo "MUSIC_PLAYLISTS_TIME_ZONE = 'Australia/Brisbane'" >> .env.toml
echo "MUSIC_PLAYLISTS_BASE_PATH = '.'" >> .env.toml
echo "LASTFM_AUTH_API_KEY = 'not-set'" >> .env.toml
- name: Run tests
run: hatch run cov

Expand Down
11 changes: 10 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ FROM python:3.12

RUN python -m pip install hatch

COPY . .
RUN mkdir /opt/music-playlists
WORKDIR /opt/music-playlists

COPY . /opt/music-playlists
RUN echo "MUSIC_PLAYLISTS_TIME_ZONE = 'Australia/Brisbane'" >> .env.toml && \
echo "MUSIC_PLAYLISTS_BASE_PATH = '.'" >> .env.toml && \
echo "LASTFM_AUTH_API_KEY = 'not-set'" >> .env.toml && \
cat .env.toml && \
pwd && \
ls -la

RUN hatch run cov
32 changes: 19 additions & 13 deletions src/music_playlists/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,6 @@ def __init__(self):
self._last_fm = last_fm.Manage(d, tz, s.lastfm_api_key)
self._radio_4zzz = radio_4zzz.Manage(d, tz)

# services
self._spotify_client = spotify.Client(
d,
s.spotify_redirect_uri,
s.spotify_client_id,
s.spotify_client_secret,
s.spotify_refresh_token,
)
self._spotify = spotify.Manage(d, self._spotify_client)

self._youtube_music_client = youtube_music.Client(d, s.youtube_music_config)
self._youtube_music = youtube_music.Manage(d, self._youtube_music_client)

# processing
self._intermediate = inter.Manage()

Expand Down Expand Up @@ -90,6 +77,8 @@ def source_run(self, name: str):
def services_update(self):
logger.info("Updating music playlists.")

self._init_services()

self._spotify.client.login()
self._youtube_music.client.login()

Expand Down Expand Up @@ -193,6 +182,23 @@ def update_youtube_music(self, track_list: inter.TrackList, playlist_id: str):
),
)

def _init_services(self):
s = self._settings
d = self._downloader

# services
self._spotify_client = spotify.Client(
d,
s.spotify_redirect_uri,
s.spotify_client_id,
s.spotify_client_secret,
s.spotify_refresh_token,
)
self._spotify = spotify.Manage(d, self._spotify_client)

self._youtube_music_client = youtube_music.Client(d, s.youtube_music_config)
self._youtube_music = youtube_music.Manage(d, self._youtube_music_client)

def _find_tracks(
self, service_name: str, tracks: list[inter.Track], search_func, embedded_func
):
Expand Down

0 comments on commit b09da40

Please sign in to comment.