res = req.get_response(fakes.wsgi_app())
self.assertEqual(res.status_int, 400)
+ def test_begin_detaching(self):
+ def fake_begin_detaching(*args, **kwargs):
+ return {}
+ self.stubs.Set(volume.API, 'begin_detaching',
+ fake_begin_detaching)
+
+ body = {'os-begin_detaching': {'fake': 'fake'}}
+ req = webob.Request.blank('/v2/fake/volumes/1/action')
+ req.method = "POST"
+ req.body = jsonutils.dumps(body)
+ req.headers["content-type"] = "application/json"
+
+ res = req.get_response(fakes.wsgi_app())
+ self.assertEqual(res.status_int, 202)
+
+ def test_roll_detaching(self):
+ def fake_roll_detaching(*args, **kwargs):
+ return {}
+ self.stubs.Set(volume.API, 'roll_detaching',
+ fake_roll_detaching)
+
+ body = {'os-roll_detaching': {'fake': 'fake'}}
+ req = webob.Request.blank('/v2/fake/volumes/1/action')
+ req.method = "POST"
+ req.body = jsonutils.dumps(body)
+ req.headers["content-type"] = "application/json"
+
+ res = req.get_response(fakes.wsgi_app())
+ self.assertEqual(res.status_int, 202)
+
def test_extend_volume(self):
def fake_extend_volume(*args, **kwargs):
return {}
req,
id,
body)
+
+ def test_volume_upload_image_typeerror(self):
+ body = {"os-volume_upload_image_fake": "fake"}
+ req = fakes.HTTPRequest.blank('/v2/tenant1/volumes/%s/action' % id)
+ self.assertRaises(webob.exc.HTTPBadRequest,
+ self.controller._volume_upload_image,
+ req,
+ id,
+ body)
+
+ def test_extend_volume_valueerror(self):
+ id = 1
+ body = {'os-extend': {'new_size': 'fake'}}
+ req = fakes.HTTPRequest.blank('/v2/tenant1/volumes/%s/action' % id)
+ self.assertRaises(webob.exc.HTTPBadRequest,
+ self.controller._extend,
+ req,
+ id,
+ body)
+
+ def test_copy_volume_to_image_notimagename(self):
+ id = 1
+ vol = {"container_format": 'bare',
+ "disk_format": 'raw',
+ "image_name": None,
+ "force": True}
+ body = {"os-volume_upload_image": vol}
+ req = fakes.HTTPRequest.blank('/v2/tenant1/volumes/%s/action' % id)
+ self.assertRaises(webob.exc.HTTPBadRequest,
+ self.controller._volume_upload_image,
+ req,
+ id,
+ body)