def test_strip_app_metadata_when_metadata_only_contains_app_metadata(self): template_dict = { 'Metadata': { 'AWS::ServerlessRepo::Application': {} }, 'Resources': {}, } expected_output = {'Resources': {}} actual_output = parser.strip_app_metadata(template_dict) self.assertEqual(actual_output, expected_output)
def setUp(self): patcher = patch('serverlessrepo.publish.boto3') self.addCleanup(patcher.stop) self.boto3_mock = patcher.start() self.serverlessrepo_mock = Mock() self.boto3_mock.client.return_value = self.serverlessrepo_mock self.template = """ { "Metadata": { "AWS::ServerlessRepo::Application": { "Name": "test-app", "Description": "hello world", "Author": "abc", "LicenseUrl": "s3://test-bucket/LICENSE", "ReadmeUrl": "s3://test-bucket/README.md", "Labels": ["test1", "test2"], "HomePageUrl": "https://github.com/abc/def", "SourceCodeUrl": "https://github.com/abc/def", "SemanticVersion": "1.0.0" } }, "Resources": { "Key1": {}, "Key2": {} } } """ self.template_dict = json.loads(self.template) self.yaml_template_without_metadata = yaml_dump( strip_app_metadata(self.template_dict)) self.application_id = 'arn:aws:serverlessrepo:us-east-1:123456789012:applications/test-app' self.application_exists_error = ClientError( { 'Error': { 'Code': 'ConflictException', 'Message': 'Application with id {} already exists'.format( self.application_id) } }, 'create_application') self.not_conflict_exception = ClientError( { 'Error': { 'Code': 'BadRequestException', 'Message': 'Random message' } }, 'create_application') self.s3_denied_exception = ClientError( { 'Error': { 'Code': 'BadRequestException', 'Message': 'Failed to copy S3 object. Access denied: bucket=test-bucket, key=test-file' } }, 'create_application') self.invalid_s3_uri_exception = ClientError( { 'Error': { 'Code': 'BadRequestException', 'Message': 'Invalid S3 URI' } }, 'create_application')
def test_strip_app_metadata_when_input_does_not_contain_metadata(self): template_dict = {'Resources': {}} actual_output = parser.strip_app_metadata(template_dict) self.assertEqual(actual_output, template_dict)