mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-04 13:39:17 +02:00
Attachments
This commit is contained in:
parent
421b441dbe
commit
c84396e669
50 changed files with 879 additions and 261 deletions
|
@ -1,4 +1,5 @@
|
|||
import pytest
|
||||
import datetime
|
||||
|
||||
from funkwhale_api.common import serializers
|
||||
from funkwhale_api.common import signals
|
||||
|
@ -63,3 +64,25 @@ def test_cannot_apply_already_applied_migration(factories):
|
|||
mutation = factories["common.Mutation"](payload={}, is_applied=True)
|
||||
with pytest.raises(mutation.__class__.DoesNotExist):
|
||||
tasks.apply_mutation(mutation_id=mutation.pk)
|
||||
|
||||
|
||||
def test_prune_unattached_attachments(factories, settings, now):
|
||||
settings.ATTACHMENTS_UNATTACHED_PRUNE_DELAY = 5
|
||||
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)
|
||||
),
|
||||
]
|
||||
|
||||
tasks.prune_unattached_attachments()
|
||||
|
||||
attachments[0].refresh_from_db()
|
||||
attachments[1].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