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:
parent
8bb0feb956
commit
9e3faf7784
11 changed files with 599 additions and 317 deletions
|
|
@ -3,7 +3,9 @@ from __future__ import unicode_literals
|
|||
import os
|
||||
|
||||
import boto3
|
||||
import pytest
|
||||
import sure # noqa
|
||||
from botocore.exceptions import ClientError
|
||||
from freezegun import freeze_time
|
||||
from unittest import SkipTest
|
||||
|
||||
|
|
@ -321,14 +323,17 @@ def test_vote_on_proposal_expiredproposal():
|
|||
|
||||
with freeze_time("2015-02-01 12:00:00"):
|
||||
# Vote yes - should set status to expired
|
||||
response = conn.vote_on_proposal.when.called_with(
|
||||
NetworkId=network_id,
|
||||
ProposalId=proposal_id,
|
||||
VoterMemberId=member_id,
|
||||
Vote="YES",
|
||||
).should.throw(
|
||||
Exception,
|
||||
"Proposal {0} is expired and you cannot vote on it.".format(proposal_id),
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.vote_on_proposal(
|
||||
NetworkId=network_id,
|
||||
ProposalId=proposal_id,
|
||||
VoterMemberId=member_id,
|
||||
Vote="YES",
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("InvalidRequestException")
|
||||
err["Message"].should.contain(
|
||||
"Proposal {0} is expired and you cannot vote on it.".format(proposal_id)
|
||||
)
|
||||
|
||||
# Get proposal details - should be EXPIRED
|
||||
|
|
@ -438,12 +443,16 @@ def test_vote_on_proposal_status_check():
|
|||
pendinginvs.should.have.length_of(1)
|
||||
|
||||
# Vote with member 3 - should throw an exception and not create a new invitation
|
||||
response = conn.vote_on_proposal.when.called_with(
|
||||
NetworkId=network_id,
|
||||
ProposalId=proposal_id,
|
||||
VoterMemberId=memberidlist[2],
|
||||
Vote="YES",
|
||||
).should.throw(Exception, "and you cannot vote on it")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.vote_on_proposal(
|
||||
NetworkId=network_id,
|
||||
ProposalId=proposal_id,
|
||||
VoterMemberId=memberidlist[2],
|
||||
Vote="YES",
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("InvalidRequestException")
|
||||
err["Message"].should.contain("and you cannot vote on it")
|
||||
|
||||
# Should still be one pending invitation
|
||||
response = conn.list_invitations()
|
||||
|
|
@ -457,12 +466,16 @@ def test_vote_on_proposal_status_check():
|
|||
def test_vote_on_proposal_badnetwork():
|
||||
conn = boto3.client("managedblockchain", region_name="us-east-1")
|
||||
|
||||
response = conn.vote_on_proposal.when.called_with(
|
||||
NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
|
||||
ProposalId="p-ABCDEFGHIJKLMNOP0123456789",
|
||||
VoterMemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
Vote="YES",
|
||||
).should.throw(Exception, "Network n-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.vote_on_proposal(
|
||||
NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
|
||||
ProposalId="p-ABCDEFGHIJKLMNOP0123456789",
|
||||
VoterMemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
Vote="YES",
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.contain("Network n-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
|
|
@ -480,12 +493,16 @@ def test_vote_on_proposal_badproposal():
|
|||
)
|
||||
network_id = response["NetworkId"]
|
||||
|
||||
response = conn.vote_on_proposal.when.called_with(
|
||||
NetworkId=network_id,
|
||||
ProposalId="p-ABCDEFGHIJKLMNOP0123456789",
|
||||
VoterMemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
Vote="YES",
|
||||
).should.throw(Exception, "Proposal p-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.vote_on_proposal(
|
||||
NetworkId=network_id,
|
||||
ProposalId="p-ABCDEFGHIJKLMNOP0123456789",
|
||||
VoterMemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
Vote="YES",
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.contain("Proposal p-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
|
|
@ -512,12 +529,16 @@ def test_vote_on_proposal_badmember():
|
|||
|
||||
proposal_id = response["ProposalId"]
|
||||
|
||||
response = conn.vote_on_proposal.when.called_with(
|
||||
NetworkId=network_id,
|
||||
ProposalId=proposal_id,
|
||||
VoterMemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
Vote="YES",
|
||||
).should.throw(Exception, "Member m-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.vote_on_proposal(
|
||||
NetworkId=network_id,
|
||||
ProposalId=proposal_id,
|
||||
VoterMemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
Vote="YES",
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.contain("Member m-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
|
|
@ -544,12 +565,16 @@ def test_vote_on_proposal_badvote():
|
|||
|
||||
proposal_id = response["ProposalId"]
|
||||
|
||||
response = conn.vote_on_proposal.when.called_with(
|
||||
NetworkId=network_id,
|
||||
ProposalId=proposal_id,
|
||||
VoterMemberId=member_id,
|
||||
Vote="FOO",
|
||||
).should.throw(Exception, "Invalid request body")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.vote_on_proposal(
|
||||
NetworkId=network_id,
|
||||
ProposalId=proposal_id,
|
||||
VoterMemberId=member_id,
|
||||
Vote="FOO",
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("BadRequestException")
|
||||
err["Message"].should.contain("Invalid request body")
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
|
|
@ -628,14 +653,17 @@ def test_vote_on_proposal_alreadyvoted():
|
|||
)
|
||||
|
||||
# Vote yes with member 1 again
|
||||
response = conn.vote_on_proposal.when.called_with(
|
||||
NetworkId=network_id,
|
||||
ProposalId=proposal_id,
|
||||
VoterMemberId=member_id,
|
||||
Vote="YES",
|
||||
).should.throw(
|
||||
Exception,
|
||||
"Member {0} has already voted on proposal {1}.".format(member_id, proposal_id),
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.vote_on_proposal(
|
||||
NetworkId=network_id,
|
||||
ProposalId=proposal_id,
|
||||
VoterMemberId=member_id,
|
||||
Vote="YES",
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceAlreadyExistsException")
|
||||
err["Message"].should.contain(
|
||||
"Member {0} has already voted on proposal {1}.".format(member_id, proposal_id)
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -643,10 +671,14 @@ def test_vote_on_proposal_alreadyvoted():
|
|||
def test_list_proposal_votes_badnetwork():
|
||||
conn = boto3.client("managedblockchain", region_name="us-east-1")
|
||||
|
||||
response = conn.list_proposal_votes.when.called_with(
|
||||
NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
|
||||
ProposalId="p-ABCDEFGHIJKLMNOP0123456789",
|
||||
).should.throw(Exception, "Network n-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.list_proposal_votes(
|
||||
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
|
||||
|
|
@ -665,6 +697,10 @@ def test_list_proposal_votes_badproposal():
|
|||
network_id = response["NetworkId"]
|
||||
member_id = response["MemberId"]
|
||||
|
||||
response = conn.list_proposal_votes.when.called_with(
|
||||
NetworkId=network_id, ProposalId="p-ABCDEFGHIJKLMNOP0123456789",
|
||||
).should.throw(Exception, "Proposal p-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.list_proposal_votes(
|
||||
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")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue