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