Add additional tests for heat.api.aws package

Change-Id: I24d8ef4cab7406d5e33bf2b9b798cf9dc402f2d6
Closes-Bug: #1416467
This commit is contained in:
Daniel Gonzalez 2015-01-23 13:41:18 +01:00
parent beb393e56c
commit 2c03a1f098
2 changed files with 48 additions and 1 deletions

View File

@ -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)

View File

@ -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)