-
Notifications
You must be signed in to change notification settings - Fork 533
Issue #3845 fix : auto-store failure going to done state #3999
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -75,10 +75,12 @@ async def test_called_auto_store_x_indy(self): | |
| with mock.patch.object( | ||
| test_module, "V20CredManager", autospec=True | ||
| ) as mock_cred_mgr: | ||
| mock_cred_ex = mock.MagicMock( | ||
| save_error_state=mock.CoroutineMock(), | ||
| save=mock.CoroutineMock(), | ||
| ) | ||
| mock_cred_mgr.return_value = mock.MagicMock( | ||
| receive_credential=mock.CoroutineMock( | ||
| return_value=mock.MagicMock(save_error_state=mock.CoroutineMock()) | ||
| ), | ||
| receive_credential=mock.CoroutineMock(return_value=mock_cred_ex), | ||
| store_credential=mock.CoroutineMock( | ||
| side_effect=[ | ||
| test_module.IndyHolderError, | ||
|
Comment on lines
84
to
86
|
||
|
|
@@ -92,18 +94,25 @@ async def test_called_auto_store_x_indy(self): | |
| self.request_context.connection_ready = True | ||
| handler_inst = test_module.V20CredIssueHandler() | ||
| responder = MockResponder() | ||
| self.request_context.settings["debug.auto_store_credential"] = True | ||
|
|
||
| await handler_inst.handle(self.request_context, responder) # holder error | ||
| await handler_inst.handle(self.request_context, responder) # storage error | ||
|
|
||
| assert mock_cred_mgr.return_value.send_cred_ack.call_count == 0 | ||
| assert mock_cred_ex.save_error_state.call_count == 1 | ||
| assert mock_cred_ex.save.call_count == 1 | ||
esune marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| async def test_called_auto_store_x_anoncreds(self): | ||
| with mock.patch.object( | ||
| test_module, "V20CredManager", autospec=True | ||
| ) as mock_cred_mgr: | ||
| mock_cred_ex = mock.MagicMock( | ||
| save_error_state=mock.CoroutineMock(), | ||
| save=mock.CoroutineMock(), | ||
| ) | ||
|
Comment on lines
+110
to
+113
|
||
| mock_cred_mgr.return_value = mock.MagicMock( | ||
| receive_credential=mock.CoroutineMock( | ||
| return_value=mock.MagicMock(save_error_state=mock.CoroutineMock()) | ||
| ), | ||
| receive_credential=mock.CoroutineMock(return_value=mock_cred_ex), | ||
| store_credential=mock.CoroutineMock( | ||
| side_effect=[ | ||
| test_module.AnonCredsHolderError, | ||
|
Comment on lines
116
to
118
|
||
|
|
@@ -117,10 +126,15 @@ async def test_called_auto_store_x_anoncreds(self): | |
| self.request_context.connection_ready = True | ||
| handler_inst = test_module.V20CredIssueHandler() | ||
| responder = MockResponder() | ||
| self.request_context.settings["debug.auto_store_credential"] = True | ||
|
|
||
| await handler_inst.handle(self.request_context, responder) # holder error | ||
| await handler_inst.handle(self.request_context, responder) # storage error | ||
|
|
||
| assert mock_cred_mgr.return_value.send_cred_ack.call_count == 0 | ||
| assert mock_cred_ex.save_error_state.call_count == 1 | ||
| assert mock_cred_ex.save.call_count == 1 | ||
esune marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| async def test_called_not_ready(self): | ||
| with mock.patch.object( | ||
| test_module, "V20CredManager", autospec=True | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The mock object
mock_cred_exneeds to include theerror_msgattribute because the handler code setscred_ex_record.error_msg = err.roll_upwhen a StorageError occurs. Without this attribute in the mock, the test may not properly validate that the error message is being set correctly on the credential exchange record.