Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

Commit

Permalink
fix codestyle & test
Browse files Browse the repository at this point in the history
  • Loading branch information
MacWale committed Mar 1, 2022
1 parent a26f8da commit 9d3383a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/documents/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ def sanity_check():


def remove_expired_documents():
i=0
i = 0
expiredDocuments = Document.objects.filter(expired__lte=Now())

for doc in expiredDocuments:
logger.info("Delete expired document {}...".format(doc.title))
doc.delete()
i+=1
i += 1

return "{} expired documents deleted.".format(i)

Expand Down
6 changes: 3 additions & 3 deletions src/documents/tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ def test_remove_expired_zero_from_one(self):
self.assertEqual(tasks.remove_expired_documents(), "0 expired documents deleted.")

def test_remove_expired_one_from_three(self):
doc1 = Document.objects.create(title="test", content="my document", checksum="wow", added=timezone.now(),
doc1 = Document.objects.create(title="test", content="my document", checksum="wow1", added=timezone.now(),
created=timezone.now(), modified=timezone.now(), expired=timezone.now()+timezone.timedelta(days=-1))
doc2 = Document.objects.create(title="test", content="my document", checksum="wow", added=timezone.now(),
doc2 = Document.objects.create(title="test", content="my document", checksum="wow2", added=timezone.now(),
created=timezone.now(), modified=timezone.now(), expired=timezone.now()+timezone.timedelta(days=1))
doc3= Document.objects.create(title="test", content="my document", checksum="wow", added=timezone.now(),
doc3= Document.objects.create(title="test", content="my document", checksum="wow3", added=timezone.now(),
created=timezone.now(), modified=timezone.now())
self.assertEqual(tasks.remove_expired_documents(), "0 expired documents deleted.")

Expand Down

0 comments on commit 9d3383a

Please sign in to comment.