@@ -29,12 +29,10 @@ def setup(monkeypatch):
2929@patch .object (Queue , "RetryMessageBatches" , return_value = MagicMock (spec = Queue ))
3030@patch .object (MessageBatchHelpers , "mark_batch_as_sent" )
3131@patch .object (MessageBatchHelpers , "mark_batch_as_failed" )
32- @patch ("time.sleep" , return_value = MagicMock ())
3332class TestRetryFailedMessageBatch :
3433 @pytest .mark .django_db
3534 def test_handle_batch_not_found (
3635 self ,
37- mock_sleep ,
3836 mock_mark_batch_as_failed ,
3937 mock_mark_batch_as_sent ,
4038 mock_retry_message_batches ,
@@ -59,7 +57,6 @@ def test_handle_batch_not_found(
5957 @pytest .mark .django_db
6058 def test_not_failed_yet (
6159 self ,
62- mock_sleep ,
6360 mock_mark_batch_as_failed ,
6461 mock_mark_batch_as_sent ,
6562 mock_retry_message_batches ,
@@ -83,7 +80,6 @@ def test_not_failed_yet(
8380 @pytest .mark .django_db
8481 def test_server_error_when_resending_batch (
8582 self ,
86- mock_sleep ,
8783 mock_mark_batch_as_failed ,
8884 mock_mark_batch_as_sent ,
8985 mock_retry_message_batches ,
@@ -110,7 +106,6 @@ def test_server_error_when_resending_batch(
110106 @pytest .mark .django_db
111107 def test_successfully_resends_batch (
112108 self ,
113- mock_sleep ,
114109 mock_mark_batch_as_failed ,
115110 mock_mark_batch_as_sent ,
116111 mock_retry_message_batches ,
@@ -133,12 +128,10 @@ def test_successfully_resends_batch(
133128 message_batch = failed_batch , response_json = ANY
134129 )
135130 mock_retry_message_batches .return_value .delete .assert_called_with (mocked_item ())
136- mock_sleep .assert_called_with (10 )
137131
138132 @pytest .mark .django_db
139133 def test_no_batches_in_queue (
140134 self ,
141- mock_sleep ,
142135 mock_mark_batch_as_failed ,
143136 mock_mark_batch_as_sent ,
144137 mock_retry_message_batches ,
@@ -157,7 +150,6 @@ def test_no_batches_in_queue(
157150 @pytest .mark .django_db
158151 def test_batch_with_retry_count_more_than_5_is_marked_as_failed_unrecoverable (
159152 self ,
160- mock_sleep ,
161153 mock_mark_batch_as_failed ,
162154 mock_mark_batch_as_sent ,
163155 mock_retry_message_batches ,
@@ -178,24 +170,3 @@ def test_batch_with_retry_count_more_than_5_is_marked_as_failed_unrecoverable(
178170 str (error .value )
179171 == f"Message Batch with id { batch_id } not sent: Retry limit exceeded"
180172 )
181-
182- @pytest .mark .django_db
183- def test_sleeps_based_on_retry_count (
184- self ,
185- mock_sleep ,
186- mock_mark_batch_as_failed ,
187- mock_mark_batch_as_sent ,
188- mock_retry_message_batches ,
189- mock_send_message_batch ,
190- ):
191- mock_send_message_batch .return_value .status_code = 201
192- subject = Command ()
193- batch_id = uuid .uuid4 ()
194- _failed_batch = MessageBatchFactory (id = batch_id , status = "failed_recoverable" )
195- mock_retry_message_batches .return_value .item .return_value .content = json .dumps (
196- {"message_batch_id" : str (batch_id ), "retry_count" : 3 }
197- )
198-
199- subject .handle ()
200-
201- mock_sleep .assert_called_with (30 )
0 commit comments