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

Make Moto (tests) compatible with flask/werkzeug 2.x #3923

Merged
merged 8 commits into from May 13, 2021

Conversation

bblommers
Copy link
Collaborator

@bblommers bblommers commented May 12, 2021

Fixes #3921

With this PR, moto will werk with both flask/werkzeug 1.x, and flask/werkzeug 2.x.

Issues encountered while trying to fix this

Problem: CodeCov throws an error for some builds:
{'detail': ErrorDetail(string='Unable to locate build via Github Actions API. Please upload with the Codecov repository upload token to resolve issue.', code='not_found')}
Solution:

  • Don't fail if this happens - we'll notice it in the report if anything goes wrong

Problem: test_s3_server_post_without_content_length fails with werkzeug 2.x/flash 1.x
Solution: Described in #3921


Problem: managedblockchain error handling fails in werkzeug 2.x
Underlying cause:
This service would return XML-errors, when boto3 expects them in JSON format. This would cause boto3 to throw an error saying: Unable to validate response: <error>Can't find network x</error>

With werkzeug 2.x, some encoding acts differently, and the error returned suddenly looks like:
Unable to validate response: <error>Can&quot;t find network x</error>

This caused the asserts to fail, as the error message no longer matches up.

Solution:
Rewrite all error scenarios to return JSON-formatted errors, and rewrite the tests to assert this is done correctly

@bblommers bblommers force-pushed the fix-flaskwerkzeug-dependency branch from a263359 to 1a31519 Compare May 12, 2021 12:58
@bblommers bblommers force-pushed the fix-flaskwerkzeug-dependency branch from 4ec2fa9 to b0a5d6c Compare May 13, 2021 08:37
@codecov-commenter
Copy link

Codecov Report

Merging #3923 (b0a5d6c) into master (8bb0feb) will increase coverage by 0.00%.
The diff coverage is 94.87%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3923   +/-   ##
=======================================
  Coverage   94.85%   94.86%           
=======================================
  Files         454      454           
  Lines       49275    49312   +37     
=======================================
+ Hits        46741    46778   +37     
  Misses       2534     2534           
Flag Coverage Δ
servertests 55.83% <69.23%> (+<0.01%) ⬆️
unittests 94.73% <94.87%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
moto/managedblockchain/exceptions.py 95.74% <92.59%> (-4.26%) ⬇️
moto/managedblockchain/responses.py 97.64% <100.00%> (+0.09%) ⬆️
moto/iam/models.py 95.27% <0.00%> (+0.14%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8bb0feb...b0a5d6c. Read the comment docs.

@bblommers bblommers changed the title Dont fail build when CodeCov fails Make Moto (tests) compatible with flask/werkzeug 2.x May 13, 2021
@bblommers bblommers merged commit 9e3faf7 into getmoto:master May 13, 2021
@bblommers bblommers added this to the 2.0.8 milestone May 13, 2021
@github-actions
Copy link
Contributor

This is now part of moto >= 2.0.8.dev3

archlinux-github pushed a commit to archlinux/svntogit-community that referenced this pull request May 15, 2021
Although a upstream dev got test failures with werkzeug/flask 2.0 [1], all tests, including `managedblockchain` ones, are green on my machine.

[1] getmoto/moto#3923

git-svn-id: file:///srv/repos/svn-community/svn@934603 9fca08f4-af9d-4005-b8df-a31f2cc04f65
archlinux-github pushed a commit to archlinux/svntogit-community that referenced this pull request May 15, 2021
Although a upstream dev got test failures with werkzeug/flask 2.0 [1], all tests, including `managedblockchain` ones, are green on my machine.

[1] getmoto/moto#3923


git-svn-id: file:///srv/repos/svn-community/svn@934603 9fca08f4-af9d-4005-b8df-a31f2cc04f65
@bblommers bblommers deleted the fix-flaskwerkzeug-dependency branch January 25, 2022 23:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Werkzeug 2.0.0 breaks tests
2 participants