Skip to content

Commit 8bf0170

Browse files
committed
Update test_fastapi.py
1 parent d9c229d commit 8bf0170

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

tests/test_serverless/test_modules/test_fastapi.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,12 @@ def test_stream(self):
242242
"error": "Stream not supported, handler must be a generator."
243243
}
244244

245+
# Test webhook caller sent
246+
with patch(f"{module_location}._send_webhook_async", return_value=True) as mock_send_webhook: # pylint: disable=line-too-long
247+
asyncio.run(worker_api._sim_run(input_object_with_webhook))
248+
asyncio.run(worker_api._sim_stream("test-123"))
249+
assert mock_send_webhook.called
250+
245251
# Test with generator handler
246252
def generator_handler(job):
247253
del job
@@ -256,12 +262,6 @@ def generator_handler(job):
256262
"stream": [{"output": {"result": "success"}}]
257263
}
258264

259-
# Test webhook caller sent
260-
with patch(f"{module_location}._send_webhook_async", return_value=True) as mock_send_webhook: # pylint: disable=line-too-long
261-
asyncio.run(worker_api._sim_run(input_object_with_webhook))
262-
asyncio.run(worker_api._sim_stream("test-123"))
263-
assert mock_send_webhook.called
264-
265265
loop.close()
266266

267267
@pytest.mark.asyncio
@@ -305,6 +305,12 @@ def test_status(self):
305305
"output": {"result": "success"}
306306
}
307307

308+
# Test webhook caller sent
309+
with patch(f"{module_location}._send_webhook_async", return_value=True) as mock_send_webhook: # pylint: disable=line-too-long
310+
asyncio.run(worker_api._sim_run(input_object_with_webhook))
311+
asyncio.run(worker_api._sim_status("test-123"))
312+
assert mock_send_webhook.called
313+
308314
# Test with generator handler
309315
def generator_handler(job):
310316
del job
@@ -326,10 +332,4 @@ def generator_handler(job):
326332
error_worker_api._sim_status("test-123"))
327333
assert "error" in error_status_return
328334

329-
# Test webhook caller sent
330-
with patch(f"{module_location}._send_webhook_async", return_value=True) as mock_send_webhook: # pylint: disable=line-too-long
331-
asyncio.run(worker_api._sim_run(input_object_with_webhook))
332-
asyncio.run(worker_api._sim_status("test-123"))
333-
assert mock_send_webhook.called
334-
335335
loop.close()

0 commit comments

Comments
 (0)