mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-05 03:49:24 +02:00
Fixed #54: Now use pytest everywhere \o/
This commit is contained in:
parent
a7758395ee
commit
099cdfa99c
65 changed files with 1466 additions and 1467 deletions
65
api/tests/music/test_works.py
Normal file
65
api/tests/music/test_works.py
Normal file
|
@ -0,0 +1,65 @@
|
|||
import json
|
||||
from django.urls import reverse
|
||||
|
||||
from funkwhale_api.music import models
|
||||
from funkwhale_api.musicbrainz import api
|
||||
from funkwhale_api.music import serializers
|
||||
|
||||
from . import data as api_data
|
||||
|
||||
|
||||
def test_can_import_work(factories, mocker):
|
||||
mocker.patch(
|
||||
'funkwhale_api.musicbrainz.api.works.get',
|
||||
return_value=api_data.works['get']['chop_suey'])
|
||||
recording = factories['music.Track'](
|
||||
mbid='07ca77cf-f513-4e9c-b190-d7e24bbad448')
|
||||
mbid = 'e2ecabc4-1b9d-30b2-8f30-3596ec423dc5'
|
||||
work = models.Work.create_from_api(id=mbid)
|
||||
|
||||
assert work.title == 'Chop Suey!'
|
||||
assert work.nature == 'song'
|
||||
assert work.language == 'eng'
|
||||
assert work.mbid == mbid
|
||||
|
||||
# a imported work should also be linked to corresponding recordings
|
||||
|
||||
recording.refresh_from_db()
|
||||
assert recording.work == work
|
||||
|
||||
|
||||
def test_can_get_work_from_recording(factories, mocker):
|
||||
mocker.patch(
|
||||
'funkwhale_api.musicbrainz.api.works.get',
|
||||
return_value=api_data.works['get']['chop_suey'])
|
||||
mocker.patch(
|
||||
'funkwhale_api.musicbrainz.api.recordings.get',
|
||||
return_value=api_data.tracks['get']['chop_suey'])
|
||||
recording = factories['music.Track'](
|
||||
work=None,
|
||||
mbid='07ca77cf-f513-4e9c-b190-d7e24bbad448')
|
||||
mbid = 'e2ecabc4-1b9d-30b2-8f30-3596ec423dc5'
|
||||
|
||||
assert recording.work == None
|
||||
|
||||
work = recording.get_work()
|
||||
|
||||
assert work.title == 'Chop Suey!'
|
||||
assert work.nature == 'song'
|
||||
assert work.language == 'eng'
|
||||
assert work.mbid == mbid
|
||||
|
||||
recording.refresh_from_db()
|
||||
assert recording.work == work
|
||||
|
||||
|
||||
def test_works_import_lyrics_if_any(db, mocker):
|
||||
mocker.patch(
|
||||
'funkwhale_api.musicbrainz.api.works.get',
|
||||
return_value=api_data.works['get']['chop_suey'])
|
||||
mbid = 'e2ecabc4-1b9d-30b2-8f30-3596ec423dc5'
|
||||
work = models.Work.create_from_api(id=mbid)
|
||||
|
||||
lyrics = models.Lyrics.objects.latest('id')
|
||||
assert lyrics.work == work
|
||||
assert lyrics.url == 'http://lyrics.wikia.com/System_Of_A_Down:Chop_Suey!'
|
Loading…
Add table
Add a link
Reference in a new issue