mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-09 00:05:21 +01:00
added sanity checker management command for manual execution #534
This commit is contained in:
parent
ed478a1d73
commit
8b2965d55b
6 changed files with 101 additions and 3 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue