-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Support the latest version of botocore #1847
Conversation
This is looking great; thanks for all of your work on this. If we can add joguSD#1 on top of this, I think we are in a good place to merge and hopefully push past all of this. If I get some time in the next couple of days, I'll try to get the final parts of this done. If anyone else gets some time before that, feel free to jump in. |
@spulec Do you think continuing to patch @mock_s3
def main():
requests.get('s3.url') # should be mocked as a feature of |
I think that is a nice feature of Moto (at least that is how we have made it work previously) so I am in favor of that. |
I am -1 on still using |
Yeah, actually I agree to that |
I suppose we could have a flag to allow the user to control if we setup |
Look forward to seeing this work land in a release. May be worth updating the README at the top to warn people in the interim. Also -1 on keeping |
@spulec Any updates on this? I think in the short-term just getting moto working with newer versions of botocore is important, and the decision to add configuration for |
Agreed that we can discuss if I don't have a lot of time right now, but if someone has time to create a PR that works with all of our existing tests, I'll be happy to merge and cut a new release. |
@lhufnagel the code looks good! Can someone else here give the branch in #1907 a test? Due to the nature of this change, would be great to have another person or two test it. |
I was able to run our internal project's test cases with:
👍 |
#1907 passes on one of my Python projects, using cloudformation, ec2, elb, iam, s3, rds, route53, and sqs mocks. |
Closing as these changes were merge with #1907 |
As discussed in #1793 in a recent version of
botocore
, the vendored version ofrequests
was dropped in favor of a direct dependency onurllib3
. This broke theMockAWS
implementation based onresponses
. As ofbotocore
version 1.12.13 the before-send event has been added which allows for the HTTP layer inbotocore
to be bypassed by registering a handler to this event that will introspect the request and return the appropriate mocked response.The event handler implementation is largely the same as the logic used in the
responses
module but boiled down to the functionality required bymoto
. This event handler is registered globally at the import time ofmoto
and allbotocore
clients created whilemoto
is imported will be able to be mocked.Unfortunately, the
before-send
event cannot support all of the functionality that mocking outrequests
could. Specifically, it cannot support mocking the instance metadata credential resolver. This means that credentials need to be provided tobotocore
in some manner now for the mocks to function, which is why I've set the credential environment variables to be present for all tests. Currently the tests that fail are either expecting instance metadata to be mocked out when accessed viarequests
, or are otherwise usingrequests
. However, this PR should support the majority ofmoto
use cases.