mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-05 03:29:23 +02:00
Resolve "Adding cover art to my albums"
This commit is contained in:
parent
7c6855d915
commit
11a533fa92
17 changed files with 388 additions and 27 deletions
|
@ -1,6 +1,7 @@
|
|||
import pytest
|
||||
import datetime
|
||||
|
||||
from funkwhale_api.common import models
|
||||
from funkwhale_api.common import serializers
|
||||
from funkwhale_api.common import signals
|
||||
from funkwhale_api.common import tasks
|
||||
|
@ -68,21 +69,27 @@ def test_cannot_apply_already_applied_migration(factories):
|
|||
|
||||
def test_prune_unattached_attachments(factories, settings, now):
|
||||
settings.ATTACHMENTS_UNATTACHED_PRUNE_DELAY = 5
|
||||
prunable_date = now - datetime.timedelta(
|
||||
seconds=settings.ATTACHMENTS_UNATTACHED_PRUNE_DELAY
|
||||
)
|
||||
attachments = [
|
||||
# attached, kept
|
||||
factories["music.Album"]().attachment_cover,
|
||||
# recent, kept
|
||||
factories["common.Attachment"](),
|
||||
# too old, pruned
|
||||
factories["common.Attachment"](
|
||||
creation_date=now
|
||||
- datetime.timedelta(seconds=settings.ATTACHMENTS_UNATTACHED_PRUNE_DELAY)
|
||||
),
|
||||
factories["common.Attachment"](creation_date=prunable_date),
|
||||
# attached to a mutation, kept even if old
|
||||
models.MutationAttachment.objects.create(
|
||||
mutation=factories["common.Mutation"](payload={}),
|
||||
attachment=factories["common.Attachment"](creation_date=prunable_date),
|
||||
).attachment,
|
||||
]
|
||||
|
||||
tasks.prune_unattached_attachments()
|
||||
|
||||
attachments[0].refresh_from_db()
|
||||
attachments[1].refresh_from_db()
|
||||
attachments[3].refresh_from_db()
|
||||
with pytest.raises(attachments[2].DoesNotExist):
|
||||
attachments[2].refresh_from_db()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue