Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include number of unprocessed payloads in the error message #278

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions healthcheck/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ def check_status(self):
dt = timezone.now() + datetime.timedelta(seconds=settings.LICENSE_POLL_INTERVAL)
unprocessed_payloads = LicencePayload.objects.filter(is_processed=False, received_at__lte=dt)

for unprocessed_payload in unprocessed_payloads:
error_message = f"Payload object has been unprocessed for over {settings.LICENSE_POLL_INTERVAL} seconds: {unprocessed_payload}"
self.add_error(HealthCheckException(error_message))
error_message = f"Number of unprocessed payloads for over {settings.LICENSE_POLL_INTERVAL} seconds: {unprocessed_payloads.count()}"
self.add_error(HealthCheckException(error_message))


class PendingMailHealthCheck(BaseHealthCheckBackend):
Expand Down
5 changes: 4 additions & 1 deletion healthcheck/tests/test_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ def test_unprocessed_payloads(self):
check = LicencePayloadsHealthCheck()
check.check_status()
assert len(check.errors) == 1
assert "Payload object has been unprocessed for over" in check.errors[0].message
assert (
f"Number of unprocessed payloads for over {settings.LICENSE_POLL_INTERVAL} seconds: 1"
== check.errors[0].message
)

def test_all_payloads_processed(self):
LicencePayload.objects.create(
Expand Down