Repository: getmoto/moto

Issue:
Werkzeug 2.0.0 breaks tests
The S3 server test `test_s3_server_post_without_content_length` no longer works with werkzeug 2.0.0, as the calls return a 200 instead of a 411.

I'm submitting a PR to downgrade werkzeug for now, back to the known working version 1.0.1, until we have a solution.
 



Discussion:
Werkzeug was downgraded as part of https://github.com/spulec/moto/pull/3920

Resolving patch:
diff --git a/moto/managedblockchain/exceptions.py b/moto/managedblockchain/exceptions.py
--- a/moto/managedblockchain/exceptions.py
+++ b/moto/managedblockchain/exceptions.py
@@ -1,10 +1,55 @@
 from __future__ import unicode_literals
-from moto.core.exceptions import RESTError
+from functools import wraps
+from werkzeug.exceptions import HTTPException
+from jinja2 import DictLoader, Environment
 
 
-class ManagedBlockchainClientError(RESTError):
+ERROR_JSON_RESPONSE = """{
+    "message": "{{message}}"
+}
+"""
+
+
+def exception_handler(f):
+    @wraps(f)
+    def _wrapper(*args, **kwargs):
+        try:
+            return f(*args, **kwargs)
+        except ManagedBlockchainClientError as err:
+            return err.code, err.get_headers(), err.description
+
+    return _wrapper
+
+
+class ManagedBlockchainClientError(HTTPException):
     code = 400
 
+    templates = {
+        "error": ERROR_JSON_RESPONSE,
+    }
+
+    def __init__(self, error_type, message, **kwargs):
+        super(HTTPException, self).__init__()
+        env = Environment(loader=DictLoader(self.templates))
+        self.error_type = error_type
+        self.message = message
+        self.description = env.get_template("error").render(
+            error_type=error_type, message=message, **kwargs
+        )
+
+    def get_headers(self, *args, **kwargs):
+        return [
+            ("Content-Type", "application/json"),
+            ("x-amzn-ErrorType", self.error_type),
+        ]
+
+    @property
+    def response(self):
+        return self.get_body()
+
+    def get_body(self, *args, **kwargs):
+        return self.description
+
 
 class BadRequestException(ManagedBlockchainClientError):
     def __init__(self, pretty_called_method, operation_error):
diff --git a/moto/managedblockchain/responses.py b/moto/managedblockchain/responses.py
--- a/moto/managedblockchain/responses.py
+++ b/moto/managedblockchain/responses.py
@@ -4,6 +4,7 @@
 from six.moves.urllib.parse import urlparse, parse_qs
 
 from moto.core.responses import BaseResponse
+from .exceptions import exception_handler
 from .models import managedblockchain_backends
 from .utils import (
     region_from_managedblckchain_url,
@@ -21,6 +22,7 @@ def __init__(self, backend):
         self.backend = backend
 
     @classmethod
+    @exception_handler
     def network_response(clazz, request, full_url, headers):
         region_name = region_from_managedblckchain_url(full_url)
         response_instance = ManagedBlockchainResponse(
@@ -73,6 +75,7 @@ def _network_response_post(self, json_body, querystring, headers):
         return 200, headers, json.dumps(response)
 
     @classmethod
+    @exception_handler
     def networkid_response(clazz, request, full_url, headers):
         region_name = region_from_managedblckchain_url(full_url)
         response_instance = ManagedBlockchainResponse(
@@ -94,6 +97,7 @@ def _networkid_response_get(self, network_id, headers):
         return 200, headers, response
 
     @classmethod
+    @exception_handler
     def proposal_response(clazz, request, full_url, headers):
         region_name = region_from_managedblckchain_url(full_url)
         response_instance = ManagedBlockchainResponse(
@@ -139,6 +143,7 @@ def _proposal_response_post(self, network_id, json_body, querystring, headers):
         return 200, headers, json.dumps(response)
 
     @classmethod
+    @exception_handler
     def proposalid_response(clazz, request, full_url, headers):
         region_name = region_from_managedblckchain_url(full_url)
         response_instance = ManagedBlockchainResponse(
@@ -160,6 +165,7 @@ def _proposalid_response_get(self, network_id, proposal_id, headers):
         return 200, headers, response
 
     @classmethod
+    @exception_handler
     def proposal_votes_response(clazz, request, full_url, headers):
         region_name = region_from_managedblckchain_url(full_url)
         response_instance = ManagedBlockchainResponse(
@@ -203,6 +209,7 @@ def _proposal_votes_response_post(
         return 200, headers, ""
 
     @classmethod
+    @exception_handler
     def invitation_response(clazz, request, full_url, headers):
         region_name = region_from_managedblckchain_url(full_url)
         response_instance = ManagedBlockchainResponse(
@@ -224,6 +231,7 @@ def _all_invitation_response(self, request, full_url, headers):
         return 200, headers, response
 
     @classmethod
+    @exception_handler
     def invitationid_response(clazz, request, full_url, headers):
         region_name = region_from_managedblckchain_url(full_url)
         response_instance = ManagedBlockchainResponse(
@@ -243,6 +251,7 @@ def _invitationid_response_delete(self, invitation_id, headers):
         return 200, headers, ""
 
     @classmethod
+    @exception_handler
     def member_response(clazz, request, full_url, headers):
         region_name = region_from_managedblckchain_url(full_url)
         response_instance = ManagedBlockchainResponse(
@@ -283,6 +292,7 @@ def _member_response_post(self, network_id, json_body, querystring, headers):
         return 200, headers, json.dumps(response)
 
     @classmethod
+    @exception_handler
     def memberid_response(clazz, request, full_url, headers):
         region_name = region_from_managedblckchain_url(full_url)
         response_instance = ManagedBlockchainResponse(
@@ -327,6 +337,7 @@ def _memberid_response_delete(self, network_id, member_id, headers):
         return 200, headers, ""
 
     @classmethod
+    @exception_handler
     def node_response(clazz, request, full_url, headers):
         region_name = region_from_managedblckchain_url(full_url)
         response_instance = ManagedBlockchainResponse(
@@ -380,6 +391,7 @@ def _node_response_post(
         return 200, headers, json.dumps(response)
 
     @classmethod
+    @exception_handler
     def nodeid_response(clazz, request, full_url, headers):
         region_name = region_from_managedblckchain_url(full_url)
         response_instance = ManagedBlockchainResponse(
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -36,8 +36,7 @@ def get_version():
     "requests>=2.5",
     "xmltodict",
     "six>1.9",
-    # TODO: werkzeug 2.x currently breaks test_s3_server_post_without_content_length
-    "werkzeug<2.0.0",
+    "werkzeug",
     "pytz",
     "python-dateutil<3.0.0,>=2.1",
     "responses>=0.9.0",
@@ -99,7 +98,7 @@ def get_version():
     _dep_sshpubkeys_py2,
     _dep_sshpubkeys_py3,
 ]
-all_server_deps = all_extra_deps + ["flask<2.0.0", "flask-cors"]
+all_server_deps = all_extra_deps + ["flask", "flask-cors"]
 
 # TODO: do we want to add ALL services here?
 # i.e. even those without extra dependencies.


Test patch:
diff --git a/tests/test_managedblockchain/test_managedblockchain_invitations.py b/tests/test_managedblockchain/test_managedblockchain_invitations.py
--- a/tests/test_managedblockchain/test_managedblockchain_invitations.py
+++ b/tests/test_managedblockchain/test_managedblockchain_invitations.py
@@ -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
 
@@ -136,6 +138,10 @@ def test_reject_invitation_badinvitation():
         Vote="YES",
     )
 
-    response = conn.reject_invitation.when.called_with(
-        InvitationId="in-ABCDEFGHIJKLMNOP0123456789",
-    ).should.throw(Exception, "InvitationId in-ABCDEFGHIJKLMNOP0123456789 not found.")
+    with pytest.raises(ClientError) as ex:
+        conn.reject_invitation(InvitationId="in-ABCDEFGHIJKLMNOP0123456789")
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("ResourceNotFoundException")
+    err["Message"].should.contain(
+        "InvitationId in-ABCDEFGHIJKLMNOP0123456789 not found."
+    )
diff --git a/tests/test_managedblockchain/test_managedblockchain_members.py b/tests/test_managedblockchain/test_managedblockchain_members.py
--- a/tests/test_managedblockchain/test_managedblockchain_members.py
+++ b/tests/test_managedblockchain/test_managedblockchain_members.py
@@ -1,8 +1,10 @@
 from __future__ import unicode_literals
 
 import boto3
+import pytest
 import sure  # noqa
 
+from botocore.exceptions import ClientError, ParamValidationError
 from moto import mock_managedblockchain
 from . import helpers
 
@@ -165,13 +167,17 @@ def test_create_another_member_withopts():
     response["Member"]["Description"].should.equal("Test Member 2")
 
     # Try to create member with already used invitation
-    response = conn.create_member.when.called_with(
-        InvitationId=invitation_id,
-        NetworkId=network_id,
-        MemberConfiguration=helpers.create_member_configuration(
-            "testmember2", "admin", "Admin12345", False, "Test Member 2 Duplicate"
-        ),
-    ).should.throw(Exception, "Invitation {0} not valid".format(invitation_id))
+    with pytest.raises(ClientError) as ex:
+        conn.create_member(
+            InvitationId=invitation_id,
+            NetworkId=network_id,
+            MemberConfiguration=helpers.create_member_configuration(
+                "testmember2", "admin", "Admin12345", False, "Test Member 2 Duplicate"
+            ),
+        )
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("InvalidRequestException")
+    err["Message"].should.contain("Invitation {0} not valid".format(invitation_id))
 
     # Delete member 2
     conn.delete_member(NetworkId=network_id, MemberId=member_id2)
@@ -182,9 +188,11 @@ def test_create_another_member_withopts():
     members.should.have.length_of(2)
 
     # But cannot get
-    response = conn.get_member.when.called_with(
-        NetworkId=network_id, MemberId=member_id2,
-    ).should.throw(Exception, "Member {0} not found".format(member_id2))
+    with pytest.raises(ClientError) as ex:
+        conn.get_member(NetworkId=network_id, MemberId=member_id2)
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("ResourceNotFoundException")
+    err["Message"].should.contain("Member {0} not found".format(member_id2))
 
     # Delete member 1
     conn.delete_member(NetworkId=network_id, MemberId=member_id)
@@ -362,13 +370,17 @@ def test_create_too_many_members():
     )[0]
 
     # Try to create one too many members
-    response = conn.create_member.when.called_with(
-        InvitationId=invitation_id,
-        NetworkId=network_id,
-        MemberConfiguration=helpers.create_member_configuration(
-            "testmember6", "admin", "Admin12345", False, "Test Member 6"
-        ),
-    ).should.throw(Exception, "is the maximum number of members allowed in a",)
+    with pytest.raises(ClientError) as ex:
+        conn.create_member(
+            InvitationId=invitation_id,
+            NetworkId=network_id,
+            MemberConfiguration=helpers.create_member_configuration(
+                "testmember6", "admin", "Admin12345", False, "Test Member 6"
+            ),
+        )
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("ResourceLimitExceededException")
+    err["Message"].should.contain("is the maximum number of members allowed in a")
 
 
 @mock_managedblockchain
@@ -409,17 +421,20 @@ def test_create_another_member_alreadyhave():
     invitation_id = response["Invitations"][0]["InvitationId"]
 
     # Should fail trying to create with same name
-    response = conn.create_member.when.called_with(
-        NetworkId=network_id,
-        InvitationId=invitation_id,
-        MemberConfiguration=helpers.create_member_configuration(
-            "testmember1", "admin", "Admin12345", False
-        ),
-    ).should.throw(
-        Exception,
+    with pytest.raises(ClientError) as ex:
+        conn.create_member(
+            NetworkId=network_id,
+            InvitationId=invitation_id,
+            MemberConfiguration=helpers.create_member_configuration(
+                "testmember1", "admin", "Admin12345", False
+            ),
+        )
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("InvalidRequestException")
+    err["Message"].should.contain(
         "Member name {0} already exists in network {1}".format(
             "testmember1", network_id
-        ),
+        )
     )
 
 
@@ -427,13 +442,17 @@ def test_create_another_member_alreadyhave():
 def test_create_another_member_badnetwork():
     conn = boto3.client("managedblockchain", region_name="us-east-1")
 
-    response = conn.create_member.when.called_with(
-        NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
-        InvitationId="id-ABCDEFGHIJKLMNOP0123456789",
-        MemberConfiguration=helpers.create_member_configuration(
-            "testmember2", "admin", "Admin12345", False
-        ),
-    ).should.throw(Exception, "Network n-ABCDEFGHIJKLMNOP0123456789 not found")
+    with pytest.raises(ClientError) as ex:
+        conn.create_member(
+            NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
+            InvitationId="id-ABCDEFGHIJKLMNOP0123456789",
+            MemberConfiguration=helpers.create_member_configuration(
+                "testmember2", "admin", "Admin12345", False
+            ),
+        )
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("ResourceNotFoundException")
+    err["Message"].should.contain("Network n-ABCDEFGHIJKLMNOP0123456789 not found")
 
 
 @mock_managedblockchain
@@ -451,13 +470,17 @@ def test_create_another_member_badinvitation():
     )
     network_id = response["NetworkId"]
 
-    response = conn.create_member.when.called_with(
-        NetworkId=network_id,
-        InvitationId="in-ABCDEFGHIJKLMNOP0123456789",
-        MemberConfiguration=helpers.create_member_configuration(
-            "testmember2", "admin", "Admin12345", False
-        ),
-    ).should.throw(Exception, "Invitation in-ABCDEFGHIJKLMNOP0123456789 not valid")
+    with pytest.raises(ClientError) as ex:
+        conn.create_member(
+            NetworkId=network_id,
+            InvitationId="in-ABCDEFGHIJKLMNOP0123456789",
+            MemberConfiguration=helpers.create_member_configuration(
+                "testmember2", "admin", "Admin12345", False
+            ),
+        )
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("InvalidRequestException")
+    err["Message"].should.contain("Invitation in-ABCDEFGHIJKLMNOP0123456789 not valid")
 
 
 @mock_managedblockchain
@@ -509,73 +532,97 @@ def test_create_another_member_adminpassword():
     badadminpassmemberconf["FrameworkConfiguration"]["Fabric"][
         "AdminPassword"
     ] = "badap"
-    response = conn.create_member.when.called_with(
-        NetworkId=network_id,
-        InvitationId=invitation_id,
-        MemberConfiguration=badadminpassmemberconf,
-    ).should.throw(
-        Exception,
-        "Invalid length for parameter MemberConfiguration.FrameworkConfiguration.Fabric.AdminPassword",
+    with pytest.raises(ParamValidationError) as ex:
+        conn.create_member(
+            NetworkId=network_id,
+            InvitationId=invitation_id,
+            MemberConfiguration=badadminpassmemberconf,
+        )
+    err = ex.value
+    str(err).should.contain(
+        "Invalid length for parameter MemberConfiguration.FrameworkConfiguration.Fabric.AdminPassword"
     )
 
     # No uppercase or numbers
     badadminpassmemberconf["FrameworkConfiguration"]["Fabric"][
         "AdminPassword"
     ] = "badadminpwd"
-    response = conn.create_member.when.called_with(
-        NetworkId=network_id,
-        InvitationId=invitation_id,
-        MemberConfiguration=badadminpassmemberconf,
-    ).should.throw(Exception, "Invalid request body")
+    with pytest.raises(ClientError) as ex:
+        conn.create_member(
+            NetworkId=network_id,
+            InvitationId=invitation_id,
+            MemberConfiguration=badadminpassmemberconf,
+        )
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("BadRequestException")
+    err["Message"].should.contain("Invalid request body")
 
     # No lowercase or numbers
     badadminpassmemberconf["FrameworkConfiguration"]["Fabric"][
         "AdminPassword"
     ] = "BADADMINPWD"
-    response = conn.create_member.when.called_with(
-        NetworkId=network_id,
-        InvitationId=invitation_id,
-        MemberConfiguration=badadminpassmemberconf,
-    ).should.throw(Exception, "Invalid request body")
+    with pytest.raises(ClientError) as ex:
+        conn.create_member(
+            NetworkId=network_id,
+            InvitationId=invitation_id,
+            MemberConfiguration=badadminpassmemberconf,
+        )
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("BadRequestException")
+    err["Message"].should.contain("Invalid request body")
 
     # No numbers
     badadminpassmemberconf["FrameworkConfiguration"]["Fabric"][
         "AdminPassword"
     ] = "badAdminpwd"
-    response = conn.create_member.when.called_with(
-        NetworkId=network_id,
-        InvitationId=invitation_id,
-        MemberConfiguration=badadminpassmemberconf,
-    ).should.throw(Exception, "Invalid request body")
+    with pytest.raises(ClientError) as ex:
+        conn.create_member(
+            NetworkId=network_id,
+            InvitationId=invitation_id,
+            MemberConfiguration=badadminpassmemberconf,
+        )
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("BadRequestException")
+    err["Message"].should.contain("Invalid request body")
 
     # Invalid character
     badadminpassmemberconf["FrameworkConfiguration"]["Fabric"][
         "AdminPassword"
     ] = "badAdmin@pwd1"
-    response = conn.create_member.when.called_with(
-        NetworkId=network_id,
-        InvitationId=invitation_id,
-        MemberConfiguration=badadminpassmemberconf,
-    ).should.throw(Exception, "Invalid request body")
+    with pytest.raises(ClientError) as ex:
+        conn.create_member(
+            NetworkId=network_id,
+            InvitationId=invitation_id,
+            MemberConfiguration=badadminpassmemberconf,
+        )
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("BadRequestException")
+    err["Message"].should.contain("Invalid request body")
 
 
 @mock_managedblockchain
 def test_list_members_badnetwork():
     conn = boto3.client("managedblockchain", region_name="us-east-1")
 
-    response = conn.list_members.when.called_with(
-        NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
-    ).should.throw(Exception, "Network n-ABCDEFGHIJKLMNOP0123456789 not found")
+    with pytest.raises(ClientError) as ex:
+        conn.list_members(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_member_badnetwork():
     conn = boto3.client("managedblockchain", region_name="us-east-1")
 
-    response = conn.get_member.when.called_with(
-        NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
-        MemberId="m-ABCDEFGHIJKLMNOP0123456789",
-    ).should.throw(Exception, "Network n-ABCDEFGHIJKLMNOP0123456789 not found")
+    with pytest.raises(ClientError) as ex:
+        conn.get_member(
+            NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
+            MemberId="m-ABCDEFGHIJKLMNOP0123456789",
+        )
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("ResourceNotFoundException")
+    err["Message"].should.contain("Network n-ABCDEFGHIJKLMNOP0123456789 not found")
 
 
 @mock_managedblockchain
@@ -593,19 +640,25 @@ def test_get_member_badmember():
     )
     network_id = response["NetworkId"]
 
-    response = conn.get_member.when.called_with(
-        NetworkId=network_id, MemberId="m-ABCDEFGHIJKLMNOP0123456789",
-    ).should.throw(Exception, "Member m-ABCDEFGHIJKLMNOP0123456789 not found")
+    with pytest.raises(ClientError) as ex:
+        conn.get_member(NetworkId=network_id, MemberId="m-ABCDEFGHIJKLMNOP0123456789")
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("ResourceNotFoundException")
+    err["Message"].should.contain("Member m-ABCDEFGHIJKLMNOP0123456789 not found")
 
 
 @mock_managedblockchain
 def test_delete_member_badnetwork():
     conn = boto3.client("managedblockchain", region_name="us-east-1")
 
-    response = conn.delete_member.when.called_with(
-        NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
-        MemberId="m-ABCDEFGHIJKLMNOP0123456789",
-    ).should.throw(Exception, "Network n-ABCDEFGHIJKLMNOP0123456789 not found")
+    with pytest.raises(ClientError) as ex:
+        conn.delete_member(
+            NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
+            MemberId="m-ABCDEFGHIJKLMNOP0123456789",
+        )
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("ResourceNotFoundException")
+    err["Message"].should.contain("Network n-ABCDEFGHIJKLMNOP0123456789 not found")
 
 
 @mock_managedblockchain
@@ -623,22 +676,30 @@ def test_delete_member_badmember():
     )
     network_id = response["NetworkId"]
 
-    response = conn.delete_member.when.called_with(
-        NetworkId=network_id, MemberId="m-ABCDEFGHIJKLMNOP0123456789",
-    ).should.throw(Exception, "Member m-ABCDEFGHIJKLMNOP0123456789 not found")
+    with pytest.raises(ClientError) as ex:
+        conn.delete_member(
+            NetworkId=network_id, MemberId="m-ABCDEFGHIJKLMNOP0123456789"
+        )
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("ResourceNotFoundException")
+    err["Message"].should.contain("Member m-ABCDEFGHIJKLMNOP0123456789 not found")
 
 
 @mock_managedblockchain
 def test_update_member_badnetwork():
     conn = boto3.client("managedblockchain", region_name="us-east-1")
 
-    response = conn.update_member.when.called_with(
-        NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
-        MemberId="m-ABCDEFGHIJKLMNOP0123456789",
-        LogPublishingConfiguration=helpers.default_memberconfiguration[
-            "LogPublishingConfiguration"
-        ],
-    ).should.throw(Exception, "Network n-ABCDEFGHIJKLMNOP0123456789 not found")
+    with pytest.raises(ClientError) as ex:
+        conn.update_member(
+            NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
+            MemberId="m-ABCDEFGHIJKLMNOP0123456789",
+            LogPublishingConfiguration=helpers.default_memberconfiguration[
+                "LogPublishingConfiguration"
+            ],
+        )
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("ResourceNotFoundException")
+    err["Message"].should.contain("Network n-ABCDEFGHIJKLMNOP0123456789 not found")
 
 
 @mock_managedblockchain
@@ -656,10 +717,14 @@ def test_update_member_badmember():
     )
     network_id = response["NetworkId"]
 
-    response = conn.update_member.when.called_with(
-        NetworkId=network_id,
-        MemberId="m-ABCDEFGHIJKLMNOP0123456789",
-        LogPublishingConfiguration=helpers.default_memberconfiguration[
-            "LogPublishingConfiguration"
-        ],
-    ).should.throw(Exception, "Member m-ABCDEFGHIJKLMNOP0123456789 not found")
+    with pytest.raises(ClientError) as ex:
+        conn.update_member(
+            NetworkId=network_id,
+            MemberId="m-ABCDEFGHIJKLMNOP0123456789",
+            LogPublishingConfiguration=helpers.default_memberconfiguration[
+                "LogPublishingConfiguration"
+            ],
+        )
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("ResourceNotFoundException")
+    err["Message"].should.contain("Member m-ABCDEFGHIJKLMNOP0123456789 not found")
diff --git a/tests/test_managedblockchain/test_managedblockchain_networks.py b/tests/test_managedblockchain/test_managedblockchain_networks.py
--- a/tests/test_managedblockchain/test_managedblockchain_networks.py
+++ b/tests/test_managedblockchain/test_managedblockchain_networks.py
@@ -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
 
@@ -68,31 +70,39 @@ def test_create_network_withopts():
 def test_create_network_noframework():
     conn = boto3.client("managedblockchain", region_name="us-east-1")
 
-    response = conn.create_network.when.called_with(
-        Name="testnetwork1",
-        Description="Test Network 1",
-        Framework="HYPERLEDGER_VINYL",
-        FrameworkVersion="1.2",
-        FrameworkConfiguration=helpers.default_frameworkconfiguration,
-        VotingPolicy=helpers.default_votingpolicy,
-        MemberConfiguration=helpers.default_memberconfiguration,
-    ).should.throw(Exception, "Invalid request body")
+    with pytest.raises(ClientError) as ex:
+        conn.create_network(
+            Name="testnetwork1",
+            Description="Test Network 1",
+            Framework="HYPERLEDGER_VINYL",
+            FrameworkVersion="1.2",
+            FrameworkConfiguration=helpers.default_frameworkconfiguration,
+            VotingPolicy=helpers.default_votingpolicy,
+            MemberConfiguration=helpers.default_memberconfiguration,
+        )
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("BadRequestException")
+    err["Message"].should.contain("Invalid request body")
 
 
 @mock_managedblockchain
 def test_create_network_badframeworkver():
     conn = boto3.client("managedblockchain", region_name="us-east-1")
 
-    response = conn.create_network.when.called_with(
-        Name="testnetwork1",
-        Description="Test Network 1",
-        Framework="HYPERLEDGER_FABRIC",
-        FrameworkVersion="1.X",
-        FrameworkConfiguration=helpers.default_frameworkconfiguration,
-        VotingPolicy=helpers.default_votingpolicy,
-        MemberConfiguration=helpers.default_memberconfiguration,
-    ).should.throw(
-        Exception, "Invalid version 1.X requested for framework HYPERLEDGER_FABRIC"
+    with pytest.raises(ClientError) as ex:
+        conn.create_network(
+            Name="testnetwork1",
+            Description="Test Network 1",
+            Framework="HYPERLEDGER_FABRIC",
+            FrameworkVersion="1.X",
+            FrameworkConfiguration=helpers.default_frameworkconfiguration,
+            VotingPolicy=helpers.default_votingpolicy,
+            MemberConfiguration=helpers.default_memberconfiguration,
+        )
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("BadRequestException")
+    err["Message"].should.contain(
+        "Invalid version 1.X requested for framework HYPERLEDGER_FABRIC"
     )
 
 
@@ -102,21 +112,27 @@ def test_create_network_badedition():
 
     frameworkconfiguration = {"Fabric": {"Edition": "SUPER"}}
 
-    response = conn.create_network.when.called_with(
-        Name="testnetwork1",
-        Description="Test Network 1",
-        Framework="HYPERLEDGER_FABRIC",
-        FrameworkVersion="1.2",
-        FrameworkConfiguration=frameworkconfiguration,
-        VotingPolicy=helpers.default_votingpolicy,
-        MemberConfiguration=helpers.default_memberconfiguration,
-    ).should.throw(Exception, "Invalid request body")
+    with pytest.raises(ClientError) as ex:
+        conn.create_network(
+            Name="testnetwork1",
+            Description="Test Network 1",
+            Framework="HYPERLEDGER_FABRIC",
+            FrameworkVersion="1.2",
+            FrameworkConfiguration=frameworkconfiguration,
+            VotingPolicy=helpers.default_votingpolicy,
+            MemberConfiguration=helpers.default_memberconfiguration,
+        )
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("BadRequestException")
+    err["Message"].should.contain("Invalid request body")
 
 
 @mock_managedblockchain
 def test_get_network_badnetwork():
     conn = boto3.client("managedblockchain", region_name="us-east-1")
 
-    response = conn.get_network.when.called_with(
-        NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
-    ).should.throw(Exception, "Network n-ABCDEFGHIJKLMNOP0123456789 not found")
+    with pytest.raises(ClientError) as ex:
+        conn.get_network(NetworkId="n-ABCDEFGHIJKLMNOP0123456789")
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("ResourceNotFoundException")
+    err["Message"].should.contain("Network n-ABCDEFGHIJKLMNOP0123456789 not found")
diff --git a/tests/test_managedblockchain/test_managedblockchain_nodes.py b/tests/test_managedblockchain/test_managedblockchain_nodes.py
--- a/tests/test_managedblockchain/test_managedblockchain_nodes.py
+++ b/tests/test_managedblockchain/test_managedblockchain_nodes.py
@@ -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
 
@@ -76,9 +78,11 @@ def test_create_node():
     helpers.node_id_exist_in_list(nodes, node_id).should.equal(True)
 
     # But cannot get
-    response = conn.get_node.when.called_with(
-        NetworkId=network_id, MemberId=member_id, NodeId=node_id,
-    ).should.throw(Exception, "Node {0} not found".format(node_id))
+    with pytest.raises(ClientError) as ex:
+        conn.get_node(NetworkId=network_id, MemberId=member_id, NodeId=node_id)
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("ResourceNotFoundException")
+    err["Message"].should.contain("Node {0} not found".format(node_id))
 
 
 @mock_managedblockchain
@@ -145,9 +149,11 @@ def test_create_node_standard_edition():
     conn.delete_member(NetworkId=network_id, MemberId=member_id)
 
     # Should now be an exception
-    response = conn.list_nodes.when.called_with(
-        NetworkId=network_id, MemberId=member_id,
-    ).should.throw(Exception, "Member {0} not found".format(member_id))
+    with pytest.raises(ClientError) as ex:
+        conn.list_nodes(NetworkId=network_id, MemberId=member_id)
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("ResourceNotFoundException")
+    err["Message"].should.contain("Member {0} not found".format(member_id))
 
 
 @mock_managedblockchain
@@ -187,12 +193,16 @@ def test_create_too_many_nodes():
     nodes.should.have.length_of(2)
 
     # Try to create one too many nodes
-    response = conn.create_node.when.called_with(
-        NetworkId=network_id,
-        MemberId=member_id,
-        NodeConfiguration=helpers.default_nodeconfiguration,
-    ).should.throw(
-        Exception, "Maximum number of nodes exceeded in member {0}".format(member_id),
+    with pytest.raises(ClientError) as ex:
+        conn.create_node(
+            NetworkId=network_id,
+            MemberId=member_id,
+            NodeConfiguration=helpers.default_nodeconfiguration,
+        )
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("ResourceLimitExceededException")
+    err["Message"].should.contain(
+        "Maximum number of nodes exceeded in member {0}".format(member_id)
     )
 
 
@@ -200,11 +210,15 @@ def test_create_too_many_nodes():
 def test_create_node_badnetwork():
     conn = boto3.client("managedblockchain", region_name="us-east-1")
 
-    response = conn.create_node.when.called_with(
-        NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
-        MemberId="m-ABCDEFGHIJKLMNOP0123456789",
-        NodeConfiguration=helpers.default_nodeconfiguration,
-    ).should.throw(Exception, "Network n-ABCDEFGHIJKLMNOP0123456789 not found")
+    with pytest.raises(ClientError) as ex:
+        conn.create_node(
+            NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
+            MemberId="m-ABCDEFGHIJKLMNOP0123456789",
+            NodeConfiguration=helpers.default_nodeconfiguration,
+        )
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("ResourceNotFoundException")
+    err["Message"].should.contain("Network n-ABCDEFGHIJKLMNOP0123456789 not found")
 
 
 @mock_managedblockchain
@@ -222,11 +236,15 @@ def test_create_node_badmember():
     )
     network_id = response["NetworkId"]
 
-    response = conn.create_node.when.called_with(
-        NetworkId=network_id,
-        MemberId="m-ABCDEFGHIJKLMNOP0123456789",
-        NodeConfiguration=helpers.default_nodeconfiguration,
-    ).should.throw(Exception, "Member m-ABCDEFGHIJKLMNOP0123456789 not found")
+    with pytest.raises(ClientError) as ex:
+        conn.create_node(
+            NetworkId=network_id,
+            MemberId="m-ABCDEFGHIJKLMNOP0123456789",
+            NodeConfiguration=helpers.default_nodeconfiguration,
+        )
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("ResourceNotFoundException")
+    err["Message"].should.contain("Member m-ABCDEFGHIJKLMNOP0123456789 not found")
 
 
 @mock_managedblockchain
@@ -248,36 +266,51 @@ def test_create_node_badnodeconfig():
     # Incorrect instance type
     logconfigbad = dict(helpers.default_nodeconfiguration)
     logconfigbad["InstanceType"] = "foo"
-    response = conn.create_node.when.called_with(
-        NetworkId=network_id, MemberId=member_id, NodeConfiguration=logconfigbad,
-    ).should.throw(Exception, "Requested instance foo isn't supported.")
+    with pytest.raises(ClientError) as ex:
+        conn.create_node(
+            NetworkId=network_id, MemberId=member_id, NodeConfiguration=logconfigbad
+        )
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("InvalidRequestException")
+    err["Message"].should.contain("Requested instance foo isn't supported.")
 
     # Incorrect instance type for edition
     logconfigbad = dict(helpers.default_nodeconfiguration)
     logconfigbad["InstanceType"] = "bc.t3.large"
-    response = conn.create_node.when.called_with(
-        NetworkId=network_id, MemberId=member_id, NodeConfiguration=logconfigbad,
-    ).should.throw(
-        Exception,
-        "Instance type bc.t3.large is not supported with STARTER Edition networks",
+    with pytest.raises(ClientError) as ex:
+        conn.create_node(
+            NetworkId=network_id, MemberId=member_id, NodeConfiguration=logconfigbad
+        )
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("InvalidRequestException")
+    err["Message"].should.contain(
+        "Instance type bc.t3.large is not supported with STARTER Edition networks."
     )
 
     # Incorrect availability zone
     logconfigbad = dict(helpers.default_nodeconfiguration)
     logconfigbad["AvailabilityZone"] = "us-east-11"
-    response = conn.create_node.when.called_with(
-        NetworkId=network_id, MemberId=member_id, NodeConfiguration=logconfigbad,
-    ).should.throw(Exception, "Availability Zone is not valid")
+    with pytest.raises(ClientError) as ex:
+        conn.create_node(
+            NetworkId=network_id, MemberId=member_id, NodeConfiguration=logconfigbad
+        )
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("InvalidRequestException")
+    err["Message"].should.contain("Availability Zone is not valid")
 
 
 @mock_managedblockchain
 def test_list_nodes_badnetwork():
     conn = boto3.client("managedblockchain", region_name="us-east-1")
 
-    response = conn.list_nodes.when.called_with(
-        NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
-        MemberId="m-ABCDEFGHIJKLMNOP0123456789",
-    ).should.throw(Exception, "Network n-ABCDEFGHIJKLMNOP0123456789 not found")
+    with pytest.raises(ClientError) as ex:
+        conn.list_nodes(
+            NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
+            MemberId="m-ABCDEFGHIJKLMNOP0123456789",
+        )
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("ResourceNotFoundException")
+    err["Message"].should.contain("Network n-ABCDEFGHIJKLMNOP0123456789 not found")
 
 
 @mock_managedblockchain
@@ -295,20 +328,28 @@ def test_list_nodes_badmember():
     )
     network_id = response["NetworkId"]
 
-    response = conn.list_nodes.when.called_with(
-        NetworkId=network_id, MemberId="m-ABCDEFGHIJKLMNOP0123456789",
-    ).should.throw(Exception, "Member m-ABCDEFGHIJKLMNOP0123456789 not found")
+    with pytest.raises(ClientError) as ex:
+        conn.list_nodes(
+            NetworkId=network_id, MemberId="m-ABCDEFGHIJKLMNOP0123456789",
+        )
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("ResourceNotFoundException")
+    err["Message"].should.contain("Member m-ABCDEFGHIJKLMNOP0123456789 not found")
 
 
 @mock_managedblockchain
 def test_get_node_badnetwork():
     conn = boto3.client("managedblockchain", region_name="us-east-1")
 
-    response = conn.get_node.when.called_with(
-        NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
-        MemberId="m-ABCDEFGHIJKLMNOP0123456789",
-        NodeId="nd-ABCDEFGHIJKLMNOP0123456789",
-    ).should.throw(Exception, "Network n-ABCDEFGHIJKLMNOP0123456789 not found")
+    with pytest.raises(ClientError) as ex:
+        conn.get_node(
+            NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
+            MemberId="m-ABCDEFGHIJKLMNOP0123456789",
+            NodeId="nd-ABCDEFGHIJKLMNOP0123456789",
+        )
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("ResourceNotFoundException")
+    err["Message"].should.contain("Network n-ABCDEFGHIJKLMNOP0123456789 not found")
 
 
 @mock_managedblockchain
@@ -326,11 +367,15 @@ def test_get_node_badmember():
     )
     network_id = response["NetworkId"]
 
-    response = conn.get_node.when.called_with(
-        NetworkId=network_id,
-        MemberId="m-ABCDEFGHIJKLMNOP0123456789",
-        NodeId="nd-ABCDEFGHIJKLMNOP0123456789",
-    ).should.throw(Exception, "Member m-ABCDEFGHIJKLMNOP0123456789 not found")
+    with pytest.raises(ClientError) as ex:
+        conn.get_node(
+            NetworkId=network_id,
+            MemberId="m-ABCDEFGHIJKLMNOP0123456789",
+            NodeId="nd-ABCDEFGHIJKLMNOP0123456789",
+        )
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("ResourceNotFoundException")
+    err["Message"].should.contain("Member m-ABCDEFGHIJKLMNOP0123456789 not found")
 
 
 @mock_managedblockchain
@@ -349,22 +394,30 @@ def test_get_node_badnode():
     network_id = response["NetworkId"]
     member_id = response["MemberId"]
 
-    response = conn.get_node.when.called_with(
-        NetworkId=network_id,
-        MemberId=member_id,
-        NodeId="nd-ABCDEFGHIJKLMNOP0123456789",
-    ).should.throw(Exception, "Node nd-ABCDEFGHIJKLMNOP0123456789 not found")
+    with pytest.raises(ClientError) as ex:
+        conn.get_node(
+            NetworkId=network_id,
+            MemberId=member_id,
+            NodeId="nd-ABCDEFGHIJKLMNOP0123456789",
+        )
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("ResourceNotFoundException")
+    err["Message"].should.contain("Node nd-ABCDEFGHIJKLMNOP0123456789 not found")
 
 
 @mock_managedblockchain
 def test_delete_node_badnetwork():
     conn = boto3.client("managedblockchain", region_name="us-east-1")
 
-    response = conn.delete_node.when.called_with(
-        NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
-        MemberId="m-ABCDEFGHIJKLMNOP0123456789",
-        NodeId="nd-ABCDEFGHIJKLMNOP0123456789",
-    ).should.throw(Exception, "Network n-ABCDEFGHIJKLMNOP0123456789 not found")
+    with pytest.raises(ClientError) as ex:
+        conn.delete_node(
+            NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
+            MemberId="m-ABCDEFGHIJKLMNOP0123456789",
+            NodeId="nd-ABCDEFGHIJKLMNOP0123456789",
+        )
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("ResourceNotFoundException")
+    err["Message"].should.contain("Network n-ABCDEFGHIJKLMNOP0123456789 not found")
 
 
 @mock_managedblockchain
@@ -382,11 +435,15 @@ def test_delete_node_badmember():
     )
     network_id = response["NetworkId"]
 
-    response = conn.delete_node.when.called_with(
-        NetworkId=network_id,
-        MemberId="m-ABCDEFGHIJKLMNOP0123456789",
-        NodeId="nd-ABCDEFGHIJKLMNOP0123456789",
-    ).should.throw(Exception, "Member m-ABCDEFGHIJKLMNOP0123456789 not found")
+    with pytest.raises(ClientError) as ex:
+        conn.delete_node(
+            NetworkId=network_id,
+            MemberId="m-ABCDEFGHIJKLMNOP0123456789",
+            NodeId="nd-ABCDEFGHIJKLMNOP0123456789",
+        )
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("ResourceNotFoundException")
+    err["Message"].should.contain("Member m-ABCDEFGHIJKLMNOP0123456789 not found")
 
 
 @mock_managedblockchain
@@ -405,25 +462,33 @@ def test_delete_node_badnode():
     network_id = response["NetworkId"]
     member_id = response["MemberId"]
 
-    response = conn.delete_node.when.called_with(
-        NetworkId=network_id,
-        MemberId=member_id,
-        NodeId="nd-ABCDEFGHIJKLMNOP0123456789",
-    ).should.throw(Exception, "Node nd-ABCDEFGHIJKLMNOP0123456789 not found")
+    with pytest.raises(ClientError) as ex:
+        conn.delete_node(
+            NetworkId=network_id,
+            MemberId=member_id,
+            NodeId="nd-ABCDEFGHIJKLMNOP0123456789",
+        )
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("ResourceNotFoundException")
+    err["Message"].should.contain("Node nd-ABCDEFGHIJKLMNOP0123456789 not found")
 
 
 @mock_managedblockchain
 def test_update_node_badnetwork():
     conn = boto3.client("managedblockchain", region_name="us-east-1")
 
-    response = conn.update_node.when.called_with(
-        NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
-        MemberId="m-ABCDEFGHIJKLMNOP0123456789",
-        NodeId="nd-ABCDEFGHIJKLMNOP0123456789",
-        LogPublishingConfiguration=helpers.default_nodeconfiguration[
-            "LogPublishingConfiguration"
-        ],
-    ).should.throw(Exception, "Network n-ABCDEFGHIJKLMNOP0123456789 not found")
+    with pytest.raises(ClientError) as ex:
+        conn.update_node(
+            NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
+            MemberId="m-ABCDEFGHIJKLMNOP0123456789",
+            NodeId="nd-ABCDEFGHIJKLMNOP0123456789",
+            LogPublishingConfiguration=helpers.default_nodeconfiguration[
+                "LogPublishingConfiguration"
+            ],
+        )
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("ResourceNotFoundException")
+    err["Message"].should.contain("Network n-ABCDEFGHIJKLMNOP0123456789 not found")
 
 
 @mock_managedblockchain
@@ -441,14 +506,18 @@ def test_update_node_badmember():
     )
     network_id = response["NetworkId"]
 
-    response = conn.update_node.when.called_with(
-        NetworkId=network_id,
-        MemberId="m-ABCDEFGHIJKLMNOP0123456789",
-        NodeId="nd-ABCDEFGHIJKLMNOP0123456789",
-        LogPublishingConfiguration=helpers.default_nodeconfiguration[
-            "LogPublishingConfiguration"
-        ],
-    ).should.throw(Exception, "Member m-ABCDEFGHIJKLMNOP0123456789 not found")
+    with pytest.raises(ClientError) as ex:
+        conn.update_node(
+            NetworkId=network_id,
+            MemberId="m-ABCDEFGHIJKLMNOP0123456789",
+            NodeId="nd-ABCDEFGHIJKLMNOP0123456789",
+            LogPublishingConfiguration=helpers.default_nodeconfiguration[
+                "LogPublishingConfiguration"
+            ],
+        )
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("ResourceNotFoundException")
+    err["Message"].should.contain("Member m-ABCDEFGHIJKLMNOP0123456789 not found")
 
 
 @mock_managedblockchain
@@ -467,11 +536,15 @@ def test_update_node_badnode():
     network_id = response["NetworkId"]
     member_id = response["MemberId"]
 
-    response = conn.update_node.when.called_with(
-        NetworkId=network_id,
-        MemberId=member_id,
-        NodeId="nd-ABCDEFGHIJKLMNOP0123456789",
-        LogPublishingConfiguration=helpers.default_nodeconfiguration[
-            "LogPublishingConfiguration"
-        ],
-    ).should.throw(Exception, "Node nd-ABCDEFGHIJKLMNOP0123456789 not found")
+    with pytest.raises(ClientError) as ex:
+        conn.update_node(
+            NetworkId=network_id,
+            MemberId=member_id,
+            NodeId="nd-ABCDEFGHIJKLMNOP0123456789",
+            LogPublishingConfiguration=helpers.default_nodeconfiguration[
+                "LogPublishingConfiguration"
+            ],
+        )
+    err = ex.value.response["Error"]
+    err["Code"].should.equal("ResourceNotFoundException")
+    err["Message"].should.contain("Node nd-ABCDEFGHIJKLMNOP0123456789 not found")
diff --git a/tests/test_managedblockchain/test_managedblockchain_proposals.py b/tests/test_managedblockchain/test_managedblockchain_proposals.py
--- a/tests/test_managedblockchain/test_managedblockchain_proposals.py
+++ b/tests/test_managedblockchain/test_managedblockchain_proposals.py
@@ -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")
diff --git a/tests/test_managedblockchain/test_managedblockchain_proposalvotes.py b/tests/test_managedblockchain/test_managedblockchain_proposalvotes.py
--- a/tests/test_managedblockchain/test_managedblockchain_proposalvotes.py
+++ b/tests/test_managedblockchain/test_managedblockchain_proposalvotes.py
@@ -3,7 +3,9 @@
 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")