OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 |
| 3 import json |
| 4 |
| 5 from tests.unit import AWSMockServiceTestCase |
| 6 |
| 7 from boto.beanstalk.layer1 import Layer1 |
| 8 |
| 9 # These tests are just checking the basic structure of |
| 10 # the Elastic Beanstalk code, by picking a few calls |
| 11 # and verifying we get the expected results with mocked |
| 12 # responses. The integration tests actually verify the |
| 13 # API calls interact with the service correctly. |
| 14 class TestListAvailableSolutionStacks(AWSMockServiceTestCase): |
| 15 connection_class = Layer1 |
| 16 |
| 17 def default_body(self): |
| 18 return json.dumps( |
| 19 {u'ListAvailableSolutionStacksResponse': |
| 20 {u'ListAvailableSolutionStacksResult': |
| 21 {u'SolutionStackDetails': [ |
| 22 {u'PermittedFileTypes': [u'war', u'zip'], |
| 23 u'SolutionStackName': u'32bit Amazon Linux running Tomcat
7'}, |
| 24 {u'PermittedFileTypes': [u'zip'], |
| 25 u'SolutionStackName': u'32bit Amazon Linux running PHP 5.
3'}], |
| 26 u'SolutionStacks': [u'32bit Amazon Linux running Tomcat 7'
, |
| 27 u'32bit Amazon Linux running PHP 5.3']
}, |
| 28 u'ResponseMetadata': {u'RequestId': u'request_id'}}}) |
| 29 |
| 30 def test_list_available_solution_stacks(self): |
| 31 self.set_http_response(status_code=200) |
| 32 api_response = self.service_connection.list_available_solution_stacks() |
| 33 stack_details = api_response['ListAvailableSolutionStacksResponse']\ |
| 34 ['ListAvailableSolutionStacksResult']\ |
| 35 ['SolutionStackDetails'] |
| 36 solution_stacks = api_response['ListAvailableSolutionStacksResponse']\ |
| 37 ['ListAvailableSolutionStacksResult']\ |
| 38 ['SolutionStacks'] |
| 39 self.assertEqual(solution_stacks, |
| 40 [u'32bit Amazon Linux running Tomcat 7', |
| 41 u'32bit Amazon Linux running PHP 5.3']) |
| 42 # These are the parameters that are actually sent to the CloudFormation |
| 43 # service. |
| 44 self.assert_request_parameters({ |
| 45 'Action': 'ListAvailableSolutionStacks', |
| 46 'ContentType': 'JSON', |
| 47 'SignatureMethod': 'HmacSHA256', |
| 48 'SignatureVersion': 2, |
| 49 'Version': '2010-12-01', |
| 50 'AWSAccessKeyId': 'aws_access_key_id', |
| 51 }, ignore_params_values=['Timestamp']) |
| 52 |
| 53 |
| 54 class TestCreateApplicationVersion(AWSMockServiceTestCase): |
| 55 connection_class = Layer1 |
| 56 |
| 57 def default_body(self): |
| 58 return json.dumps({ |
| 59 'CreateApplicationVersionResponse': |
| 60 {u'CreateApplicationVersionResult': |
| 61 {u'ApplicationVersion': |
| 62 {u'ApplicationName': u'application1', |
| 63 u'DateCreated': 1343067094.342, |
| 64 u'DateUpdated': 1343067094.342, |
| 65 u'Description': None, |
| 66 u'SourceBundle': {u'S3Bucket': u'elasticbeanstalk-us-east-1
', |
| 67 u'S3Key': u'resources/elasticbeanstalk-sampleapp.war'}, |
| 68 u'VersionLabel': u'version1'}}}}) |
| 69 |
| 70 def test_create_application_version(self): |
| 71 self.set_http_response(status_code=200) |
| 72 api_response = self.service_connection.create_application_version( |
| 73 'application1', 'version1', s3_bucket='mybucket', s3_key='mykey', |
| 74 auto_create_application=True) |
| 75 app_version = api_response['CreateApplicationVersionResponse']\ |
| 76 ['CreateApplicationVersionResult']\ |
| 77 ['ApplicationVersion'] |
| 78 self.assert_request_parameters({ |
| 79 'Action': 'CreateApplicationVersion', |
| 80 'ContentType': 'JSON', |
| 81 'SignatureMethod': 'HmacSHA256', |
| 82 'SignatureVersion': 2, |
| 83 'Version': '2010-12-01', |
| 84 'ApplicationName': 'application1', |
| 85 'AutoCreateApplication': 'true', |
| 86 'SourceBundle.S3Bucket': 'mybucket', |
| 87 'SourceBundle.S3Key': 'mykey', |
| 88 'VersionLabel': 'version1', |
| 89 'AWSAccessKeyId': 'aws_access_key_id', |
| 90 }, ignore_params_values=['Timestamp']) |
| 91 self.assertEqual(app_version['ApplicationName'], 'application1') |
| 92 self.assertEqual(app_version['VersionLabel'], 'version1') |
| 93 |
| 94 |
| 95 class TestCreateEnvironment(AWSMockServiceTestCase): |
| 96 connection_class = Layer1 |
| 97 |
| 98 def default_body(self): |
| 99 return json.dumps({}) |
| 100 |
| 101 def test_create_environment(self): |
| 102 self.set_http_response(status_code=200) |
| 103 api_response = self.service_connection.create_environment( |
| 104 'application1', 'environment1', 'version1', |
| 105 '32bit Amazon Linux running Tomcat 7', |
| 106 option_settings=[ |
| 107 ('aws:autoscaling:launchconfiguration', 'Ec2KeyName', |
| 108 'mykeypair'), |
| 109 ('aws:elasticbeanstalk:application:environment', 'ENVVAR', |
| 110 'VALUE1')]) |
| 111 self.assert_request_parameters({ |
| 112 'Action': 'CreateEnvironment', |
| 113 'ApplicationName': 'application1', |
| 114 'EnvironmentName': 'environment1', |
| 115 'TemplateName': '32bit Amazon Linux running Tomcat 7', |
| 116 'ContentType': 'JSON', |
| 117 'SignatureMethod': 'HmacSHA256', |
| 118 'SignatureVersion': 2, |
| 119 'Version': '2010-12-01', |
| 120 'VersionLabel': 'version1', |
| 121 'AWSAccessKeyId': 'aws_access_key_id', |
| 122 'OptionSettings.member.1.Namespace': 'aws:autoscaling:launchconfigur
ation', |
| 123 'OptionSettings.member.1.OptionName': 'Ec2KeyName', |
| 124 'OptionSettings.member.1.Value': 'mykeypair', |
| 125 'OptionSettings.member.2.Namespace': 'aws:elasticbeanstalk:applicati
on:environment', |
| 126 'OptionSettings.member.2.OptionName': 'ENVVAR', |
| 127 'OptionSettings.member.2.Value': 'VALUE1', |
| 128 }, ignore_params_values=['Timestamp']) |
OLD | NEW |