Test updates

This commit is contained in:
Alex Janousek
2025-09-26 17:42:01 -04:00
parent 96c9bc3e5e
commit 50ed613ebf

View File

@@ -1,15 +1,11 @@
""" """
Tests for job notification update logic during polling. Tests for disabled job polling endpoint.
These tests verify the poll status endpoint behavior and document These tests verify that the poll status endpoint is properly disabled
the JavaScript notification refresh logic: and returns 410 Gone status. The JavaScript notification refresh logic
1. Notifications update for first 50 messages is no longer used as polling has been replaced with manual refresh.
2. Notifications stop updating after 50 messages (to prevent performance issues)
3. Notifications always update when job finishes
""" """
import json
import pytest import pytest
@@ -58,31 +54,14 @@ def test_poll_status_notification_update_logic(
"main.view_job_status_poll", "main.view_job_status_poll",
service_id=service_one["id"], service_id=service_one["id"],
job_id=fake_uuid, job_id=fake_uuid,
_expected_status=410,
) )
assert response.status_code == 200 assert response.status_code == 410
data = json.loads(response.get_data(as_text=True)) # Endpoint is disabled, so no data to verify
# Verify the response # Since the polling endpoint is disabled, the JavaScript logic being tested
assert data["sent_count"] == delivered # is no longer relevant. The test now verifies the endpoint is disabled.
assert data["failed_count"] == failed
assert data["pending_count"] == pending
assert data["total_count"] == total
assert data["finished"] is finished
processed_count = delivered + failed
if js_should_update_notifications:
# JavaScript would call: await updateNotifications()
if finished:
assert finished, f"JS updates notifications: {reason}"
else:
assert processed_count <= 50, f"JS updates notifications: {reason}"
assert not finished, f"JS updates notifications: {reason}"
else:
# JavaScript would NOT update notifications
assert processed_count > 50, f"JS skips notification update: {reason}"
assert not finished, f"JS skips notification update: {reason}"
def test_poll_status_provides_required_fields( def test_poll_status_provides_required_fields(
@@ -107,12 +86,7 @@ def test_poll_status_provides_required_fields(
"main.view_job_status_poll", "main.view_job_status_poll",
service_id=service_one["id"], service_id=service_one["id"],
job_id=fake_uuid, job_id=fake_uuid,
_expected_status=410,
) )
data = json.loads(response.get_data(as_text=True)) assert response.status_code == 410
required_fields = {"sent_count", "failed_count", "finished", "pending_count", "total_count"}
assert set(data.keys()) == required_fields
response_size = len(response.get_data(as_text=True))
assert response_size < 200, f"Response too large: {response_size} bytes"