Only allow MusicBrainz tagged file on a pod (#2083)

Part-of: <https://dev.funkwhale.audio/funkwhale/funkwhale/-/merge_requests/2607>
This commit is contained in:
Petitminion 2023-11-03 16:44:41 +01:00 committed by Marge
commit 2e3205a19d
3 changed files with 37 additions and 0 deletions

View file

@ -1400,3 +1400,30 @@ def test_fs_import(factories, cache, mocker, settings):
}
assert cache.get("fs-import:status") == "finished"
assert "Pruning dangling tracks" in cache.get("fs-import:logs")[-1]
def test_upload_checks_mbid_tag(temp_signal, factories, mocker):
mocker.patch("funkwhale_api.federation.routes.outbox.dispatch")
mocker.patch("funkwhale_api.music.tasks.populate_album_cover")
mocker.patch("funkwhale_api.music.metadata.Metadata.get_picture")
# mocker.spy(tasks, "get_track_from_import_metadata")
track = factories["music.Track"](album__attachment_cover=None, mbid=None)
path = os.path.join(DATA_DIR, "with_cover.opus")
upload = factories["music.Upload"](
track=None,
audio_file__from_path=path,
import_metadata={"funkwhale": {"track": {"uuid": str(track.uuid)}}},
)
mocker.patch("funkwhale_api.music.models.TrackActor.create_entries")
with temp_signal(signals.upload_import_status_updated) as handler:
tasks.process_upload(upload_id=upload.pk)
upload.refresh_from_db()
assert upload.import_status == "errored"
assert upload.import_details == {
"error_code": "Uploading files without a MusicBrainz ID is not permitted in this pod",
"detail": "You can tag you files with MusicBrainz Picard",
}