Skip to content

Commit 3d0e444

Browse files
committed
Merge remote-tracking branch 'origin/release/2.9' into develop
2 parents 0ea52c7 + 4854fa5 commit 3d0e444

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

apps/archived/archived.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from operator import itemgetter
1212
from copy import deepcopy
13-
from flask import current_app as app
13+
from flask import current_app as app, request
1414
from eve.utils import config, ParsedRequest
1515
import logging
1616

@@ -178,7 +178,7 @@ def validate_delete_action(self, doc, allow_all_types=False):
178178
doc[config.ID_FIELD] = id_field
179179

180180
def on_delete(self, doc):
181-
self.validate_delete_action(doc)
181+
self.validate_delete_action(doc, allow_all_types=not request)
182182

183183
def delete(self, lookup):
184184
if app.testing and len(lookup) == 0:

tests/archive/commands_test.py

+24
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,35 @@
11
from superdesk.tests import TestCase
22
from superdesk.utc import utcnow
33
from apps.archive.commands import RemoveExpiredContent
4+
from datetime import datetime
5+
from unittest.mock import patch
6+
from bson import ObjectId
47

58

69
class RemoveExpiredContentTestCase(TestCase):
10+
test_context = False
11+
712
def test_is_expired(self):
813
command = RemoveExpiredContent()
914
item = {"expiry": None, "_id": "foo"}
1015
now = utcnow()
1116
self.assertFalse(command._can_remove_item(item, now))
17+
18+
def test_expired_archived_picture(self):
19+
self.app.data.insert(
20+
"archived",
21+
[
22+
{
23+
"type": "picture",
24+
"_id": ObjectId.from_datetime(datetime(2024, 1, 1)),
25+
"item_id": "test",
26+
"guid": "test",
27+
},
28+
],
29+
)
30+
31+
with patch.dict(self.app.config, {"ARCHIVED_EXPIRY_MINUTES": 1}):
32+
RemoveExpiredContent().run()
33+
34+
archived_items = self.app.data.find_all("archived")
35+
assert 0 == archived_items.count()

0 commit comments

Comments
 (0)