Skip to content

Commit

Permalink
fix: unawaited coroutines in test conductor
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Bluhm <[email protected]>
  • Loading branch information
dbluhm committed Oct 27, 2023
1 parent 5b64fc1 commit 89e87c1
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions aries_cloudagent/core/tests/test_conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,10 @@ async def test_handle_nots(self):
) as mock_conn_mgr, mock.patch.object(
conductor.dispatcher, "run_task", mock.MagicMock()
) as mock_run_task:
mock_conn_mgr.return_value.get_connection_targets = mock.CoroutineMock()
# Normally this should be a coroutine mock; however, the coroutine
# is awaited by dispatcher.run_task, which is mocked here. MagicMock
# to prevent unawaited coroutine warning.
mock_conn_mgr.return_value.get_connection_targets = mock.MagicMock()
mock_run_task.side_effect = test_module.ConnectionManagerError()
await conductor.queue_outbound(conductor.root_profile, message)
mock_outbound_mgr.return_value.enqueue_message.assert_not_called()
Expand Down Expand Up @@ -749,7 +752,12 @@ async def test_handle_not_returned_ledger_x(self):
with mock.patch.object(
conductor.dispatcher, "run_task", mock.MagicMock()
) as mock_dispatch_run, mock.patch.object(
conductor, "queue_outbound", mock.CoroutineMock()
# Normally this should be a coroutine mock; however, the coroutine
# is awaited by dispatcher.run_task, which is mocked here. MagicMock
# to prevent unawaited coroutine warning.
conductor,
"queue_outbound",
mock.MagicMock(),
) as mock_queue, mock.patch.object(
conductor.admin_server, "notify_fatal_error", mock.MagicMock()
) as mock_notify:
Expand Down Expand Up @@ -789,7 +797,10 @@ async def test_queue_outbound_ledger_x(self):
) as mock_dispatch_run, mock.patch.object(
conductor.admin_server, "notify_fatal_error", mock.MagicMock()
) as mock_notify:
conn_mgr.return_value.get_connection_targets = mock.CoroutineMock()
# Normally this should be a coroutine mock; however, the coroutine
# is awaited by dispatcher.run_task, which is mocked here. MagicMock
# to prevent unawaited coroutine warning.
conn_mgr.return_value.get_connection_targets = mock.MagicMock()
mock_dispatch_run.side_effect = test_module.LedgerConfigError(
"No such ledger"
)
Expand Down

0 comments on commit 89e87c1

Please sign in to comment.