]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
heat engine : fix exception syntax issue
authorSteven Hardy <shardy@redhat.com>
Wed, 13 Mar 2013 18:03:34 +0000 (18:03 +0000)
committerSteven Hardy <shardy@redhat.com>
Wed, 13 Mar 2013 18:05:31 +0000 (18:05 +0000)
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
heat/tests/test_engine_service.py

index d84ca1750655b7992bebdcd48afe04318becae30..b56cf83aab503b7839609c9bac819ca6f651a114 100644 (file)
@@ -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:
index 81880972455803cfc0d83608113212cb2f0e8ec6..e5ed9679e450a73a7e5be330d6b7fc3692e989e9 100644 (file)
@@ -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,