Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(292)

Unified Diff: third_party/boto/tests/unit/cloudformation/test_connection.py

Issue 698893003: Update checked in version of gsutil to version 4.6 (Closed) Base URL: http://dart.googlecode.com/svn/third_party/gsutil/
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/boto/tests/unit/cloudformation/test_connection.py
===================================================================
--- third_party/boto/tests/unit/cloudformation/test_connection.py (revision 33376)
+++ third_party/boto/tests/unit/cloudformation/test_connection.py (working copy)
@@ -11,6 +11,7 @@
from tests.unit import AWSMockServiceTestCase
from boto.cloudformation.connection import CloudFormationConnection
+from boto.exception import BotoServerError
SAMPLE_TEMPLATE = r"""
@@ -108,12 +109,24 @@
def test_create_stack_fails(self):
self.set_http_response(status_code=400, reason='Bad Request',
- body='Invalid arg.')
- with self.assertRaises(self.service_connection.ResponseError):
+ body='{"Error": {"Code": 1, "Message": "Invalid arg."}}')
+ with self.assertRaisesRegexp(self.service_connection.ResponseError,
+ 'Invalid arg.'):
api_response = self.service_connection.create_stack(
'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):
@@ -569,6 +582,10 @@
<Description>EC2 KeyPair</Description>
</member>
</Parameters>
+ <CapabilitiesReason>Reason</CapabilitiesReason>
+ <Capabilities>
+ <member>CAPABILITY_IAM</member>
+ </Capabilities>
</ValidateTemplateResult>
<ResponseMetadata>
<RequestId>0be7b6e8-e4a0-11e0-a5bd-9f8d5a7dbc91</RequestId>
@@ -593,6 +610,11 @@
self.assertEqual(param2.no_echo, True)
self.assertEqual(param2.parameter_key, 'KeyName')
+ self.assertEqual(template.capabilities_reason, 'Reason')
+
+ self.assertEqual(len(template.capabilities), 1)
+ self.assertEqual(template.capabilities[0].value, 'CAPABILITY_IAM')
+
self.assert_request_parameters({
'Action': 'ValidateTemplate',
'TemplateBody': SAMPLE_TEMPLATE,
@@ -616,5 +638,81 @@
})
+class TestCloudFormationEstimateTemplateCost(CloudFormationConnectionBase):
+ def default_body(self):
+ return """
+ {
+ "EstimateTemplateCostResponse": {
+ "EstimateTemplateCostResult": {
+ "Url": "http://calculator.s3.amazonaws.com/calc5.html?key=cf-2e351785-e821-450c-9d58-625e1e1ebfb6"
+ }
+ }
+ }
+ """
+
+ def test_estimate_template_cost(self):
+ self.set_http_response(status_code=200)
+ api_response = self.service_connection.estimate_template_cost(
+ template_body='{}')
+ self.assertEqual(api_response,
+ 'http://calculator.s3.amazonaws.com/calc5.html?key=cf-2e351785-e821-450c-9d58-625e1e1ebfb6')
+ self.assert_request_parameters({
+ 'Action': 'EstimateTemplateCost',
+ 'ContentType': 'JSON',
+ 'TemplateBody': '{}',
+ 'Version': '2010-05-15',
+ })
+
+
+class TestCloudFormationGetStackPolicy(CloudFormationConnectionBase):
+ def default_body(self):
+ return """
+ {
+ "GetStackPolicyResponse": {
+ "GetStackPolicyResult": {
+ "StackPolicyBody": "{...}"
+ }
+ }
+ }
+ """
+
+ def test_get_stack_policy(self):
+ self.set_http_response(status_code=200)
+ api_response = self.service_connection.get_stack_policy('stack-id')
+ self.assertEqual(api_response, '{...}')
+ self.assert_request_parameters({
+ 'Action': 'GetStackPolicy',
+ 'ContentType': 'JSON',
+ 'StackName': 'stack-id',
+ 'Version': '2010-05-15',
+ })
+
+
+class TestCloudFormationSetStackPolicy(CloudFormationConnectionBase):
+ def default_body(self):
+ return """
+ {
+ "SetStackPolicyResponse": {
+ "SetStackPolicyResult": {
+ "Some": "content"
+ }
+ }
+ }
+ """
+
+ def test_set_stack_policy(self):
+ self.set_http_response(status_code=200)
+ api_response = self.service_connection.set_stack_policy('stack-id',
+ stack_policy_body='{}')
+ self.assertEqual(api_response['Some'], 'content')
+ self.assert_request_parameters({
+ 'Action': 'SetStackPolicy',
+ 'ContentType': 'JSON',
+ 'StackName': 'stack-id',
+ 'StackPolicyBody': '{}',
+ 'Version': '2010-05-15',
+ })
+
+
if __name__ == '__main__':
unittest.main()
« no previous file with comments | « third_party/boto/tests/unit/beanstalk/test_layer1.py ('k') | third_party/boto/tests/unit/cloudformation/test_stack.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698