mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-28 03:46:06 -05:00 
			
		
		
		
	more tests
This commit is contained in:
		| @@ -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]) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 jonaswinkler
					jonaswinkler