def test_update_application_metadata_with_passed_in_sar_client(self): sar_client = Mock() update_application_metadata(self.template, self.application_id, sar_client) # the self initiated boto3 client shouldn't be used self.serverlessrepo_mock.update_application.assert_not_called() sar_client.update_application.assert_called_once()
def test_raise_value_error_for_not_dict_or_string_template(self): with self.assertRaises(ValueError) as context: update_application_metadata(123, self.application_id) message = str(context.exception) expected = 'Input template should be a string or dictionary' self.assertEqual(expected, message) self.serverlessrepo_mock.update_application.assert_not_called()
def test_raise_value_error_for_empty_application_id(self): with self.assertRaises(ValueError) as context: update_application_metadata(self.template, '') message = str(context.exception) expected = 'Require SAM template and application ID to update application metadata' self.assertEqual(expected, message) self.serverlessrepo_mock.update_application.assert_not_called()
def test_update_application_metadata_ignore_irrelevant_fields(self): update_application_metadata(self.template, self.application_id) # SemanticVersion in the template should be ignored expected_request = { 'ApplicationId': self.application_id, 'Author': 'abc', 'Description': 'hello world' } self.serverlessrepo_mock.update_application.assert_called_once_with( **expected_request)
def test_publish_template_dict_should_copy_template(self, copy_mock): copy_mock.return_value = self.template_dict update_application_metadata(self.template_dict, self.application_id) copy_mock.assert_called_with(self.template_dict)
def test_update_application_metadata_with_template_string_should_parse_template( self, parse_template_mock): parse_template_mock.return_value = self.template_dict update_application_metadata(self.template, self.application_id) parse_template_mock.assert_called_with(self.template)