tests
Part-of: <https://dev.funkwhale.audio/funkwhale/funkwhale/-/merge_requests/2658>
This commit is contained in:
parent
a03cc1db24
commit
05ec6f6d0f
|
@ -47,7 +47,6 @@ def get_activity(user, limit=20):
|
|||
"track", "user", "track__artist", "track__album__artist"
|
||||
),
|
||||
]
|
||||
breakpoint()
|
||||
records = combined_recent(limit=limit, querysets=querysets)
|
||||
|
||||
return [r["object"] for r in records]
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
import funkwhale_api
|
||||
import liblistenbrainz
|
||||
|
||||
from django.utils import timezone
|
||||
|
||||
import funkwhale_api
|
||||
from config import plugins
|
||||
from funkwhale_api.favorites import models as favorites_models
|
||||
from funkwhale_api.history import models as history_models
|
||||
|
|
|
@ -36,7 +36,7 @@ PLUGIN = plugins.get_plugin_config(
|
|||
"label": "Enable listenings sync",
|
||||
"help": "If enable, your listening from Listenbrainz will be imported into Funkwhale. This means they \
|
||||
will be used has any other funkwhale listenings to filter out recently listened content or \
|
||||
generate recomendations",
|
||||
generate recommendations",
|
||||
},
|
||||
{
|
||||
"name": "sync_facorites",
|
||||
|
@ -50,7 +50,7 @@ PLUGIN = plugins.get_plugin_config(
|
|||
"name": "submit_favorites",
|
||||
"type": "boolean",
|
||||
"default": False,
|
||||
"label": "Enable favorite submition to Listenbrainz services",
|
||||
"label": "Enable favorite submission to Listenbrainz services",
|
||||
"help": "If enable, your favorites from Funkwhale will be submit to Listenbrainz",
|
||||
},
|
||||
],
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import datetime
|
||||
|
||||
import liblistenbrainz
|
||||
|
||||
from django.utils import timezone
|
||||
|
||||
from config import plugins
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import factory
|
||||
from django.utils import timezone
|
||||
|
||||
from funkwhale_api.factories import NoUpdateOnCreate, registry
|
||||
from funkwhale_api.music.factories import TrackFactory
|
||||
|
|
|
@ -27,6 +27,7 @@ from funkwhale_api.activity import record
|
|||
from funkwhale_api.federation import actors
|
||||
from funkwhale_api.moderation import mrf
|
||||
from funkwhale_api.music import licenses
|
||||
|
||||
from . import utils as test_utils
|
||||
|
||||
pytest_plugins = "aiohttp.pytest_plugin"
|
||||
|
|
|
@ -2,7 +2,6 @@ import datetime
|
|||
import logging
|
||||
|
||||
import liblistenbrainz
|
||||
|
||||
import pytest
|
||||
from django.urls import reverse
|
||||
from django.utils import timezone
|
||||
|
@ -14,14 +13,14 @@ from funkwhale_api.history import models as history_models
|
|||
|
||||
|
||||
def test_listenbrainz_submit_listen(logged_in_client, mocker, factories):
|
||||
plugin = plugins.get_plugin_config(
|
||||
config = plugins.get_plugin_config(
|
||||
name="listenbrainz",
|
||||
description="A plugin that allows you to submit or sync your listens and favorites to ListenBrainz.",
|
||||
conf=[],
|
||||
source=False,
|
||||
)
|
||||
handler = mocker.Mock()
|
||||
plugins.register_hook(plugins.LISTENING_CREATED, plugin)(handler)
|
||||
plugins.register_hook(plugins.LISTENING_CREATED, config)(handler)
|
||||
plugins.set_conf(
|
||||
"listenbrainz",
|
||||
{
|
||||
|
@ -38,10 +37,9 @@ def test_listenbrainz_submit_listen(logged_in_client, mocker, factories):
|
|||
track = factories["music.Track"]()
|
||||
url = reverse("api:v1:history:listenings-list")
|
||||
logged_in_client.post(url, {"track": track.pk})
|
||||
response = logged_in_client.get(url)
|
||||
logged_in_client.get(url)
|
||||
listening = history_models.Listening.objects.get(user=logged_in_client.user)
|
||||
handler.assert_called_once_with(listening=listening, conf=None)
|
||||
# why conf=none ?
|
||||
|
||||
|
||||
def test_sync_listenings_from_listenbrainz(factories, mocker, caplog):
|
||||
|
@ -131,9 +129,7 @@ def test_sync_favorites_from_listenbrainz(factories, mocker, caplog):
|
|||
track_last_sync = factories["music.Track"](
|
||||
mbid="c878ef2f-c08d-4a81-a047-f2a9f978cec7"
|
||||
)
|
||||
favorite_last_sync = factories["favorites.TrackFavorite"](
|
||||
track=track_last_sync, source="Listenbrainz"
|
||||
)
|
||||
factories["favorites.TrackFavorite"](track=track_last_sync, source="Listenbrainz")
|
||||
|
||||
conf = {
|
||||
"user_name": user.username,
|
||||
|
|
Loading…
Reference in New Issue