From 834b87a258a162ff8462de98b54a8036bf592d87 Mon Sep 17 00:00:00 2001 From: Steven Hardy Date: Wed, 13 Mar 2013 18:03:34 +0000 Subject: [PATCH] heat engine : fix exception syntax issue Fix exception clause to use a tuple or the two types of exception are not correctly caught. fixes bug 1154708 Change-Id: Ia742c92dc189d03f8034ca864334526f1234dde3 --- heat/engine/service.py | 2 +- heat/tests/test_engine_service.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/heat/engine/service.py b/heat/engine/service.py index d84ca175..b56cf83a 100644 --- a/heat/engine/service.py +++ b/heat/engine/service.py @@ -377,7 +377,7 @@ class EngineService(service.Service): # are deployed as ec2 keypairs try: ec2_creds = json.loads(cnxt.aws_creds).get('ec2Credentials') - except TypeError, AttributeError: + except (TypeError, AttributeError): ec2_creds = None if ec2_creds: diff --git a/heat/tests/test_engine_service.py b/heat/tests/test_engine_service.py index 81880972..e5ed9679 100644 --- a/heat/tests/test_engine_service.py +++ b/heat/tests/test_engine_service.py @@ -15,6 +15,7 @@ import os import unittest +import json import mox from nose.plugins.attrib import attr @@ -644,6 +645,20 @@ class stackServiceTest(unittest.TestCase): self.stack_identity, 'foo')) + def test_stack_authorize_stack_user_attribute_error(self): + self.m.StubOutWithMock(json, 'loads') + json.loads(mox.IgnoreArg()).AndRaise(AttributeError) + self.assertFalse(self.man._authorize_stack_user(self.ctx, + self.stack_identity, + 'foo')) + + def test_stack_authorize_stack_user_type_error(self): + self.m.StubOutWithMock(json, 'loads') + json.loads(mox.IgnoreArg()).AndRaise(TypeError) + self.assertFalse(self.man._authorize_stack_user(self.ctx, + self.stack_identity, + 'foo')) + def test_stack_resources_describe(self): resources = self.man.describe_stack_resources(self.ctx, self.stack_identity, -- 2.45.2