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

* Dont fail if CodeCov fails - for now

* CI - Force cache rebuild

* Bump werkzeug to latest version

* CI - Enforce cache flush

* ManagedBlockchain - fix error format

* ManagedBlockchain - Fix tests to use pytest.raises paradigm

* Revert "Lock Flask (#3925)"

This reverts commit 8bb0feb956.

* CI - Enforce cache rebuild
This commit is contained in:
Bert Blommers 2021-05-13 10:36:56 +01:00 committed by GitHub
commit 9e3faf7784
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 599 additions and 317 deletions

View file

@ -1,8 +1,10 @@
from __future__ import unicode_literals
import boto3
import pytest
import sure # noqa
from botocore.exceptions import ClientError
from moto import mock_managedblockchain
from . import helpers
@ -82,11 +84,15 @@ def test_create_proposal_withopts():
def test_create_proposal_badnetwork():
conn = boto3.client("managedblockchain", region_name="us-east-1")
response = conn.create_proposal.when.called_with(
NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
MemberId="m-ABCDEFGHIJKLMNOP0123456789",
Actions=helpers.default_policy_actions,
).should.throw(Exception, "Network n-ABCDEFGHIJKLMNOP0123456789 not found")
with pytest.raises(ClientError) as ex:
conn.create_proposal(
NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
MemberId="m-ABCDEFGHIJKLMNOP0123456789",
Actions=helpers.default_policy_actions,
)
err = ex.value.response["Error"]
err["Code"].should.equal("ResourceNotFoundException")
err["Message"].should.contain("Network n-ABCDEFGHIJKLMNOP0123456789 not found")
@mock_managedblockchain
@ -104,11 +110,15 @@ def test_create_proposal_badmember():
)
network_id = response["NetworkId"]
response = conn.create_proposal.when.called_with(
NetworkId=network_id,
MemberId="m-ABCDEFGHIJKLMNOP0123456789",
Actions=helpers.default_policy_actions,
).should.throw(Exception, "Member m-ABCDEFGHIJKLMNOP0123456789 not found")
with pytest.raises(ClientError) as ex:
conn.create_proposal(
NetworkId=network_id,
MemberId="m-ABCDEFGHIJKLMNOP0123456789",
Actions=helpers.default_policy_actions,
)
err = ex.value.response["Error"]
err["Code"].should.equal("ResourceNotFoundException")
err["Message"].should.contain("Member m-ABCDEFGHIJKLMNOP0123456789 not found")
@mock_managedblockchain
@ -130,9 +140,15 @@ def test_create_proposal_badinvitationacctid():
network_id = response["NetworkId"]
member_id = response["MemberId"]
response = conn.create_proposal.when.called_with(
NetworkId=network_id, MemberId=member_id, Actions=actions,
).should.throw(Exception, "Account ID format specified in proposal is not valid")
with pytest.raises(ClientError) as ex:
conn.create_proposal(
NetworkId=network_id, MemberId=member_id, Actions=actions,
)
err = ex.value.response["Error"]
err["Code"].should.equal("InvalidRequestException")
err["Message"].should.contain(
"Account ID format specified in proposal is not valid"
)
@mock_managedblockchain
@ -154,28 +170,38 @@ def test_create_proposal_badremovalmemid():
network_id = response["NetworkId"]
member_id = response["MemberId"]
response = conn.create_proposal.when.called_with(
NetworkId=network_id, MemberId=member_id, Actions=actions,
).should.throw(Exception, "Member ID format specified in proposal is not valid")
with pytest.raises(ClientError) as ex:
conn.create_proposal(
NetworkId=network_id, MemberId=member_id, Actions=actions,
)
err = ex.value.response["Error"]
err["Code"].should.equal("InvalidRequestException")
err["Message"].should.contain("Member ID format specified in proposal is not valid")
@mock_managedblockchain
def test_list_proposal_badnetwork():
conn = boto3.client("managedblockchain", region_name="us-east-1")
response = conn.list_proposals.when.called_with(
NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
).should.throw(Exception, "Network n-ABCDEFGHIJKLMNOP0123456789 not found")
with pytest.raises(ClientError) as ex:
conn.list_proposals(NetworkId="n-ABCDEFGHIJKLMNOP0123456789",)
err = ex.value.response["Error"]
err["Code"].should.equal("ResourceNotFoundException")
err["Message"].should.contain("Network n-ABCDEFGHIJKLMNOP0123456789 not found")
@mock_managedblockchain
def test_get_proposal_badnetwork():
conn = boto3.client("managedblockchain", region_name="us-east-1")
response = conn.get_proposal.when.called_with(
NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
ProposalId="p-ABCDEFGHIJKLMNOP0123456789",
).should.throw(Exception, "Network n-ABCDEFGHIJKLMNOP0123456789 not found")
with pytest.raises(ClientError) as ex:
conn.get_proposal(
NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
ProposalId="p-ABCDEFGHIJKLMNOP0123456789",
)
err = ex.value.response["Error"]
err["Code"].should.equal("ResourceNotFoundException")
err["Message"].should.contain("Network n-ABCDEFGHIJKLMNOP0123456789 not found")
@mock_managedblockchain
@ -193,6 +219,10 @@ def test_get_proposal_badproposal():
)
network_id = response["NetworkId"]
response = conn.get_proposal.when.called_with(
NetworkId=network_id, ProposalId="p-ABCDEFGHIJKLMNOP0123456789",
).should.throw(Exception, "Proposal p-ABCDEFGHIJKLMNOP0123456789 not found")
with pytest.raises(ClientError) as ex:
conn.get_proposal(
NetworkId=network_id, ProposalId="p-ABCDEFGHIJKLMNOP0123456789",
)
err = ex.value.response["Error"]
err["Code"].should.equal("ResourceNotFoundException")
err["Message"].should.contain("Proposal p-ABCDEFGHIJKLMNOP0123456789 not found")