Open nicolalandro opened 3 years ago
Hi @nicolalandro,
Sorry to hear you're having issues. Because download_file
is not a native s3 operation (it's part of s3Transfer), I'm not sure if there's any way around the operation mismatch because it uses several native S3 operations to calculate the object size, download the file, etc. I'll check with the team to see if there's a way to accomplish this.
Thank you, I will wait the fix, for now I fix with manual mock that raise exception, to have official version will simplify the code and make it more real.
# download do not return error
s3mock_cli.download_file = lambda x, y, z: True
error = mock.Mock()
error.get = lambda x, y: 200 if x == 'Code' else 'text'
response = mock.Mock()
response.get = lambda x, y: error
response.__contains__ = lambda x, y: False
# upload return error
s3mock_cli.upload_file = lambda x, y, z: (_ for _ in ()).throw(ClientError(response, 'name'))
I'm waiting news.
Hi @nicolalandro,
I was able to review this with the team earlier today and it's currently not possible to work around this using the botocore stubber due to the reasons I mentioned before— We will have to write a customization for the S3Transfer methods (upload_file, download_file, etc.), as they are customizations over s3 APIs themselves. This could be documented better as well. Thanks for pointing this out!
Describe the bug Using the stubber, addind a client error it generate a "StubResponseError".
Versions:
Steps to reproduce With this code you can reproduce:
Expected behavior I expect that the code go into the exception handle
Debug logs Full stack trace: