summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorSirisha Devineni <sirisha_devineni@persistent.co.in>2012-09-13 23:44:08 +0530
committerSirisha Devineni <sirisha_devineni@persistent.co.in>2012-09-20 15:28:18 +0530
commita7a0705699662ec3a604126eec868c673cd5328e (patch)
tree999edaf31f5a72298c2dc7e5ac6538c7833ffb0e /nova/tests
parent64a45f03c180a485f72be54a1b42f23b7a752699 (diff)
Raise NotFound for non-existent volume snapshot create
When user tries to create snapshot of a non-existent volume then handle the VolumeNotFound exception raised during snapshot creation and throw it as HTTPNotFound Fixes bug 1050388 Change-Id: I869ed6a29f66889636bcf92115117d407079e539
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/api/openstack/fakes.py2
-rw-r--r--nova/tests/api/openstack/volume/test_snapshots.py14
2 files changed, 15 insertions, 1 deletions
diff --git a/nova/tests/api/openstack/fakes.py b/nova/tests/api/openstack/fakes.py
index dc9ccc5f3..fb7a7183c 100644
--- a/nova/tests/api/openstack/fakes.py
+++ b/nova/tests/api/openstack/fakes.py
@@ -567,7 +567,7 @@ def stub_volume_get(self, context, volume_id):
def stub_volume_get_notfound(self, context, volume_id):
- raise exc.NotFound
+ raise exc.VolumeNotFound(volume_id=volume_id)
def stub_volume_get_all(context, search_opts=None):
diff --git a/nova/tests/api/openstack/volume/test_snapshots.py b/nova/tests/api/openstack/volume/test_snapshots.py
index 66f8cddc3..c6e703f83 100644
--- a/nova/tests/api/openstack/volume/test_snapshots.py
+++ b/nova/tests/api/openstack/volume/test_snapshots.py
@@ -124,6 +124,20 @@ class SnapshotApiTest(test.TestCase):
req,
body)
+ def test_snapshot_create_nonexistent_volume_id(self):
+ self.stubs.Set(volume.api.API, 'get', fakes.stub_volume_get_notfound)
+
+ snapshot = {"volume_id": 13,
+ "force": False,
+ "display_name": "Snapshot Test Name",
+ "display_description": "Snapshot Test Desc"}
+ body = dict(snapshot=snapshot)
+ req = fakes.HTTPRequest.blank('/v1/snapshots')
+ self.assertRaises(webob.exc.HTTPNotFound,
+ self.controller.create,
+ req,
+ body)
+
def test_snapshot_delete(self):
self.stubs.Set(volume.api.API, "get_snapshot", stub_snapshot_get)
self.stubs.Set(volume.api.API, "delete_snapshot", stub_snapshot_delete)