See #297: removed unused variables
This commit is contained in:
parent
2b1c46317f
commit
639882bd34
|
@ -41,7 +41,6 @@ class Command(BaseCommand):
|
||||||
script["entrypoint"](self, **options)
|
script["entrypoint"](self, **options)
|
||||||
|
|
||||||
def show_help(self):
|
def show_help(self):
|
||||||
indentation = 4
|
|
||||||
self.stdout.write("")
|
self.stdout.write("")
|
||||||
self.stdout.write("Available scripts:")
|
self.stdout.write("Available scripts:")
|
||||||
self.stdout.write("Launch with: python manage.py <script_name>")
|
self.stdout.write("Launch with: python manage.py <script_name>")
|
||||||
|
|
|
@ -40,7 +40,6 @@ class ActionSerializer(serializers.Serializer):
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def validate_objects(self, value):
|
def validate_objects(self, value):
|
||||||
qs = None
|
|
||||||
if value == "all":
|
if value == "all":
|
||||||
return self.queryset.all().order_by("id")
|
return self.queryset.all().order_by("id")
|
||||||
if type(value) in [list, tuple]:
|
if type(value) in [list, tuple]:
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
import os
|
import os
|
||||||
import json
|
|
||||||
from urllib.parse import quote_plus
|
|
||||||
import youtube_dl
|
import youtube_dl
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
import glob
|
|
||||||
|
|
||||||
|
|
||||||
def download(
|
def download(
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import datetime
|
import datetime
|
||||||
import logging
|
import logging
|
||||||
import uuid
|
|
||||||
import xml
|
import xml
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
@ -155,7 +154,6 @@ class SystemActor(object):
|
||||||
return handler(data, actor)
|
return handler(data, actor)
|
||||||
|
|
||||||
def handle_follow(self, ac, sender):
|
def handle_follow(self, ac, sender):
|
||||||
system_actor = self.get_actor_instance()
|
|
||||||
serializer = serializers.FollowSerializer(
|
serializer = serializers.FollowSerializer(
|
||||||
data=ac, context={"follow_actor": sender}
|
data=ac, context={"follow_actor": sender}
|
||||||
)
|
)
|
||||||
|
@ -325,7 +323,6 @@ class TestActor(SystemActor):
|
||||||
reply_url = "https://{}/activities/note/{}".format(
|
reply_url = "https://{}/activities/note/{}".format(
|
||||||
settings.FEDERATION_HOSTNAME, now.timestamp()
|
settings.FEDERATION_HOSTNAME, now.timestamp()
|
||||||
)
|
)
|
||||||
reply_content = "{} Pong!".format(sender.mention_username)
|
|
||||||
reply_activity = {
|
reply_activity = {
|
||||||
"@context": [
|
"@context": [
|
||||||
"https://www.w3.org/ns/activitystreams",
|
"https://www.w3.org/ns/activitystreams",
|
||||||
|
|
|
@ -687,7 +687,7 @@ class AudioSerializer(serializers.Serializer):
|
||||||
|
|
||||||
def validate_url(self, v):
|
def validate_url(self, v):
|
||||||
try:
|
try:
|
||||||
url = v["href"]
|
v["href"]
|
||||||
except (KeyError, TypeError):
|
except (KeyError, TypeError):
|
||||||
raise serializers.ValidationError("Missing href")
|
raise serializers.ValidationError("Missing href")
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ def verify_django(django_request, public_key):
|
||||||
v = request.headers[h]
|
v = request.headers[h]
|
||||||
if v:
|
if v:
|
||||||
request.headers[h] = str(v)
|
request.headers[h] = str(v)
|
||||||
prepared_request = request.prepare()
|
request.prepare()
|
||||||
return verify(request, public_key)
|
return verify(request, public_key)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -249,7 +249,7 @@ class LibraryViewSet(
|
||||||
def create(self, request, *args, **kwargs):
|
def create(self, request, *args, **kwargs):
|
||||||
serializer = serializers.APILibraryCreateSerializer(data=request.data)
|
serializer = serializers.APILibraryCreateSerializer(data=request.data)
|
||||||
serializer.is_valid(raise_exception=True)
|
serializer.is_valid(raise_exception=True)
|
||||||
library = serializer.save()
|
serializer.save()
|
||||||
return response.Response(serializer.data, status=201)
|
return response.Response(serializer.data, status=201)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ memo = memoize.Memoizer(store, namespace="instance:stats")
|
||||||
|
|
||||||
def get():
|
def get():
|
||||||
share_stats = preferences.get("instance__nodeinfo_stats_enabled")
|
share_stats = preferences.get("instance__nodeinfo_stats_enabled")
|
||||||
private = preferences.get("instance__nodeinfo_private")
|
|
||||||
data = {
|
data = {
|
||||||
"version": "2.0",
|
"version": "2.0",
|
||||||
"software": {"name": "funkwhale", "version": funkwhale_api.__version__},
|
"software": {"name": "funkwhale", "version": funkwhale_api.__version__},
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import urllib.request
|
import urllib.request
|
||||||
import html.parser
|
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import cacheops
|
import cacheops
|
||||||
import os
|
|
||||||
|
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import os
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
from funkwhale_api.common.utils import rename_file
|
from funkwhale_api.common.utils import rename_file
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import os
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
from funkwhale_api.common.utils import rename_file
|
from funkwhale_api.common.utils import rename_file
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import os
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
from funkwhale_api.music.utils import guess_mimetype
|
from funkwhale_api.music.utils import guess_mimetype
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import os
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import os
|
|
||||||
import uuid
|
import uuid
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import os
|
import os
|
||||||
import io
|
|
||||||
import arrow
|
import arrow
|
||||||
import datetime
|
import datetime
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import ffmpeg
|
import ffmpeg
|
||||||
import os
|
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import subprocess
|
|
||||||
import unicodedata
|
import unicodedata
|
||||||
import urllib
|
import urllib
|
||||||
|
|
||||||
|
|
|
@ -178,7 +178,6 @@ class Command(BaseCommand):
|
||||||
async = options["async"]
|
async = options["async"]
|
||||||
import_handler = tasks.import_job_run.delay if async else tasks.import_job_run
|
import_handler = tasks.import_job_run.delay if async else tasks.import_job_run
|
||||||
batch = user.imports.create(source="shell")
|
batch = user.imports.create(source="shell")
|
||||||
total = len(paths)
|
|
||||||
errors = []
|
errors = []
|
||||||
for i, path in list(enumerate(paths)):
|
for i, path in list(enumerate(paths)):
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import acoustid
|
import acoustid
|
||||||
import os
|
import os
|
||||||
import datetime
|
|
||||||
from django.core.files import File
|
from django.core.files import File
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
|
|
||||||
|
|
|
@ -147,7 +147,7 @@ class TagRadio(RelatedObjectRadio):
|
||||||
|
|
||||||
def get_queryset(self, **kwargs):
|
def get_queryset(self, **kwargs):
|
||||||
qs = super().get_queryset(**kwargs)
|
qs = super().get_queryset(**kwargs)
|
||||||
return Track.objects.filter(tags__in=[self.session.related_object])
|
return qs.filter(tags__in=[self.session.related_object])
|
||||||
|
|
||||||
|
|
||||||
@registry.register(name="artist")
|
@registry.register(name="artist")
|
||||||
|
|
|
@ -108,7 +108,7 @@ class RadioSessionTrackViewSet(mixins.CreateModelMixin, viewsets.GenericViewSet)
|
||||||
assert request.user == session.user
|
assert request.user == session.user
|
||||||
except AssertionError:
|
except AssertionError:
|
||||||
return Response(status=status.HTTP_403_FORBIDDEN)
|
return Response(status=status.HTTP_403_FORBIDDEN)
|
||||||
track = session.radio.pick()
|
session.radio.pick()
|
||||||
session_track = session.session_tracks.all().latest("id")
|
session_track = session.session_tracks.all().latest("id")
|
||||||
# self.perform_create(serializer)
|
# self.perform_create(serializer)
|
||||||
# dirty override here, since we use a different serializer for creation and detail
|
# dirty override here, since we use a different serializer for creation and detail
|
||||||
|
|
|
@ -12,7 +12,6 @@ MAPPING = {
|
||||||
|
|
||||||
class SubsonicContentNegociation(negotiation.DefaultContentNegotiation):
|
class SubsonicContentNegociation(negotiation.DefaultContentNegotiation):
|
||||||
def select_renderer(self, request, renderers, format_suffix=None):
|
def select_renderer(self, request, renderers, format_suffix=None):
|
||||||
path = request.path
|
|
||||||
data = request.GET or request.POST
|
data = request.GET or request.POST
|
||||||
requested_format = data.get("f", "xml")
|
requested_format = data.get("f", "xml")
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -158,7 +158,6 @@ class SubsonicViewSet(viewsets.GenericViewSet):
|
||||||
)
|
)
|
||||||
@find_object(music_models.Artist.objects.all())
|
@find_object(music_models.Artist.objects.all())
|
||||||
def get_artist_info2(self, request, *args, **kwargs):
|
def get_artist_info2(self, request, *args, **kwargs):
|
||||||
artist = kwargs.pop("obj")
|
|
||||||
payload = {"artist-info2": {}}
|
payload = {"artist-info2": {}}
|
||||||
|
|
||||||
return response.Response(payload, status=200)
|
return response.Response(payload, status=200)
|
||||||
|
|
|
@ -7,7 +7,7 @@ from funkwhale_api.activity import utils
|
||||||
def test_activity_view(factories, api_client, preferences, anonymous_user):
|
def test_activity_view(factories, api_client, preferences, anonymous_user):
|
||||||
preferences["common__api_authentication_required"] = False
|
preferences["common__api_authentication_required"] = False
|
||||||
favorite = factories["favorites.TrackFavorite"](user__privacy_level="everyone")
|
favorite = factories["favorites.TrackFavorite"](user__privacy_level="everyone")
|
||||||
listening = factories["history.Listening"]()
|
factories["history.Listening"]()
|
||||||
url = reverse("api:v1:activity-list")
|
url = reverse("api:v1:activity-list")
|
||||||
objects = utils.get_activity(anonymous_user)
|
objects = utils.get_activity(anonymous_user)
|
||||||
serializer = serializers.AutoSerializer(objects, many=True)
|
serializer = serializers.AutoSerializer(objects, many=True)
|
||||||
|
|
|
@ -26,14 +26,14 @@ def string_list_pref(preferences):
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_string_list_serializer_to_db(input, output):
|
def test_string_list_serializer_to_db(input, output):
|
||||||
s = common_preferences.StringListSerializer.to_db(input) == output
|
common_preferences.StringListSerializer.to_db(input) == output
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"input,output", [("a,b,c", ["a", "b", "c"]), (None, []), ("", [])]
|
"input,output", [("a,b,c", ["a", "b", "c"]), (None, []), ("", [])]
|
||||||
)
|
)
|
||||||
def test_string_list_serializer_to_python(input, output):
|
def test_string_list_serializer_to_python(input, output):
|
||||||
s = common_preferences.StringListSerializer.to_python(input) == output
|
common_preferences.StringListSerializer.to_python(input) == output
|
||||||
|
|
||||||
|
|
||||||
def test_string_list_pref_default(string_list_pref, preferences):
|
def test_string_list_pref_default(string_list_pref, preferences):
|
||||||
|
|
|
@ -47,7 +47,7 @@ def test_action_serializer_validates_objects():
|
||||||
|
|
||||||
def test_action_serializers_objects_clean_ids(factories):
|
def test_action_serializers_objects_clean_ids(factories):
|
||||||
user1 = factories["users.User"]()
|
user1 = factories["users.User"]()
|
||||||
user2 = factories["users.User"]()
|
factories["users.User"]()
|
||||||
|
|
||||||
data = {"objects": [user1.pk], "action": "test"}
|
data = {"objects": [user1.pk], "action": "test"}
|
||||||
serializer = TestSerializer(data, queryset=models.User.objects.all())
|
serializer = TestSerializer(data, queryset=models.User.objects.all())
|
||||||
|
@ -69,8 +69,8 @@ def test_action_serializers_objects_clean_all(factories):
|
||||||
|
|
||||||
def test_action_serializers_save(factories, mocker):
|
def test_action_serializers_save(factories, mocker):
|
||||||
handler = mocker.spy(TestSerializer, "handle_test")
|
handler = mocker.spy(TestSerializer, "handle_test")
|
||||||
user1 = factories["users.User"]()
|
factories["users.User"]()
|
||||||
user2 = factories["users.User"]()
|
factories["users.User"]()
|
||||||
|
|
||||||
data = {"objects": "all", "action": "test"}
|
data = {"objects": "all", "action": "test"}
|
||||||
serializer = TestSerializer(data, queryset=models.User.objects.all())
|
serializer = TestSerializer(data, queryset=models.User.objects.all())
|
||||||
|
@ -82,7 +82,7 @@ def test_action_serializers_save(factories, mocker):
|
||||||
|
|
||||||
|
|
||||||
def test_action_serializers_filterset(factories):
|
def test_action_serializers_filterset(factories):
|
||||||
user1 = factories["users.User"](is_active=False)
|
factories["users.User"](is_active=False)
|
||||||
user2 = factories["users.User"](is_active=True)
|
user2 = factories["users.User"](is_active=True)
|
||||||
|
|
||||||
data = {"objects": "all", "action": "test", "filters": {"is_active": True}}
|
data = {"objects": "all", "action": "test", "filters": {"is_active": True}}
|
||||||
|
|
|
@ -186,7 +186,6 @@ def fake_request():
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def activity_registry():
|
def activity_registry():
|
||||||
r = record.registry
|
|
||||||
state = list(record.registry.items())
|
state = list(record.registry.items())
|
||||||
yield record.registry
|
yield record.registry
|
||||||
record.registry.clear()
|
record.registry.clear()
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import uuid
|
|
||||||
|
|
||||||
from funkwhale_api.federation import activity
|
from funkwhale_api.federation import activity
|
||||||
from funkwhale_api.federation import serializers
|
from funkwhale_api.federation import serializers
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import arrow
|
import arrow
|
||||||
import pytest
|
import pytest
|
||||||
import uuid
|
|
||||||
|
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
@ -350,7 +349,7 @@ def test_library_actor_handles_follow_manual_approval(preferences, mocker, facto
|
||||||
def test_library_actor_handles_follow_auto_approval(preferences, mocker, factories):
|
def test_library_actor_handles_follow_auto_approval(preferences, mocker, factories):
|
||||||
preferences["federation__music_needs_approval"] = False
|
preferences["federation__music_needs_approval"] = False
|
||||||
actor = factories["federation.Actor"]()
|
actor = factories["federation.Actor"]()
|
||||||
accept_follow = mocker.patch("funkwhale_api.federation.activity.accept_follow")
|
mocker.patch("funkwhale_api.federation.activity.accept_follow")
|
||||||
library_actor = actors.SYSTEM_ACTORS["library"].get_actor_instance()
|
library_actor = actors.SYSTEM_ACTORS["library"].get_actor_instance()
|
||||||
data = {
|
data = {
|
||||||
"actor": actor.url,
|
"actor": actor.url,
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import pytest
|
import pytest
|
||||||
import uuid
|
|
||||||
|
|
||||||
from django import db
|
from django import db
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import cryptography.exceptions
|
import cryptography.exceptions
|
||||||
import io
|
|
||||||
import pytest
|
import pytest
|
||||||
import requests_http_signature
|
import requests_http_signature
|
||||||
|
|
||||||
|
|
|
@ -159,7 +159,6 @@ def test_audio_file_list_actor_page_exclude_federated_files(
|
||||||
db, preferences, api_client, factories
|
db, preferences, api_client, factories
|
||||||
):
|
):
|
||||||
preferences["federation__music_needs_approval"] = False
|
preferences["federation__music_needs_approval"] = False
|
||||||
library = actors.SYSTEM_ACTORS["library"].get_actor_instance()
|
|
||||||
tfs = factories["music.TrackFile"].create_batch(size=5, federation=True)
|
tfs = factories["music.TrackFile"].create_batch(size=5, federation=True)
|
||||||
|
|
||||||
url = reverse("federation:music:files-list")
|
url = reverse("federation:music:files-list")
|
||||||
|
@ -188,7 +187,6 @@ def test_audio_file_list_actor_page_error_too_far(
|
||||||
|
|
||||||
|
|
||||||
def test_library_actor_includes_library_link(db, preferences, api_client):
|
def test_library_actor_includes_library_link(db, preferences, api_client):
|
||||||
actor = actors.SYSTEM_ACTORS["library"].get_actor_instance()
|
|
||||||
url = reverse("federation:instance-actors-detail", kwargs={"actor": "library"})
|
url = reverse("federation:instance-actors-detail", kwargs={"actor": "library"})
|
||||||
response = api_client.get(url)
|
response = api_client.get(url)
|
||||||
expected_links = [
|
expected_links = [
|
||||||
|
@ -263,7 +261,7 @@ def test_follow_library(superuser_api_client, mocker, factories, r_mock):
|
||||||
def test_can_list_system_actor_following(factories, superuser_api_client):
|
def test_can_list_system_actor_following(factories, superuser_api_client):
|
||||||
library_actor = actors.SYSTEM_ACTORS["library"].get_actor_instance()
|
library_actor = actors.SYSTEM_ACTORS["library"].get_actor_instance()
|
||||||
follow1 = factories["federation.Follow"](actor=library_actor)
|
follow1 = factories["federation.Follow"](actor=library_actor)
|
||||||
follow2 = factories["federation.Follow"]()
|
factories["federation.Follow"]()
|
||||||
|
|
||||||
url = reverse("api:v1:federation:libraries-following")
|
url = reverse("api:v1:federation:libraries-following")
|
||||||
response = superuser_api_client.get(url)
|
response = superuser_api_client.get(url)
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import random
|
|
||||||
import json
|
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
@ -10,7 +8,6 @@ from funkwhale_api.history import models
|
||||||
def test_can_create_listening(factories):
|
def test_can_create_listening(factories):
|
||||||
track = factories["music.Track"]()
|
track = factories["music.Track"]()
|
||||||
user = factories["users.User"]()
|
user = factories["users.User"]()
|
||||||
now = timezone.now()
|
|
||||||
l = models.Listening.objects.create(user=user, track=track)
|
l = models.Listening.objects.create(user=user, track=track)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,6 @@ def test_fix_track_files_size(factories, mocker):
|
||||||
|
|
||||||
|
|
||||||
def test_fix_track_files_mimetype(factories, mocker):
|
def test_fix_track_files_mimetype(factories, mocker):
|
||||||
name = "test.mp3"
|
|
||||||
mp3_path = os.path.join(DATA_DIR, "test.mp3")
|
mp3_path = os.path.join(DATA_DIR, "test.mp3")
|
||||||
ogg_path = os.path.join(DATA_DIR, "test.ogg")
|
ogg_path = os.path.join(DATA_DIR, "test.ogg")
|
||||||
tf1 = factories["music.TrackFile"](
|
tf1 = factories["music.TrackFile"](
|
||||||
|
|
|
@ -195,7 +195,7 @@ def test_import_batch_notifies_followers(factories, mocker):
|
||||||
|
|
||||||
f1 = factories["federation.Follow"](approved=True, target=library_actor)
|
f1 = factories["federation.Follow"](approved=True, target=library_actor)
|
||||||
f2 = factories["federation.Follow"](approved=False, target=library_actor)
|
f2 = factories["federation.Follow"](approved=False, target=library_actor)
|
||||||
f3 = factories["federation.Follow"]()
|
factories["federation.Follow"]()
|
||||||
|
|
||||||
mocked_deliver = mocker.patch("funkwhale_api.federation.activity.deliver")
|
mocked_deliver = mocker.patch("funkwhale_api.federation.activity.deliver")
|
||||||
batch = factories["music.ImportBatch"]()
|
batch = factories["music.ImportBatch"]()
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import json
|
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
|
||||||
from funkwhale_api.music import models
|
from funkwhale_api.music import models
|
||||||
|
|
|
@ -44,7 +44,6 @@ def test_set_acoustid_on_track_file(factories, mocker, preferences):
|
||||||
|
|
||||||
def test_set_acoustid_on_track_file_required_high_score(factories, mocker):
|
def test_set_acoustid_on_track_file_required_high_score(factories, mocker):
|
||||||
track_file = factories["music.TrackFile"](acoustid_track_id=None)
|
track_file = factories["music.TrackFile"](acoustid_track_id=None)
|
||||||
id = "e475bf79-c1ce-4441-bed7-1e33f226c0a2"
|
|
||||||
payload = {"results": [{"score": 0.79}], "status": "ok"}
|
payload = {"results": [{"score": 0.79}], "status": "ok"}
|
||||||
m = mocker.patch("acoustid.match", return_value=payload)
|
m = mocker.patch("acoustid.match", return_value=payload)
|
||||||
r = tasks.set_acoustid_on_track_file(track_file_id=track_file.pk)
|
r = tasks.set_acoustid_on_track_file(track_file_id=track_file.pk)
|
||||||
|
@ -159,7 +158,6 @@ def test_import_job_skip_if_already_exists(artists, albums, tracks, factories, m
|
||||||
)
|
)
|
||||||
|
|
||||||
job = factories["music.FileImportJob"](audio_file__path=path)
|
job = factories["music.FileImportJob"](audio_file__path=path)
|
||||||
f = job.audio_file
|
|
||||||
tasks.import_job_run(import_job_id=job.pk)
|
tasks.import_job_run(import_job_id=job.pk)
|
||||||
job.refresh_from_db()
|
job.refresh_from_db()
|
||||||
|
|
||||||
|
@ -219,7 +217,6 @@ def test_update_album_cover_mbid(factories, mocker):
|
||||||
|
|
||||||
|
|
||||||
def test_update_album_cover_file_data(factories, mocker):
|
def test_update_album_cover_file_data(factories, mocker):
|
||||||
path = os.path.join(DATA_DIR, "test.mp3")
|
|
||||||
album = factories["music.Album"](cover="", mbid=None)
|
album = factories["music.Album"](cover="", mbid=None)
|
||||||
tf = factories["music.TrackFile"](track__album=album)
|
tf = factories["music.TrackFile"](track__album=album)
|
||||||
|
|
||||||
|
@ -236,7 +233,6 @@ def test_update_album_cover_file_data(factories, mocker):
|
||||||
@pytest.mark.parametrize("ext,mimetype", [("jpg", "image/jpeg"), ("png", "image/png")])
|
@pytest.mark.parametrize("ext,mimetype", [("jpg", "image/jpeg"), ("png", "image/png")])
|
||||||
def test_update_album_cover_file_cover_separate_file(ext, mimetype, factories, mocker):
|
def test_update_album_cover_file_cover_separate_file(ext, mimetype, factories, mocker):
|
||||||
mocker.patch("funkwhale_api.music.tasks.IMAGE_TYPES", [(ext, mimetype)])
|
mocker.patch("funkwhale_api.music.tasks.IMAGE_TYPES", [(ext, mimetype)])
|
||||||
path = os.path.join(DATA_DIR, "test.mp3")
|
|
||||||
image_path = os.path.join(DATA_DIR, "cover.{}".format(ext))
|
image_path = os.path.join(DATA_DIR, "cover.{}".format(ext))
|
||||||
with open(image_path, "rb") as f:
|
with open(image_path, "rb") as f:
|
||||||
image_content = f.read()
|
image_content = f.read()
|
||||||
|
|
|
@ -334,7 +334,7 @@ def test_import_job_viewset_get_queryset_upload_filters_user(
|
||||||
logged_in_api_client.user.permission_upload = True
|
logged_in_api_client.user.permission_upload = True
|
||||||
logged_in_api_client.user.save()
|
logged_in_api_client.user.save()
|
||||||
|
|
||||||
job = factories["music.ImportJob"]()
|
factories["music.ImportJob"]()
|
||||||
url = reverse("api:v1:import-jobs-list")
|
url = reverse("api:v1:import-jobs-list")
|
||||||
response = logged_in_api_client.get(url)
|
response = logged_in_api_client.get(url)
|
||||||
|
|
||||||
|
@ -347,7 +347,7 @@ def test_import_batch_viewset_get_queryset_upload_filters_user(
|
||||||
logged_in_api_client.user.permission_upload = True
|
logged_in_api_client.user.permission_upload = True
|
||||||
logged_in_api_client.user.save()
|
logged_in_api_client.user.save()
|
||||||
|
|
||||||
job = factories["music.ImportBatch"]()
|
factories["music.ImportBatch"]()
|
||||||
url = reverse("api:v1:import-batches-list")
|
url = reverse("api:v1:import-batches-list")
|
||||||
response = logged_in_api_client.get(url)
|
response = logged_in_api_client.get(url)
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import json
|
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
|
||||||
from funkwhale_api.music import models
|
from funkwhale_api.music import models
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import json
|
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
|
||||||
from funkwhale_api.musicbrainz import api
|
from funkwhale_api.musicbrainz import api
|
||||||
|
|
|
@ -53,7 +53,7 @@ def test_update_insert_is_called_when_index_is_provided(factories, mocker):
|
||||||
second = factories["playlists.PlaylistTrack"](playlist=playlist, index=1)
|
second = factories["playlists.PlaylistTrack"](playlist=playlist, index=1)
|
||||||
insert = mocker.spy(models.Playlist, "insert")
|
insert = mocker.spy(models.Playlist, "insert")
|
||||||
factories["playlists.Playlist"]()
|
factories["playlists.Playlist"]()
|
||||||
track = factories["music.Track"]()
|
factories["music.Track"]()
|
||||||
serializer = serializers.PlaylistTrackWriteSerializer(
|
serializer = serializers.PlaylistTrackWriteSerializer(
|
||||||
second, data={"playlist": playlist.pk, "track": second.track.pk, "index": 0}
|
second, data={"playlist": playlist.pk, "track": second.track.pk, "index": 0}
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import json
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
@ -13,7 +12,7 @@ def test_can_create_playlist_via_api(logged_in_api_client):
|
||||||
url = reverse("api:v1:playlists-list")
|
url = reverse("api:v1:playlists-list")
|
||||||
data = {"name": "test", "privacy_level": "everyone"}
|
data = {"name": "test", "privacy_level": "everyone"}
|
||||||
|
|
||||||
response = logged_in_api_client.post(url, data)
|
logged_in_api_client.post(url, data)
|
||||||
|
|
||||||
playlist = logged_in_api_client.user.playlists.latest("id")
|
playlist = logged_in_api_client.user.playlists.latest("id")
|
||||||
assert playlist.name == "test"
|
assert playlist.name == "test"
|
||||||
|
@ -38,7 +37,7 @@ def test_playlist_inherits_user_privacy(logged_in_api_client):
|
||||||
|
|
||||||
data = {"name": "test"}
|
data = {"name": "test"}
|
||||||
|
|
||||||
response = logged_in_api_client.post(url, data)
|
logged_in_api_client.post(url, data)
|
||||||
playlist = user.playlists.latest("id")
|
playlist = user.playlists.latest("id")
|
||||||
assert playlist.privacy_level == user.privacy_level
|
assert playlist.privacy_level == user.privacy_level
|
||||||
|
|
||||||
|
@ -80,7 +79,7 @@ def test_only_can_add_track_on_own_playlist_via_api(factories, logged_in_api_cli
|
||||||
|
|
||||||
def test_deleting_plt_updates_indexes(mocker, factories, logged_in_api_client):
|
def test_deleting_plt_updates_indexes(mocker, factories, logged_in_api_client):
|
||||||
remove = mocker.spy(models.Playlist, "remove")
|
remove = mocker.spy(models.Playlist, "remove")
|
||||||
track = factories["music.Track"]()
|
factories["music.Track"]()
|
||||||
plt = factories["playlists.PlaylistTrack"](
|
plt = factories["playlists.PlaylistTrack"](
|
||||||
index=0, playlist__user=logged_in_api_client.user
|
index=0, playlist__user=logged_in_api_client.user
|
||||||
)
|
)
|
||||||
|
|
|
@ -15,7 +15,7 @@ class NoopFilter(filters.RadioFilter):
|
||||||
|
|
||||||
|
|
||||||
def test_most_simple_radio_does_not_filter_anything(factories):
|
def test_most_simple_radio_does_not_filter_anything(factories):
|
||||||
tracks = factories["music.Track"].create_batch(3)
|
factories["music.Track"].create_batch(3)
|
||||||
radio = factories["radios.Radio"](config=[{"type": "noop"}])
|
radio = factories["radios.Radio"](config=[{"type": "noop"}])
|
||||||
|
|
||||||
assert radio.version == 0
|
assert radio.version == 0
|
||||||
|
|
|
@ -75,7 +75,6 @@ def test_can_get_choices_for_custom_radio(factories):
|
||||||
files = factories["music.TrackFile"].create_batch(5, track__artist=artist)
|
files = factories["music.TrackFile"].create_batch(5, track__artist=artist)
|
||||||
tracks = [f.track for f in files]
|
tracks = [f.track for f in files]
|
||||||
wrong_files = factories["music.TrackFile"].create_batch(5)
|
wrong_files = factories["music.TrackFile"].create_batch(5)
|
||||||
wrong_tracks = [f.track for f in wrong_files]
|
|
||||||
|
|
||||||
session = factories["radios.CustomRadioSession"](
|
session = factories["radios.CustomRadioSession"](
|
||||||
custom_radio__config=[{"type": "artist", "ids": [artist.pk]}]
|
custom_radio__config=[{"type": "artist", "ids": [artist.pk]}]
|
||||||
|
@ -115,13 +114,12 @@ def test_can_start_custom_radio_from_api(logged_in_client, factories):
|
||||||
|
|
||||||
def test_can_use_radio_session_to_filter_choices(factories):
|
def test_can_use_radio_session_to_filter_choices(factories):
|
||||||
files = factories["music.TrackFile"].create_batch(30)
|
files = factories["music.TrackFile"].create_batch(30)
|
||||||
tracks = [f.track for f in files]
|
|
||||||
user = factories["users.User"]()
|
user = factories["users.User"]()
|
||||||
radio = radios.RandomRadio()
|
radio = radios.RandomRadio()
|
||||||
session = radio.start_session(user)
|
session = radio.start_session(user)
|
||||||
|
|
||||||
for i in range(30):
|
for i in range(30):
|
||||||
p = radio.pick()
|
radio.pick()
|
||||||
|
|
||||||
# ensure 30 differents tracks have been suggested
|
# ensure 30 differents tracks have been suggested
|
||||||
tracks_id = [
|
tracks_id = [
|
||||||
|
@ -186,7 +184,6 @@ def test_can_start_artist_radio(factories):
|
||||||
user = factories["users.User"]()
|
user = factories["users.User"]()
|
||||||
artist = factories["music.Artist"]()
|
artist = factories["music.Artist"]()
|
||||||
wrong_files = factories["music.TrackFile"].create_batch(5)
|
wrong_files = factories["music.TrackFile"].create_batch(5)
|
||||||
wrong_tracks = [f.track for f in wrong_files]
|
|
||||||
good_files = factories["music.TrackFile"].create_batch(5, track__artist=artist)
|
good_files = factories["music.TrackFile"].create_batch(5, track__artist=artist)
|
||||||
good_tracks = [f.track for f in good_files]
|
good_tracks = [f.track for f in good_files]
|
||||||
|
|
||||||
|
@ -201,7 +198,6 @@ def test_can_start_tag_radio(factories):
|
||||||
user = factories["users.User"]()
|
user = factories["users.User"]()
|
||||||
tag = factories["taggit.Tag"]()
|
tag = factories["taggit.Tag"]()
|
||||||
wrong_files = factories["music.TrackFile"].create_batch(5)
|
wrong_files = factories["music.TrackFile"].create_batch(5)
|
||||||
wrong_tracks = [f.track for f in wrong_files]
|
|
||||||
good_files = factories["music.TrackFile"].create_batch(5, track__tags=[tag])
|
good_files = factories["music.TrackFile"].create_batch(5, track__tags=[tag])
|
||||||
good_tracks = [f.track for f in good_files]
|
good_tracks = [f.track for f in good_files]
|
||||||
|
|
||||||
|
@ -236,7 +232,7 @@ def test_can_start_less_listened_radio(factories):
|
||||||
good_files = factories["music.TrackFile"].create_batch(5)
|
good_files = factories["music.TrackFile"].create_batch(5)
|
||||||
good_tracks = [f.track for f in good_files]
|
good_tracks = [f.track for f in good_files]
|
||||||
radio = radios.LessListenedRadio()
|
radio = radios.LessListenedRadio()
|
||||||
session = radio.start_session(user)
|
radio.start_session(user)
|
||||||
|
|
||||||
for i in range(5):
|
for i in range(5):
|
||||||
assert radio.pick() in good_tracks
|
assert radio.pick() in good_tracks
|
||||||
|
|
|
@ -25,7 +25,6 @@ def test_auth_with_password_hex(api_request, factories):
|
||||||
user = factories["users.User"]()
|
user = factories["users.User"]()
|
||||||
user.subsonic_api_token = "password"
|
user.subsonic_api_token = "password"
|
||||||
user.save()
|
user.save()
|
||||||
token = authentication.get_token(salt, "password")
|
|
||||||
request = api_request.get(
|
request = api_request.get(
|
||||||
"/",
|
"/",
|
||||||
{
|
{
|
||||||
|
@ -49,7 +48,6 @@ def test_auth_with_password_cleartext(api_request, factories):
|
||||||
user = factories["users.User"]()
|
user = factories["users.User"]()
|
||||||
user.subsonic_api_token = "password"
|
user.subsonic_api_token = "password"
|
||||||
user.save()
|
user.save()
|
||||||
token = authentication.get_token(salt, "password")
|
|
||||||
request = api_request.get("/", {"u": user.username, "p": "password"})
|
request = api_request.get("/", {"u": user.username, "p": "password"})
|
||||||
|
|
||||||
authenticator = authentication.SubsonicAuthentication()
|
authenticator = authentication.SubsonicAuthentication()
|
||||||
|
@ -63,7 +61,6 @@ def test_auth_with_inactive_users(api_request, factories):
|
||||||
user = factories["users.User"](is_active=False)
|
user = factories["users.User"](is_active=False)
|
||||||
user.subsonic_api_token = "password"
|
user.subsonic_api_token = "password"
|
||||||
user.save()
|
user.save()
|
||||||
token = authentication.get_token(salt, "password")
|
|
||||||
request = api_request.get("/", {"u": user.username, "p": "password"})
|
request = api_request.get("/", {"u": user.username, "p": "password"})
|
||||||
|
|
||||||
authenticator = authentication.SubsonicAuthentication()
|
authenticator = authentication.SubsonicAuthentication()
|
||||||
|
|
|
@ -5,8 +5,6 @@ import pytest
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
|
||||||
from rest_framework.response import Response
|
|
||||||
|
|
||||||
from funkwhale_api.music import models as music_models
|
from funkwhale_api.music import models as music_models
|
||||||
from funkwhale_api.music import views as music_views
|
from funkwhale_api.music import views as music_views
|
||||||
from funkwhale_api.subsonic import renderers
|
from funkwhale_api.subsonic import renderers
|
||||||
|
@ -80,7 +78,7 @@ def test_ping(f, db, api_client):
|
||||||
def test_get_artists(f, db, logged_in_api_client, factories):
|
def test_get_artists(f, db, logged_in_api_client, factories):
|
||||||
url = reverse("api:subsonic-get-artists")
|
url = reverse("api:subsonic-get-artists")
|
||||||
assert url.endswith("getArtists") is True
|
assert url.endswith("getArtists") is True
|
||||||
artists = factories["music.Artist"].create_batch(size=10)
|
factories["music.Artist"].create_batch(size=10)
|
||||||
expected = {
|
expected = {
|
||||||
"artists": serializers.GetArtistsSerializer(
|
"artists": serializers.GetArtistsSerializer(
|
||||||
music_models.Artist.objects.all()
|
music_models.Artist.objects.all()
|
||||||
|
@ -97,7 +95,7 @@ def test_get_artist(f, db, logged_in_api_client, factories):
|
||||||
url = reverse("api:subsonic-get-artist")
|
url = reverse("api:subsonic-get-artist")
|
||||||
assert url.endswith("getArtist") is True
|
assert url.endswith("getArtist") is True
|
||||||
artist = factories["music.Artist"]()
|
artist = factories["music.Artist"]()
|
||||||
albums = factories["music.Album"].create_batch(size=3, artist=artist)
|
factories["music.Album"].create_batch(size=3, artist=artist)
|
||||||
expected = {"artist": serializers.GetArtistSerializer(artist).data}
|
expected = {"artist": serializers.GetArtistSerializer(artist).data}
|
||||||
response = logged_in_api_client.get(url, {"id": artist.pk})
|
response = logged_in_api_client.get(url, {"id": artist.pk})
|
||||||
|
|
||||||
|
@ -124,7 +122,7 @@ def test_get_album(f, db, logged_in_api_client, factories):
|
||||||
assert url.endswith("getAlbum") is True
|
assert url.endswith("getAlbum") is True
|
||||||
artist = factories["music.Artist"]()
|
artist = factories["music.Artist"]()
|
||||||
album = factories["music.Album"](artist=artist)
|
album = factories["music.Album"](artist=artist)
|
||||||
tracks = factories["music.Track"].create_batch(size=3, album=album)
|
factories["music.Track"].create_batch(size=3, album=album)
|
||||||
expected = {"album": serializers.GetAlbumSerializer(album).data}
|
expected = {"album": serializers.GetAlbumSerializer(album).data}
|
||||||
response = logged_in_api_client.get(url, {"f": f, "id": album.pk})
|
response = logged_in_api_client.get(url, {"f": f, "id": album.pk})
|
||||||
|
|
||||||
|
@ -166,7 +164,7 @@ def test_unstar(f, db, logged_in_api_client, factories):
|
||||||
url = reverse("api:subsonic-unstar")
|
url = reverse("api:subsonic-unstar")
|
||||||
assert url.endswith("unstar") is True
|
assert url.endswith("unstar") is True
|
||||||
track = factories["music.Track"]()
|
track = factories["music.Track"]()
|
||||||
favorite = factories["favorites.TrackFavorite"](
|
factories["favorites.TrackFavorite"](
|
||||||
track=track, user=logged_in_api_client.user
|
track=track, user=logged_in_api_client.user
|
||||||
)
|
)
|
||||||
response = logged_in_api_client.get(url, {"f": f, "id": track.pk})
|
response = logged_in_api_client.get(url, {"f": f, "id": track.pk})
|
||||||
|
@ -283,7 +281,7 @@ def test_update_playlist(f, db, logged_in_api_client, factories):
|
||||||
url = reverse("api:subsonic-update-playlist")
|
url = reverse("api:subsonic-update-playlist")
|
||||||
assert url.endswith("updatePlaylist") is True
|
assert url.endswith("updatePlaylist") is True
|
||||||
playlist = factories["playlists.Playlist"](user=logged_in_api_client.user)
|
playlist = factories["playlists.Playlist"](user=logged_in_api_client.user)
|
||||||
plt = factories["playlists.PlaylistTrack"](index=0, playlist=playlist)
|
factories["playlists.PlaylistTrack"](index=0, playlist=playlist)
|
||||||
new_track = factories["music.Track"]()
|
new_track = factories["music.Track"]()
|
||||||
response = logged_in_api_client.get(
|
response = logged_in_api_client.get(
|
||||||
url,
|
url,
|
||||||
|
@ -350,7 +348,7 @@ def test_get_music_folders(f, db, logged_in_api_client, factories):
|
||||||
def test_get_indexes(f, db, logged_in_api_client, factories):
|
def test_get_indexes(f, db, logged_in_api_client, factories):
|
||||||
url = reverse("api:subsonic-get-indexes")
|
url = reverse("api:subsonic-get-indexes")
|
||||||
assert url.endswith("getIndexes") is True
|
assert url.endswith("getIndexes") is True
|
||||||
artists = factories["music.Artist"].create_batch(size=10)
|
factories["music.Artist"].create_batch(size=10)
|
||||||
expected = {
|
expected = {
|
||||||
"indexes": serializers.GetArtistsSerializer(
|
"indexes": serializers.GetArtistsSerializer(
|
||||||
music_models.Artist.objects.all()
|
music_models.Artist.objects.all()
|
||||||
|
@ -384,5 +382,5 @@ def test_scrobble(factories, logged_in_api_client):
|
||||||
|
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
|
|
||||||
l = logged_in_api_client.user.listenings.latest("id")
|
listening = logged_in_api_client.user.listenings.latest("id")
|
||||||
assert l.track == track
|
assert listening.track == track
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import pytest
|
import pytest
|
||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
import uuid
|
|
||||||
|
|
||||||
from django.core.management import call_command
|
from django.core.management import call_command
|
||||||
from django.core.management.base import CommandError
|
from django.core.management.base import CommandError
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import json
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from funkwhale_api.providers.youtube.client import client
|
from funkwhale_api.providers.youtube.client import client
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import pytest
|
import pytest
|
||||||
import uuid
|
|
||||||
|
|
||||||
from jwt.exceptions import DecodeError
|
from jwt.exceptions import DecodeError
|
||||||
from rest_framework_jwt.settings import api_settings
|
from rest_framework_jwt.settings import api_settings
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import json
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from django.test import RequestFactory
|
from django.test import RequestFactory
|
||||||
|
@ -114,7 +113,7 @@ def test_changing_password_updates_secret_key(logged_in_api_client):
|
||||||
payload = {"old_password": "test", "new_password1": "new", "new_password2": "new"}
|
payload = {"old_password": "test", "new_password1": "new", "new_password2": "new"}
|
||||||
url = reverse("change_password")
|
url = reverse("change_password")
|
||||||
|
|
||||||
response = logged_in_api_client.post(url, payload)
|
logged_in_api_client.post(url, payload)
|
||||||
|
|
||||||
user.refresh_from_db()
|
user.refresh_from_db()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue