Merge "Catch correct not found error in senlin plugin"
This commit is contained in:
commit
a95d77889d
@ -37,12 +37,12 @@ class SenlinClientPlugin(client_plugin.ClientPlugin):
|
|||||||
return client.Client(self.VERSION, **args)
|
return client.Client(self.VERSION, **args)
|
||||||
|
|
||||||
def is_not_found(self, ex):
|
def is_not_found(self, ex):
|
||||||
return isinstance(ex, exc.HTTPNotFound)
|
return isinstance(ex, exc.sdkexc.ResourceNotFound)
|
||||||
|
|
||||||
|
|
||||||
class ProfileConstraint(constraints.BaseCustomConstraint):
|
class ProfileConstraint(constraints.BaseCustomConstraint):
|
||||||
|
|
||||||
expected_exceptions = (exc.HTTPNotFound,)
|
expected_exceptions = (exc.sdkexc.ResourceNotFound,)
|
||||||
|
|
||||||
def validate_with_client(self, client, profile):
|
def validate_with_client(self, client, profile):
|
||||||
client.client(CLIENT_NAME).get_profile(profile)
|
client.client(CLIENT_NAME).get_profile(profile)
|
||||||
|
@ -44,5 +44,6 @@ class ProfileConstraintTest(common.HeatTestCase):
|
|||||||
self.assertTrue(self.constraint.validate("PROFILE_ID", self.ctx))
|
self.assertTrue(self.constraint.validate("PROFILE_ID", self.ctx))
|
||||||
|
|
||||||
def test_validate_false(self):
|
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))
|
self.assertFalse(self.constraint.validate("PROFILE_ID", self.ctx))
|
||||||
|
@ -137,7 +137,7 @@ class SenlinClusterTest(common.HeatTestCase):
|
|||||||
def test_cluster_delete_success(self):
|
def test_cluster_delete_success(self):
|
||||||
cluster = self._create_cluster(self.t)
|
cluster = self._create_cluster(self.t)
|
||||||
self.senlin_mock.get_cluster.side_effect = [
|
self.senlin_mock.get_cluster.side_effect = [
|
||||||
exc.HTTPNotFound(),
|
exc.sdkexc.ResourceNotFound('SenlinCluster'),
|
||||||
]
|
]
|
||||||
scheduler.TaskRunner(cluster.delete)()
|
scheduler.TaskRunner(cluster.delete)()
|
||||||
self.senlin_mock.delete_cluster.assert_called_once_with(
|
self.senlin_mock.delete_cluster.assert_called_once_with(
|
||||||
|
Loading…
Reference in New Issue
Block a user