class UnitTest_CloudGemFramework_ProjectResourceHandler_Custom_ServiceApi_SwaggerConfiguration( unittest.TestCase): INPUT_SWAGGER_CONTENT = 'Test Swagger $TestSetting1$ $TestSetting1$ $TestSetting2$ $ResourceGroupName$ $DeploymentName$ $RoleArn$ $Region$ $RestApiResourceName$' SWAGGER_SETTINGS = {'TestSetting1': 'A', 'TestSetting2': 'B'} OUTPUT_SWAGGER_CONTENT = 'Test Swagger A A B {} {} {} {} {}'.format( MockResourceGroupInfo.MOCK_RESOURCE_GROUP_NAME, MockDeploymentInfo.MOCK_DEPLOYMENT_NAME, ROLE_ARN, MockResourceGroupInfo.MOCK_REGION, REST_API_RESOURCE_NAME) RESOURCE_PROPERTIES = { 'ConfigurationBucket': CONFIGURATION_BUCKET, 'ConfigurationKey': CONFIGURATION_KEY, 'SwaggerSettings': SWAGGER_SETTINGS } PROPS = properties._Properties(RESOURCE_PROPERTIES, Custom_ServiceApi.PROPERTY_SCHEMA) @mock.patch.object(Custom_ServiceApi, 's3') def test_get_input_swagger_content(self, *args): # Setup Custom_ServiceApi.s3.get_object.return_value = mock_aws.s3_get_object_response( self.INPUT_SWAGGER_CONTENT) # Execute result = Custom_ServiceApi.get_input_swagger_content(self.PROPS) # Verify Custom_ServiceApi.s3.get_object.assert_called_once_with( Bucket=CONFIGURATION_BUCKET, Key=INPUT_SWAGGER_KEY) self.assertEquals(self.INPUT_SWAGGER_CONTENT, result) def test_configure_swagger_content(self, *args): # Execute result = Custom_ServiceApi.configure_swagger_content( RESOURCE_GROUP_INFO, self.PROPS, ROLE_ARN, REST_API_RESOURCE_NAME, self.INPUT_SWAGGER_CONTENT) # Verify self.assertEquals(self.OUTPUT_SWAGGER_CONTENT, result)
} } }, 'CacheClusterEnabled': True, 'CacheClusterSize': '0.5', 'StageVariables': { 'StageVariables': '' } } MINIMAL_RESOURCE_PROPERTIES = { 'ConfigurationBucket': CONFIGURATION_BUCKET, 'ConfigurationKey': CONFIGURATION_KEY } FULL_PROPS = properties._Properties(FULL_RESOURCE_PROPERTIES, Custom_ServiceApi.PROPERTY_SCHEMA) MINIMAL_PROPS = properties._Properties(MINIMAL_RESOURCE_PROPERTIES, Custom_ServiceApi.PROPERTY_SCHEMA) PROPS_MATCHER = PropertiesMatcher() class UnitTest_CloudGemFramework_ProjectResourceHandler_Custom_ServiceApi_RequestTypes( unittest.TestCase): @mock.patch.object(custom_resource_response, 'success_response') @mock.patch.object(role_utils, 'create_access_control_role', return_value=ROLE_ARN) @mock.patch.object(stack_info.StackInfoManager, 'get_stack_info', return_value=RESOURCE_GROUP_INFO)