Skip to content

Commit 284a9c3

Browse files
committed
feat: message group id for report request and reporting tasks
1 parent 3dbedbb commit 284a9c3

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

app/celery/reporting_tasks.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ def create_nightly_notification_status():
174174
"service_id": service_id,
175175
},
176176
queue=QueueNames.REPORTING,
177+
MessageGroupId=str(service_id),
177178
)
178179

179180

app/service/rest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1610,6 +1610,7 @@ def create_report_request_by_type(service_id):
16101610
process_report_request.apply_async(
16111611
kwargs={"service_id": report_request.service_id, "report_request_id": report_request.id},
16121612
queue=QueueNames.REPORT_REQUESTS_NOTIFICATIONS,
1613+
MessageGroupId=str(report_request.service_id),
16131614
)
16141615

16151616
return jsonify(data=created_request.serialize()), 201

tests/app/celery/test_reporting_tasks.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ def test_create_nightly_notification_status_triggers_tasks(
7878
mock_celery.assert_called_with(
7979
kwargs={"service_id": sample_service.id, "process_day": "2019-07-31", "notification_type": SMS_TYPE},
8080
queue=QueueNames.REPORTING,
81+
MessageGroupId=str(sample_service.id),
8182
)
8283

8384

tests/app/service/test_rest.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2598,7 +2598,11 @@ def test_verify_reply_to_email_address_should_send_verification_email(
25982598
notification = Notification.query.first()
25992599
assert notification.template_id == verify_reply_to_address_email_template.id
26002600
assert response["data"] == {"id": str(notification.id)}
2601-
mocked.assert_called_once_with([str(notification.id)], queue="notify-internal-tasks")
2601+
mocked.assert_called_once_with(
2602+
[str(notification.id)],
2603+
queue="notify-internal-tasks",
2604+
MessageGroupId=str(notification.service_id),
2605+
)
26022606
assert notification.reply_to_text == notify_service.get_default_reply_to_email_address()
26032607

26042608

@@ -4594,7 +4598,11 @@ def test_update_service_join_request_by_id_notification_sent(
45944598
)
45954599

45964600
notification = Notification.query.first()
4597-
mock_deliver_email_task.assert_called_once_with(([str(notification.id)]), queue="notify-internal-tasks")
4601+
mock_deliver_email_task.assert_called_once_with(
4602+
([str(notification.id)]),
4603+
queue="notify-internal-tasks",
4604+
MessageGroupId=str(notification.service_id),
4605+
)
45984606

45994607
assert notification.reply_to_text == notify_service.get_default_reply_to_email_address()
46004608
assert notification.to == f"{requester_id}@digital.cabinet-office.gov.uk"
@@ -4640,7 +4648,11 @@ def test_update_service_join_request_get_template(
46404648
)
46414649

46424650
notification = Notification.query.first()
4643-
mock_deliver_email_task.assert_called_once_with(([str(notification.id)]), queue="notify-internal-tasks")
4651+
mock_deliver_email_task.assert_called_once_with(
4652+
([str(notification.id)]),
4653+
queue="notify-internal-tasks",
4654+
MessageGroupId=str(notification.service_id),
4655+
)
46444656

46454657
assert notification.template.version == template.version
46464658
assert notification.template_id == template.id
@@ -4786,6 +4798,7 @@ def test_create_report_request_by_type(
47864798
"service_id": sample_service.id,
47874799
},
47884800
queue="report-requests-notifications-tasks",
4801+
MessageGroupId=str(sample_service.id),
47894802
)
47904803

47914804
assert json_resp["data"]["id"]
@@ -4869,6 +4882,7 @@ def test_create_report_request_by_type_creates_new_when_no_existing(admin_reques
48694882
"service_id": sample_service.id,
48704883
},
48714884
queue="report-requests-notifications-tasks",
4885+
MessageGroupId=str(sample_service.id),
48724886
)
48734887

48744888

@@ -4917,4 +4931,5 @@ def test_create_report_request_by_type_creates_new_if_existing_is_stale(
49174931
"service_id": sample_service.id,
49184932
},
49194933
queue="report-requests-notifications-tasks",
4934+
MessageGroupId=str(sample_service.id),
49204935
)

0 commit comments

Comments
 (0)