mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
added sanity checker management command for manual execution #534
This commit is contained in:
@@ -65,6 +65,7 @@ class TestArchiver(DirectoriesMixin, TestCase):
|
||||
self.assertEqual(doc1.archive_filename, "document.pdf")
|
||||
self.assertEqual(doc2.archive_filename, "document_01.pdf")
|
||||
|
||||
|
||||
class TestDecryptDocuments(TestCase):
|
||||
|
||||
@override_settings(
|
||||
@@ -154,3 +155,37 @@ class TestCreateClassifier(TestCase):
|
||||
call_command("document_create_classifier")
|
||||
|
||||
m.assert_called_once()
|
||||
|
||||
|
||||
class TestSanityChecker(DirectoriesMixin, TestCase):
|
||||
|
||||
def test_no_errors(self):
|
||||
with self.assertLogs() as capture:
|
||||
call_command("document_sanity_checker")
|
||||
|
||||
self.assertEqual(len(capture.output), 1)
|
||||
self.assertIn("No issues found.", capture.output[0])
|
||||
|
||||
@mock.patch("documents.management.commands.document_sanity_checker.logger.warning")
|
||||
@mock.patch("documents.management.commands.document_sanity_checker.logger.error")
|
||||
def test_warnings(self, error, warning):
|
||||
doc = Document.objects.create(title="test", filename="test.pdf", checksum="d41d8cd98f00b204e9800998ecf8427e")
|
||||
Path(doc.source_path).touch()
|
||||
Path(doc.thumbnail_path).touch()
|
||||
|
||||
call_command("document_sanity_checker")
|
||||
|
||||
error.assert_not_called()
|
||||
warning.assert_called()
|
||||
|
||||
@mock.patch("documents.management.commands.document_sanity_checker.logger.warning")
|
||||
@mock.patch("documents.management.commands.document_sanity_checker.logger.error")
|
||||
def test_errors(self, error, warning):
|
||||
doc = Document.objects.create(title="test", content="test", filename="test.pdf", checksum="abc")
|
||||
Path(doc.source_path).touch()
|
||||
Path(doc.thumbnail_path).touch()
|
||||
|
||||
call_command("document_sanity_checker")
|
||||
|
||||
warning.assert_not_called()
|
||||
error.assert_called()
|
||||
|
Reference in New Issue
Block a user