Skip to content
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

Force-remove mocks after tests to fix batcher invocation during deploy #31

Merged
merged 2 commits into from
Aug 8, 2017

Conversation

austinbyers
Copy link
Collaborator

@austinbyers austinbyers commented Aug 8, 2017

After #28 introduced moto to the unit test framework, the batcher invocation during python3 manage.py deploy breaks with an error like the following:

requests.exceptions.ConnectionError: Connection refused: POST https://lambda.REGION.amazonaws.com/2015-03-31/functions/FUNCTION_NAME

Due to getmoto/moto#1026, moto mocks are not always restored correctly. This means that after the unit tests run, part of boto3 was still mocked out.

As a simple workaround, I've added a decorator which manually restores the underlying HTTPAdapter after running the unit test suite.

Other Minor Changes

  • Fixes a link in README
  • Fixes Dynamo metric alarm to reference generic ThrottledRequests instead of ReadThrottleEvents specifically

Tested

CI and deployed to an empty test account. Batcher invocation was successful during the test deploy.

Reviewers

to: @ryandeivert
cc: @airbnb/binaryalert-maintainers

@austinbyers austinbyers requested a review from ryandeivert August 8, 2017 02:48
@@ -58,6 +59,7 @@ def deploy():
analyze_all()


@boto3_mocks.restore_http_adapter
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume you have, but did you try importing all of the the moto mocks as decorators, like:

from moto import mock_cloudwatch, mock_s3, mock_lambda, mock_sqs

and wrapping the whole MainTest class with them, like:

@mock_s3
@mock_sqs
@mock_lambda
@mock_cloudwatch
class MainTest(unittest.TestCase):
    ....

instead of instantiating them within the test case setup?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this quick and it doesn't seem to work either :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I tried decorating individual tests, class-level, and explicit mock/unmock :(

Copy link
Contributor

@ryandeivert ryandeivert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@austinbyers austinbyers merged commit 3362fdc into master Aug 8, 2017
@austinbyers austinbyers deleted the abb--fix-unmocking branch August 8, 2017 18:35
@austinbyers austinbyers modified the milestone: 1.0.0 Aug 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants