API Endpoint to list lirary tracks
This commit is contained in:
parent
bdf9347917
commit
57bf43bb96
7 changed files with 100 additions and 5 deletions
|
|
@ -1,4 +1,5 @@
|
|||
from django.core.paginator import Paginator
|
||||
from django.utils import timezone
|
||||
|
||||
from funkwhale_api.federation import serializers
|
||||
from funkwhale_api.federation import tasks
|
||||
|
|
@ -21,6 +22,7 @@ def test_scan_library_page_does_nothing_if_federation_disabled(
|
|||
|
||||
def test_scan_library_fetches_page_and_calls_scan_page(
|
||||
mocker, factories, r_mock):
|
||||
now = timezone.now()
|
||||
library = factories['federation.Library'](federation_enabled=True)
|
||||
collection_conf = {
|
||||
'actor': library.actor,
|
||||
|
|
@ -39,6 +41,8 @@ def test_scan_library_fetches_page_and_calls_scan_page(
|
|||
page_url=collection.data['first'],
|
||||
until=None,
|
||||
)
|
||||
library.refresh_from_db()
|
||||
assert library.fetched_date > now
|
||||
|
||||
|
||||
def test_scan_page_fetches_page_and_creates_tracks(
|
||||
|
|
|
|||
|
|
@ -312,7 +312,7 @@ def test_can_patch_library(factories, superuser_api_client):
|
|||
def test_scan_library(factories, mocker, superuser_api_client):
|
||||
scan = mocker.patch(
|
||||
'funkwhale_api.federation.tasks.scan_library.delay',
|
||||
return_value='id')
|
||||
return_value=mocker.Mock(id='id'))
|
||||
library = factories['federation.Library']()
|
||||
now = timezone.now()
|
||||
data = {
|
||||
|
|
@ -329,3 +329,20 @@ def test_scan_library(factories, mocker, superuser_api_client):
|
|||
library_id=library.pk,
|
||||
until=now
|
||||
)
|
||||
|
||||
|
||||
def test_list_library_tracks(factories, superuser_api_client):
|
||||
library = factories['federation.Library']()
|
||||
lts = list(reversed(factories['federation.LibraryTrack'].create_batch(
|
||||
size=5, library=library)))
|
||||
factories['federation.LibraryTrack'].create_batch(size=5)
|
||||
url = reverse('api:v1:federation:library-tracks-list')
|
||||
response = superuser_api_client.get(url, {'library': library.uuid})
|
||||
|
||||
assert response.status_code == 200
|
||||
assert response.data == {
|
||||
'results': serializers.APILibraryTrackSerializer(lts, many=True).data,
|
||||
'count': 5,
|
||||
'previous': None,
|
||||
'next': None,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue