Skip to content

Commit

Permalink
test: new auto-response paths in connections and didexchange
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Bluhm <dbluhm@pm.me>
  • Loading branch information
dbluhm committed Dec 3, 2021
1 parent 2869e45 commit eec51a1
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,24 @@ async def test_called(self, mock_conn_mgr, request_context):
)
assert not responder.messages

@pytest.mark.asyncio
@async_mock.patch.object(handler, "ConnectionManager")
async def test_called_with_auto_response(self, mock_conn_mgr, request_context):
mock_conn_rec = async_mock.MagicMock()
mock_conn_rec.accept = ConnRecord.ACCEPT_AUTO
mock_conn_mgr.return_value.receive_request = async_mock.CoroutineMock(
return_value=mock_conn_rec
)
mock_conn_mgr.return_value.create_response = async_mock.CoroutineMock()
request_context.message = ConnectionRequest()
handler_inst = handler.ConnectionRequestHandler()
responder = MockResponder()
await handler_inst.handle(request_context, responder)
mock_conn_mgr.return_value.receive_request.assert_called_once_with(
request_context.message, request_context.message_receipt, mediation_id=None
)
assert responder.messages

@pytest.mark.asyncio
@async_mock.patch.object(handler, "ConnectionManager")
async def test_connection_record_with_mediation_metadata(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,28 @@ async def test_called(self, mock_didx_mgr):
)
assert not responder.messages

@async_mock.patch.object(test_module, "DIDXManager")
async def test_called_with_auto_response(self, mock_didx_mgr):
mock_conn_rec = async_mock.MagicMock()
mock_conn_rec.accept = conn_record.ConnRecord.ACCEPT_AUTO
mock_conn_rec.save = async_mock.CoroutineMock()
mock_didx_mgr.return_value.receive_request = async_mock.CoroutineMock(
return_value=mock_conn_rec
)
mock_didx_mgr.return_value.create_response = async_mock.CoroutineMock()
self.ctx.message = DIDXRequest()
handler_inst = test_module.DIDXRequestHandler()
responder = MockResponder()
await handler_inst.handle(self.ctx, responder)

mock_didx_mgr.return_value.receive_request.assert_called_once_with(
request=self.ctx.message,
recipient_did=self.ctx.message_receipt.recipient_did,
recipient_verkey=None,
mediation_id=None,
)
assert responder.messages

@async_mock.patch.object(test_module, "DIDXManager")
async def test_problem_report(self, mock_didx_mgr):
mock_didx_mgr.return_value.receive_request = async_mock.CoroutineMock(
Expand Down

0 comments on commit eec51a1

Please sign in to comment.