|
17 | 17 |
|
18 | 18 | from app.config import Settings |
19 | 19 | from app.model.response.sample import Sample |
20 | | -from app.producer.outbound_producer import publish_to_outbound |
21 | 20 | from tests_integration.support.model.inbound_message import InboundMessage |
22 | 21 |
|
23 | 22 | PUBLISH_INBOUND_ENDPOINT = "/context/test-support/publish-inbound-messages" |
@@ -110,16 +109,11 @@ def test_publish_inbound_message_publishes_to_retries_and_succeeds_on_last_attem |
110 | 109 | test_client: TestClient, |
111 | 110 | captured_logs: list[MutableMapping[str, Any]], |
112 | 111 | ): |
113 | | - def side_effect_logic(*args, **kwargs): |
114 | | - if mock_publish_to_outbound.call_count == 1: |
115 | | - raise ValueError("First failure") |
116 | | - if mock_publish_to_outbound.call_count == 2: |
117 | | - raise TypeError("Second failure") |
118 | | - |
119 | | - # Call 3 and all future calls fall back to the real thing |
120 | | - return publish_to_outbound(*args, **kwargs) |
121 | | - |
122 | | - mock_publish_to_outbound.side_effect = side_effect_logic |
| 112 | + mock_publish_to_outbound.side_effect = [ |
| 113 | + ValueError("First failure"), |
| 114 | + ValueError("Second failure"), |
| 115 | + None, |
| 116 | + ] |
123 | 117 |
|
124 | 118 | sample1: Sample = Sample( |
125 | 119 | id=uuid.uuid4(), |
@@ -182,6 +176,16 @@ def side_effect_logic(*args, **kwargs): |
182 | 176 | ) |
183 | 177 | ).is_empty() |
184 | 178 |
|
| 179 | + for attempt in Retrying( |
| 180 | + stop=stop_after_delay(5), wait=wait_fixed(0.5), reraise=True |
| 181 | + ): |
| 182 | + with attempt: |
| 183 | + assert_that(mock_publish_to_outbound.call_count).is_equal_to(3) |
| 184 | + |
| 185 | + assert_that( |
| 186 | + mock_publish_to_outbound.call_args_list[2].kwargs["samples"] |
| 187 | + ).is_equal_to(samples) |
| 188 | + |
185 | 189 |
|
186 | 190 | def test_publish_bulk_inbound_message( |
187 | 191 | enable_test_components: Settings, |
|
0 commit comments