Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add test for error attributes

  • Loading branch information...
commit 8979fe54d411f9c066a3e5f6368da50d0ec93fe0 1 parent cc0f694
@danielgtaylor danielgtaylor authored
Showing with 13 additions and 5 deletions.
  1. +1 −5 boto/exception.py
  2. +12 −0 tests/unit/cloudformation/test_connection.py
View
6 boto/exception.py
@@ -24,14 +24,10 @@
"""
Exception classes - Subclassing allows you to check for specific errors
"""
-try:
- import json
-except ImportError:
- import simplejson as json
-
import base64
import xml.sax
from boto import handler
+from boto.compat import json
from boto.resultset import ResultSet
View
12 tests/unit/cloudformation/test_connection.py
@@ -11,6 +11,7 @@
from tests.unit import AWSMockServiceTestCase
from boto.cloudformation.connection import CloudFormationConnection
+from boto.exception import BotoServerError
SAMPLE_TEMPLATE = r"""
@@ -115,6 +116,17 @@ def test_create_stack_fails(self):
'stack_name', template_body=SAMPLE_TEMPLATE,
parameters=[('KeyName', 'myKeyName')])
+ def test_create_stack_fail_error(self):
+ self.set_http_response(status_code=400, reason='Bad Request',
+ body='{"RequestId": "abc", "Error": {"Code": 1, "Message": "Invalid arg."}}')
+ try:
+ api_response = self.service_connection.create_stack(
+ 'stack_name', template_body=SAMPLE_TEMPLATE,
+ parameters=[('KeyName', 'myKeyName')])
+ except BotoServerError, e:
+ self.assertEqual('abc', e.request_id)
+ self.assertEqual(1, e.error_code)
+ self.assertEqual('Invalid arg.', e.message)
class TestCloudFormationUpdateStack(CloudFormationConnectionBase):
def default_body(self):
Please sign in to comment.
Something went wrong with that request. Please try again.