From 2c03a1f0984a99e7e0b90f7ea32ca108748f62a4 Mon Sep 17 00:00:00 2001 From: Daniel Gonzalez Date: Fri, 23 Jan 2015 13:41:18 +0100 Subject: [PATCH] Add additional tests for heat.api.aws package Change-Id: I24d8ef4cab7406d5e33bf2b9b798cf9dc402f2d6 Closes-Bug: #1416467 --- heat/tests/test_api_aws.py | 39 ++++++++++++++++++++++++++++++++- heat/tests/test_api_ec2token.py | 10 +++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/heat/tests/test_api_aws.py b/heat/tests/test_api_aws.py index b0caaa521..98d199f4f 100644 --- a/heat/tests/test_api_aws.py +++ b/heat/tests/test_api_aws.py @@ -11,8 +11,9 @@ # License for the specific language governing permissions and limitations # under the License. - +from heat.api.aws import exception as aws_exception from heat.api.aws import utils as api_utils +from heat.common import exception as common_exception from heat.tests import common @@ -182,3 +183,39 @@ class AWSCommonTest(common.HeatTestCase): expected = {"bar": 123} result = api_utils.reformat_dict_keys(keymap, data) self.assertEqual(expected, result) + + def test_get_param_value(self): + params = {"foo": 123} + self.assertEqual(123, api_utils.get_param_value(params, "foo")) + + def test_get_param_value_missing(self): + params = {"foo": 123} + self.assertRaises( + aws_exception.HeatMissingParameterError, + api_utils.get_param_value, params, "bar") + + def test_map_remote_error(self): + ex = Exception() + expected = aws_exception.HeatInternalFailureError + self.assertIsInstance(aws_exception.map_remote_error(ex), expected) + + def test_map_remote_error_inval_param_error(self): + ex = AttributeError() + expected = aws_exception.HeatInvalidParameterValueError + self.assertIsInstance(aws_exception.map_remote_error(ex), expected) + + def test_map_remote_error_denied_error(self): + ex = common_exception.Forbidden() + expected = aws_exception.HeatAccessDeniedError + self.assertIsInstance(aws_exception.map_remote_error(ex), expected) + + def test_map_remote_error_already_exists_error(self): + ex = common_exception.StackExists(stack_name="teststack") + expected = aws_exception.AlreadyExistsError + self.assertIsInstance(aws_exception.map_remote_error(ex), expected) + + def test_map_remote_error_invalid_action_error(self): + ex = common_exception.ActionInProgress(stack_name="teststack", + action="testing") + expected = aws_exception.HeatActionInProgressError + self.assertIsInstance(aws_exception.map_remote_error(ex), expected) diff --git a/heat/tests/test_api_ec2token.py b/heat/tests/test_api_ec2token.py index aaec80e9c..ee115e79f 100644 --- a/heat/tests/test_api_ec2token.py +++ b/heat/tests/test_api_ec2token.py @@ -519,3 +519,13 @@ class Ec2TokenTest(common.HeatTestCase): self.assertEqual('woot', ec2.__call__(dummy_req)) self.m.VerifyAll() + + def test_filter_factory(self): + ec2_filter = ec2token.EC2Token_filter_factory(global_conf={}) + + self.assertEqual('xyz', ec2_filter('xyz').application) + + def test_filter_factory_none_app(self): + ec2_filter = ec2token.EC2Token_filter_factory(global_conf={}) + + self.assertEqual(None, ec2_filter(None).application)