From 3d7528030ab2eaa796e548a8997d941ba03187a2 Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Sat, 4 Mar 2023 17:28:42 -0500 Subject: [PATCH] Clean up imports --- tests/scrobbles_tests/test_views.py | 9 ++++----- tests/videos_tests/test_imdb.py | 2 +- vrobbler/apps/music/aggregators.py | 4 +--- vrobbler/apps/scrobbles/models.py | 4 ++-- vrobbler/apps/scrobbles/scrobblers.py | 12 ++++++------ vrobbler/apps/scrobbles/tasks.py | 3 +-- vrobbler/apps/scrobbles/views.py | 4 +--- vrobbler/settings.py | 1 + 8 files changed, 17 insertions(+), 22 deletions(-) diff --git a/tests/scrobbles_tests/test_views.py b/tests/scrobbles_tests/test_views.py index 8c37223..9adce08 100644 --- a/tests/scrobbles_tests/test_views.py +++ b/tests/scrobbles_tests/test_views.py @@ -1,11 +1,10 @@ import json + import pytest - from django.urls import reverse - -from vrobbler.apps.scrobbles.models import Scrobble -from vrobbler.apps.music.models import Track -from vrobbler.apps.podcasts.models import Episode +from music.models import Track +from podcasts.models import Episode +from scrobbles.models import Scrobble @pytest.mark.django_db diff --git a/tests/videos_tests/test_imdb.py b/tests/videos_tests/test_imdb.py index cbe49b7..8f43e9b 100644 --- a/tests/videos_tests/test_imdb.py +++ b/tests/videos_tests/test_imdb.py @@ -1,6 +1,6 @@ import pytest -from vrobbler.apps.videos.imdb import lookup_video_from_imdb +from videos.imdb import lookup_video_from_imdb @pytest.mark.skip(reason="Need to sort out third party API testing") diff --git a/vrobbler/apps/music/aggregators.py b/vrobbler/apps/music/aggregators.py index e355b6e..15c79f6 100644 --- a/vrobbler/apps/music/aggregators.py +++ b/vrobbler/apps/music/aggregators.py @@ -1,13 +1,11 @@ from datetime import datetime, timedelta -from typing import List from django.apps import apps from django.db.models import Count, Q, QuerySet from django.utils import timezone -from music.models import Artist, Track +from profiles.utils import now_user_timezone from scrobbles.models import Scrobble from videos.models import Video -from vrobbler.apps.profiles.utils import now_user_timezone def scrobble_counts(user=None): diff --git a/vrobbler/apps/scrobbles/models.py b/vrobbler/apps/scrobbles/models.py index 6660469..a558ae1 100644 --- a/vrobbler/apps/scrobbles/models.py +++ b/vrobbler/apps/scrobbles/models.py @@ -16,7 +16,7 @@ from scrobbles.utils import check_scrobble_for_finish from sports.models import SportEvent from videos.models import Series, Video -from vrobbler.apps.profiles.utils import ( +from profiles.utils import ( end_of_day, end_of_month, end_of_week, @@ -24,7 +24,7 @@ from vrobbler.apps.profiles.utils import ( start_of_month, start_of_week, ) -from vrobbler.apps.scrobbles.stats import build_charts +from scrobbles.stats import build_charts logger = logging.getLogger(__name__) User = get_user_model() diff --git a/vrobbler/apps/scrobbles/scrobblers.py b/vrobbler/apps/scrobbles/scrobblers.py index 615dc10..3d39640 100644 --- a/vrobbler/apps/scrobbles/scrobblers.py +++ b/vrobbler/apps/scrobbles/scrobblers.py @@ -5,16 +5,16 @@ from dateutil.parser import parse from django.utils import timezone from music.constants import JELLYFIN_POST_KEYS from music.models import Track -from podcasts.models import Episode -from scrobbles.models import Scrobble -from scrobbles.utils import convert_to_seconds, parse_mopidy_uri -from videos.models import Video -from sports.models import SportEvent -from vrobbler.apps.music.utils import ( +from music.utils import ( get_or_create_album, get_or_create_artist, get_or_create_track, ) +from podcasts.models import Episode +from scrobbles.models import Scrobble +from scrobbles.utils import convert_to_seconds, parse_mopidy_uri +from sports.models import SportEvent +from videos.models import Video logger = logging.getLogger(__name__) diff --git a/vrobbler/apps/scrobbles/tasks.py b/vrobbler/apps/scrobbles/tasks.py index 8092420..c2e2dab 100644 --- a/vrobbler/apps/scrobbles/tasks.py +++ b/vrobbler/apps/scrobbles/tasks.py @@ -7,8 +7,7 @@ from scrobbles.models import ( KoReaderImport, LastFmImport, ) - -from vrobbler.apps.scrobbles.stats import build_yesterdays_charts_for_user +from scrobbles.stats import build_yesterdays_charts_for_user logger = logging.getLogger(__name__) User = get_user_model() diff --git a/vrobbler/apps/scrobbles/views.py b/vrobbler/apps/scrobbles/views.py index 2948943..e25b0ca 100644 --- a/vrobbler/apps/scrobbles/views.py +++ b/vrobbler/apps/scrobbles/views.py @@ -17,7 +17,7 @@ from django.views.decorators.csrf import csrf_exempt from django.views.generic import DetailView, FormView, TemplateView from django.views.generic.edit import CreateView from django.views.generic.list import ListView -from music.aggregators import scrobble_counts, week_of_scrobbles +from music.aggregators import live_charts, scrobble_counts, week_of_scrobbles from rest_framework import status from rest_framework.decorators import ( api_view, @@ -57,8 +57,6 @@ from scrobbles.tasks import ( from sports.thesportsdb import lookup_event_from_thesportsdb from videos.imdb import lookup_video_from_imdb -from vrobbler.apps.music.aggregators import live_charts - logger = logging.getLogger(__name__) diff --git a/vrobbler/settings.py b/vrobbler/settings.py index b02d13f..69e601f 100644 --- a/vrobbler/settings.py +++ b/vrobbler/settings.py @@ -157,6 +157,7 @@ if TESTING: DATABASES = { "default": dj_database_url.config(default="sqlite:///testdb.sqlite3") } + db_str = "" if 'sqlite' in DATABASES['default']['ENGINE']: db_str = f"Connected to sqlite@{DATABASES['default']['NAME']}"