Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

more tests

jonaswinklere24b40de2919
diff --git a/src/documents/tests/test_tasks.py b/src/documents/tests/test_tasks.py
index 6d04e58e1..653590707 100644
--- a/src/documents/tests/test_tasks.py
+++ b/src/documents/tests/test_tasks.py
@@ -1,10 +1,12 @@
from datetime import datetime
+from unittest import mock
from django.test import TestCase
from django.utils import timezone
from documents import tasks
from documents.models import Document
+from documents.sanity_checker import SanityError, SanityFailedError
from documents.tests.utils import DirectoriesMixin
@@ -22,3 +24,19 @@ class TestTasks(DirectoriesMixin, TestCase):
def test_train_classifier(self):
tasks.train_classifier()
+
+ @mock.patch("documents.tasks.sanity_checker.check_sanity")
+ def test_sanity_check(self, m):
+ m.return_value = []
+ tasks.sanity_check()
+ m.assert_called_once()
+ m.reset_mock()
+ m.return_value = [SanityError("")]
+ self.assertRaises(SanityFailedError, tasks.sanity_check)
+ m.assert_called_once()
+
+ def test_culk_update_documents(self):
+ doc1 = Document.objects.create(title="test", content="my document", checksum="wow", added=timezone.now(),
+ created=timezone.now(), modified=timezone.now())
+
+ tasks.bulk_update_documents([doc1.pk])