Add missing CannotUpdate exception

* Add missing exception CannotUpdate
* Add unit tests to verify that exception is called

Closes-Bug: #1508876
Change-Id: I9b69ac2bb683a01d5c55d11c9df2657ef23da2e8
This commit is contained in:
Alexander Saprykin 2015-10-22 13:08:47 +02:00
parent b09d472543
commit 6fe73c5d57
3 changed files with 20 additions and 0 deletions

View File

@ -189,6 +189,8 @@ class BaseHandler(object):
errors.NodeOffline,
errors.NoDeploymentTasks,
errors.UnavailableRelease,
errors.CannotCreate,
errors.CannotUpdate,
errors.CannotDelete
) as exc:
raise cls.http(400, exc.message)

View File

@ -25,6 +25,7 @@ default_messages = {
# REST errors
"CannotDelete": "Can't delete object",
"CannotCreate": "Can't create object",
"CannotUpdate": "Can't update object",
"NotAllowed": "Action is not allowed",
"InvalidField": "Invalid field specified for object",
"ObjectNotFound": "Object not found in DB",

View File

@ -600,6 +600,23 @@ class TestNodeObject(BaseIntegrationTest):
template, group_name)
)
def test_update_w_error(self):
self.env.create(
nodes_kwargs=[
{'roles': ['controller']},
{'roles': ['compute', 'cinder']}
]
)
cluster_2 = self.env.create_cluster()
node_0 = self.env.nodes[0]
data = {
'cluster_id': cluster_2['id']
}
self.assertRaises(
errors.CannotUpdate, objects.Node.update, node_0, data)
class TestTaskObject(BaseIntegrationTest):