mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-06 02:20:01 +02:00
Edits for artists and albums
This commit is contained in:
parent
2836b11190
commit
55d0e52c55
15 changed files with 523 additions and 151 deletions
|
@ -1,6 +1,54 @@
|
|||
import datetime
|
||||
import pytest
|
||||
|
||||
from funkwhale_api.music import licenses
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"field, old_value, new_value, expected", [("name", "foo", "bar", "bar")]
|
||||
)
|
||||
def test_artist_mutation(field, old_value, new_value, expected, factories, now, mocker):
|
||||
dispatch = mocker.patch("funkwhale_api.federation.routes.outbox.dispatch")
|
||||
artist = factories["music.Artist"](**{field: old_value})
|
||||
mutation = factories["common.Mutation"](
|
||||
type="update", target=artist, payload={field: new_value}
|
||||
)
|
||||
mutation.apply()
|
||||
artist.refresh_from_db()
|
||||
|
||||
assert getattr(artist, field) == expected
|
||||
dispatch.assert_called_once_with(
|
||||
{"type": "Update", "object": {"type": "Artist"}}, context={"artist": artist}
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"field, old_value, new_value, expected",
|
||||
[
|
||||
("title", "foo", "bar", "bar"),
|
||||
(
|
||||
"release_date",
|
||||
datetime.date(2016, 1, 1),
|
||||
"2018-02-01",
|
||||
datetime.date(2018, 2, 1),
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_album_mutation(field, old_value, new_value, expected, factories, now, mocker):
|
||||
dispatch = mocker.patch("funkwhale_api.federation.routes.outbox.dispatch")
|
||||
album = factories["music.Album"](**{field: old_value})
|
||||
mutation = factories["common.Mutation"](
|
||||
type="update", target=album, payload={field: new_value}
|
||||
)
|
||||
mutation.apply()
|
||||
album.refresh_from_db()
|
||||
|
||||
assert getattr(album, field) == expected
|
||||
dispatch.assert_called_once_with(
|
||||
{"type": "Update", "object": {"type": "Album"}}, context={"album": album}
|
||||
)
|
||||
|
||||
|
||||
def test_track_license_mutation(factories, now):
|
||||
track = factories["music.Track"](license=None)
|
||||
mutation = factories["common.Mutation"](
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue