diff --git a/src/documents/sanity_checker.py b/src/documents/sanity_checker.py index 7fe8ec88e..90aea9866 100644 --- a/src/documents/sanity_checker.py +++ b/src/documents/sanity_checker.py @@ -38,7 +38,10 @@ class SanityCheckMessages: for doc_pk in self._messages: if doc_pk is not None: doc = all_docs.get(pk=doc_pk) - logger.info(f"Document: {doc.pk}, title: {doc.title}") + logger.info( + f"Detected following issue(s) with document #{doc.pk}," + f" titled {doc.title}", + ) for msg in self._messages[doc_pk]: logger.log(msg["level"], msg["message"]) diff --git a/src/documents/tests/test_management_exporter.py b/src/documents/tests/test_management_exporter.py index c509b9339..66fee3948 100644 --- a/src/documents/tests/test_management_exporter.py +++ b/src/documents/tests/test_management_exporter.py @@ -6,6 +6,7 @@ import tempfile from pathlib import Path from unittest import mock +import pytest from django.core.management import call_command from django.test import override_settings from django.test import TestCase @@ -190,7 +191,7 @@ class TestExportImport(DirectoriesMixin, TestCase): self.assertEqual(Document.objects.get(id=self.d4.id).title, "wow_dec") messages = check_sanity() # everything is alright after the test - self.assertEqual(len(messages), 0, str([str(m) for m in messages])) + self.assertEqual(len(messages), 0) def test_exporter_with_filename_format(self): shutil.rmtree(os.path.join(self.dirs.media_dir, "documents")) diff --git a/src/documents/tests/test_sanity_check.py b/src/documents/tests/test_sanity_check.py index 4a61ac7ff..f8d554277 100644 --- a/src/documents/tests/test_sanity_check.py +++ b/src/documents/tests/test_sanity_check.py @@ -63,9 +63,9 @@ class TestSanityCheck(DirectoriesMixin, TestCase): self.assertTrue(messages.has_error) with self.assertLogs() as capture: messages.log_messages() - self.assertRegex( + self.assertEqual( capture.records[0].message, - f"Document: {doc.pk}, title: {doc.title}", + f"Detected following issue(s) with document #{doc.pk}, titled {doc.title}", ) self.assertRegex(capture.records[1].message, messageRegex) diff --git a/src/documents/tests/test_tasks.py b/src/documents/tests/test_tasks.py index 41b9380db..998b7d955 100644 --- a/src/documents/tests/test_tasks.py +++ b/src/documents/tests/test_tasks.py @@ -538,7 +538,7 @@ class TestTasks(DirectoriesMixin, TestCase): @mock.patch("documents.tasks.sanity_checker.check_sanity") def test_sanity_check_error(self, m): messages = SanityCheckMessages() - messages.error("Some error") + messages.error(None, "Some error") m.return_value = messages self.assertRaises(SanityCheckFailedException, tasks.sanity_check) m.assert_called_once() @@ -546,7 +546,7 @@ class TestTasks(DirectoriesMixin, TestCase): @mock.patch("documents.tasks.sanity_checker.check_sanity") def test_sanity_check_warning(self, m): messages = SanityCheckMessages() - messages.warning("Some warning") + messages.warning(None, "Some warning") m.return_value = messages self.assertEqual( tasks.sanity_check(), @@ -557,7 +557,7 @@ class TestTasks(DirectoriesMixin, TestCase): @mock.patch("documents.tasks.sanity_checker.check_sanity") def test_sanity_check_info(self, m): messages = SanityCheckMessages() - messages.info("Some info") + messages.info(None, "Some info") m.return_value = messages self.assertEqual( tasks.sanity_check(),