Chore: remove unused SanityCheckMessages summary properties

has_global_issues was never referenced and total_issue_count was only asserted in tests. The two private issue counters that fed it are removed as well, and the tests assert on has_error and has_warning instead.
This commit is contained in:
Trenton H committed 2026-11-16 07:22:22 -08:00
1 parent e1bd11d0e4
commit 03e53fd724
3 files changed
+7 -26

No files matched your search

+5 -22
View File
@@ -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:
@@ -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")
-3
View File
@@ -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