Skip to content

Commit 8cbecc1

Browse files
committed
Added new param to utils.get_max_download_date
1 parent 1561f06 commit 8cbecc1

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/imio/esign/tests/test_utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding: utf-8 -*-
22
"""utils tests for this package."""
3+
from datetime import date
34
from datetime import timedelta
45
from imio.esign.testing import IMIO_ESIGN_INTEGRATION_TESTING # noqa: E501
56
from imio.esign.utils import add_files_to_session
@@ -327,8 +328,10 @@ def test_get_file_download_url(self):
327328
def test_get_max_download_date(self):
328329
annex = self.folders[0]
329330
mod_date = annex.modified().asdatetime().date()
330-
self.assertEqual(get_max_download_date(annex), mod_date + timedelta(days=120))
331+
self.assertEqual(get_max_download_date(annex), mod_date + timedelta(days=90))
331332
self.assertEqual(get_max_download_date(annex, timedelta(days=0)), mod_date)
333+
today = date.today()
334+
self.assertEqual(get_max_download_date(None, timedelta(days=0), today), today)
332335

333336

334337
# example of annotation content

src/imio/esign/utils.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,12 +402,14 @@ def get_file_download_url(uid, separator="-", block_size=5, root_url=None):
402402
return "{}/{}".format(root_url.strip('/'), short_uid), short_uid
403403

404404

405-
def get_max_download_date(obj, delta=timedelta(days=120)):
405+
def get_max_download_date(obj, delta=timedelta(days=90), adate=None):
406406
"""Get the maximum download date for e-sign files. Is takes the modification date and adds delta.
407407
408408
:param obj: content object
409409
:param delta: timedelta to add to modification date
410+
:param adate: use date instead of modification date
410411
:return: maximum download date
411412
"""
412-
mod_date = obj.modified().asdatetime().date()
413-
return mod_date + delta
413+
if adate is None:
414+
adate = obj.modified().asdatetime().date()
415+
return adate + delta

0 commit comments

Comments
 (0)