I am using botocore.stub.Stubber to mock the kmsclient. The code I am using is
with botocore.stub.Stubber(s3) as stubber:
with botocore.stub.Stubber(kms) as stubber2:
stubber.add_response('copy_object', response, expectedParams)
stubber.activate()
stubber2.add_response('decrypt', response2, expectedParams2)
stubber2.activate()
handleCore(__makeValidEvent(), None, s3, kms)
stubber.assert_no_pending_responses()
stubber2.assert_no_pending_responses()
With the actual implementation the kmsclient call is happening twice which results in the following exception
params = {'CiphertextBlob': b"\x01\x02\x02\x00x#\xc1\xdbp6\xe1Y\x0fS\x15\x80<\x86\xb5\xb2\x86\x9f\xaf\xa2Z\x07\xfef\x8d\xb2\xd7...\t'\xe2\xb9\x10w0\x83\xcb\xe1\xcb`\xd1\xc2\x8c\xe4\x82Q/*\xb3]\xcfZ\xb9\xbd\x1c\x9c\x96(e\x94j\x1a\x91\xba\xaeO[>\x97"}
def _assert_expected_call_order(self, model, params):
if not self._queue:
raise UnStubbedResponseError(
operation_name=model.name,
reason=(
> 'Unexpected API Call: A call was made but no additional calls expected.'
'Either the API Call was not stubbed or it was called multiple times.'
)
)
E botocore.exceptions.UnStubbedResponseError: Error getting response stub for operation Decrypt: Unexpected API Call: A call was made but no additional calls expected.Either the API Call was not stubbed or it was called multiple times.
Can someone let me know how can could be used for multiple calls on the same object(kmsclient in this case)