Merge "Catch correct not found error in senlin plugin"

This commit is contained in:
Jenkins 2016-01-27 05:45:30 +00:00 committed by Gerrit Code Review
commit a95d77889d
3 changed files with 5 additions and 4 deletions

View File

@ -37,12 +37,12 @@ class SenlinClientPlugin(client_plugin.ClientPlugin):
return client.Client(self.VERSION, **args)
def is_not_found(self, ex):
return isinstance(ex, exc.HTTPNotFound)
return isinstance(ex, exc.sdkexc.ResourceNotFound)
class ProfileConstraint(constraints.BaseCustomConstraint):
expected_exceptions = (exc.HTTPNotFound,)
expected_exceptions = (exc.sdkexc.ResourceNotFound,)
def validate_with_client(self, client, profile):
client.client(CLIENT_NAME).get_profile(profile)

View File

@ -44,5 +44,6 @@ class ProfileConstraintTest(common.HeatTestCase):
self.assertTrue(self.constraint.validate("PROFILE_ID", self.ctx))
def test_validate_false(self):
self.mock_get_profile.side_effect = exc.HTTPNotFound
self.mock_get_profile.side_effect = exc.sdkexc.ResourceNotFound(
'PROFILE_ID')
self.assertFalse(self.constraint.validate("PROFILE_ID", self.ctx))

View File

@ -137,7 +137,7 @@ class SenlinClusterTest(common.HeatTestCase):
def test_cluster_delete_success(self):
cluster = self._create_cluster(self.t)
self.senlin_mock.get_cluster.side_effect = [
exc.HTTPNotFound(),
exc.sdkexc.ResourceNotFound('SenlinCluster'),
]
scheduler.TaskRunner(cluster.delete)()
self.senlin_mock.delete_cluster.assert_called_once_with(