Skip to content

Commit

Permalink
fix: is_expired exactly backward
Browse files Browse the repository at this point in the history
  • Loading branch information
aaxelb committed Oct 17, 2024
1 parent 5df7db0 commit 36ea734
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion share/models/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ def is_latest(self):
def is_expired(self) -> bool:
return (
self.expiration_date is not None
and self.expiration_date >= datetime.date.today()
and self.expiration_date <= datetime.date.today()
)

class Meta:
Expand Down
13 changes: 13 additions & 0 deletions tests/share/models/test_rawdata.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import datetime
import pytest
import hashlib

Expand Down Expand Up @@ -65,3 +66,15 @@ def test_store_data_dedups_complex(self, source_config):
assert rd2.created is False
assert rd1.date_modified < rd2.date_modified
assert rd1.date_created == rd2.date_created

def test_is_expired(self):
rd = RawDatum()
assert rd.expiration_date is None
assert not rd.is_expired
_today = datetime.date.today()
rd.expiration_date = datetime.date(_today.year - 1, _today.month, _today.day)
assert rd.is_expired
rd.expiration_date = datetime.date(_today.year, _today.month, _today.day)
assert rd.is_expired
rd.expiration_date = datetime.date(_today.year + 1, _today.month, _today.day)
assert not rd.is_expired

0 comments on commit 36ea734

Please sign in to comment.