diff --git a/src/documents/sanity_checker.py b/src/documents/sanity_checker.py index 413ebff32b..7949641ac3 100644 --- a/src/documents/sanity_checker.py +++ b/src/documents/sanity_checker.py @@ -49,8 +49,6 @@ class SanityCheckMessages: self._document_error_pks: set[int] = set() self._document_warning_pks: set[int] = set() self._document_info_pks: set[int] = set() - self._document_error_issue_count: int = 0 - self._document_warning_issue_count: int = 0 self.has_error: bool = False self.has_warning: bool = False self.has_info: bool = False @@ -76,17 +74,17 @@ class SanityCheckMessages: def error(self, doc_pk: int | None, message: str) -> None: self._messages[doc_pk].append({"level": logging.ERROR, "message": message}) self.has_error = True - if doc_pk is not None: - self._document_error_issue_count += 1 - if self._add_document_issue(doc_pk, self._document_error_pks): - self.document_error_count += 1 + if doc_pk is not None and self._add_document_issue( + doc_pk, + self._document_error_pks, + ): + self.document_error_count += 1 def warning(self, doc_pk: int | None, message: str) -> None: self._messages[doc_pk].append({"level": logging.WARNING, "message": message}) self.has_warning = True if doc_pk is not None: - self._document_warning_issue_count += 1 if self._add_document_issue(doc_pk, self._document_warning_pks): self.document_warning_count += 1 else: @@ -116,21 +114,6 @@ class SanityCheckMessages: def __getitem__(self, item: int | None) -> list[MessageEntry]: return self._messages[item] - # -- Summarize Helpers -------------------------------------------------- - - @property - def has_global_issues(self) -> bool: - return None in self._messages - - @property - def total_issue_count(self) -> int: - """Total number of error and warning messages across all documents and global.""" - return ( - self._document_error_issue_count - + self._document_warning_issue_count - + self.global_warning_count - ) - # -- Logging output (used by Celery task path) -------------------------- def log_messages(self) -> None: diff --git a/src/documents/tests/test_management_exporter.py b/src/documents/tests/test_management_exporter.py index ec6a21b772..9419f24fed 100644 --- a/src/documents/tests/test_management_exporter.py +++ b/src/documents/tests/test_management_exporter.py @@ -305,7 +305,8 @@ class TestExportImport( self.assertEqual(Permission.objects.count(), num_permission_objects) messages = check_sanity() # everything is alright after the test - self.assertEqual(messages.total_issue_count, 0) + self.assertFalse(messages.has_error) + self.assertFalse(messages.has_warning) def test_exporter_with_filename_format(self) -> None: shutil.rmtree(Path(self.dirs.media_dir) / "documents") diff --git a/src/documents/tests/test_sanity_check.py b/src/documents/tests/test_sanity_check.py index e04367f7b3..b78feef5ab 100644 --- a/src/documents/tests/test_sanity_check.py +++ b/src/documents/tests/test_sanity_check.py @@ -39,7 +39,6 @@ class TestSanityCheckMessages: assert messages.document_warning_count == 1 assert messages.document_info_count == 1 assert messages.global_warning_count == 1 - assert messages.total_issue_count == 5 @pytest.mark.django_db @@ -51,7 +50,6 @@ class TestCheckSanityNoDocuments: messages = check_sanity() assert not messages.has_error assert not messages.has_warning - assert messages.total_issue_count == 0 @pytest.mark.usefixtures("paperless_dirs") def test_no_issues_logs_clean(self, caplog: pytest.LogCaptureFixture) -> None: @@ -67,7 +65,6 @@ class TestCheckSanityHealthyDocument: messages = check_sanity() assert not messages.has_error assert not messages.has_warning - assert messages.total_issue_count == 0 @pytest.mark.django_db