diff --git a/heat/engine/clients/os/openstacksdk.py b/heat/engine/clients/os/openstacksdk.py index a1ad0e2031..56c17b45bf 100644 --- a/heat/engine/clients/os/openstacksdk.py +++ b/heat/engine/clients/os/openstacksdk.py @@ -67,7 +67,7 @@ class OpenStackSDKPlugin(client_plugin.ClientPlugin): return interfaces def is_not_found(self, ex): - return isinstance(ex, exceptions.ResourceNotFound) + return isinstance(ex, exceptions.NotFoundException) def find_network_segment(self, value): return self.client().network.find_segment(value).id diff --git a/heat/tests/clients/test_sdk_client.py b/heat/tests/clients/test_sdk_client.py index 45935b13ca..98f40af07e 100644 --- a/heat/tests/clients/test_sdk_client.py +++ b/heat/tests/clients/test_sdk_client.py @@ -21,14 +21,23 @@ from heat.tests import utils class OpenStackSDKPluginTest(common.HeatTestCase): - @mock.patch('openstack.connection.Connection') - def test_create(self, mock_connection): + def setUp(self, mock_connection): + super(OpenStackSDKPluginTest, self).setUp() context = utils.dummy_context() - plugin = context.clients.client_plugin('openstack') - client = plugin.client() + self.plugin = context.clients.client_plugin('openstack') + + def test_create(self): + client = self.plugin.client() self.assertIsNotNone(client.network.segments) + def test_is_not_found(self): + self.assertFalse(self.plugin.is_not_found( + exceptions.HttpException(http_status=400))) + self.assertFalse(self.plugin.is_not_found(Exception)) + self.assertTrue(self.plugin.is_not_found( + exceptions.NotFoundException(http_status=404))) + class SegmentConstraintTest(common.HeatTestCase):