Skip to content

Commit e4e1406

Browse files
committed
fix send_message_batch tests that referenced retries
1 parent fa1dd50 commit e4e1406

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

manage_breast_screening/notifications/tests/management/commands/test_send_message_batch.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import json
21
from datetime import datetime, timedelta
32
from unittest.mock import ANY, MagicMock, patch
43

@@ -188,7 +187,7 @@ def test_handle_with_unrecoverable_failures(
188187
def test_handle_with_recoverable_failures(
189188
self, mark_batch_as_sent, mock_send_message_batch, status_code
190189
):
191-
"""Test that message batches which fail to send are marked correctly"""
190+
"""Test that message batches which fail to send are marked as unrecoverable"""
192191
notify_errors = {"errors": [{"some-error": "details"}]}
193192
mock_send_message_batch.return_value.status_code = status_code
194193
mock_send_message_batch.return_value.json.return_value = notify_errors
@@ -198,22 +197,12 @@ def test_handle_with_recoverable_failures(
198197
)
199198
routing_plan_id = RoutingPlan.for_episode_type(appointment.episode_type).id
200199

201-
with patch(
202-
"manage_breast_screening.notifications.views.Queue.RetryMessageBatches"
203-
) as mock_queue:
204-
queue_instance = MagicMock()
205-
mock_queue.return_value = queue_instance
206-
Command().handle()
200+
Command().handle()
207201

208202
message_batches = MessageBatch.objects.filter(routing_plan_id=routing_plan_id)
209203
assert message_batches.count() == 1
210-
assert message_batches[0].status == "failed_recoverable"
204+
assert message_batches[0].status == "failed_unrecoverable"
211205
assert message_batches[0].nhs_notify_errors == notify_errors
212-
queue_instance.add.assert_called_once_with(
213-
json.dumps(
214-
{"message_batch_id": str(message_batches[0].id), "retry_count": 0}
215-
)
216-
)
217206

218207
def test_handle_does_nothing_on_weekend(
219208
self, mock_mark_batch_as_sent, mock_send_message_batch, time_machine

0 commit comments

Comments
 (0)