# License for the specific language governing permissions and limitations
# under the License.
-import ast
-
import fixtures
import mock
from oslo_concurrency import lockutils
req = webob.Request.blank('/v2/fake/volumes/%s/action' % volume['id'])
req.method = 'POST'
req.headers['content-type'] = 'application/json'
- req.body = \
- jsonutils.dumps({'os-reset_status': updated_status})
+ req.body = jsonutils.dump_as_bytes({'os-reset_status': updated_status})
req.environ['cinder.context'] = ctx
resp = req.get_response(app())
return resp
snapshot.id)
req.method = 'POST'
req.headers['content-type'] = 'application/json'
- req.body = \
- jsonutils.dumps({'os-reset_status': updated_status})
+ req.body = jsonutils.dump_as_bytes({'os-reset_status': updated_status})
req.environ['cinder.context'] = ctx
resp = req.get_response(app())
return resp
req = webob.Request.blank('/v2/fake/backups/%s/action' % backup['id'])
req.method = 'POST'
req.headers['content-type'] = 'application/json'
- req.body = \
- jsonutils.dumps({'os-reset_status': updated_status})
+ req.body = jsonutils.dump_as_bytes({'os-reset_status': updated_status})
req.environ['cinder.context'] = ctx
resp = req.get_response(app())
return resp
'missing-volume-id')
req.method = 'POST'
req.headers['content-type'] = 'application/json'
- req.body = jsonutils.dumps({'os-reset_status': {'status':
- 'available'}})
+ body = {'os-reset_status': {'status': 'available'}}
+ req.body = jsonutils.dump_as_bytes(body)
req.environ['cinder.context'] = ctx
resp = req.get_response(app())
self.assertEqual(404, resp.status_int)
req = webob.Request.blank('/v2/fake/volumes/%s/action' % volume['id'])
req.method = 'POST'
req.headers['content-type'] = 'application/json'
- req.body = jsonutils.dumps({'os-force_delete': {}})
+ req.body = jsonutils.dump_as_bytes({'os-force_delete': {}})
# attach admin context to request
req.environ['cinder.context'] = ctx
resp = req.get_response(app())
req = webob.Request.blank(path)
req.method = 'POST'
req.headers['content-type'] = 'application/json'
- req.body = jsonutils.dumps({'os-force_delete': {}})
+ req.body = jsonutils.dump_as_bytes({'os-force_delete': {}})
# attach admin context to request
req.environ['cinder.context'] = ctx
resp = req.get_response(app())
req.method = 'POST'
req.headers['content-type'] = 'application/json'
# request status of 'error'
- req.body = jsonutils.dumps({'os-force_detach':
- {'attachment_id': attachment['id'],
- 'connector': connector}})
+ body = {'os-force_detach': {'attachment_id': attachment['id'],
+ 'connector': connector}}
+ req.body = jsonutils.dump_as_bytes(body)
# attach admin context to request
req.environ['cinder.context'] = ctx
# make request
req.method = 'POST'
req.headers['content-type'] = 'application/json'
# request status of 'error'
- req.body = jsonutils.dumps({'os-force_detach':
- {'attachment_id': attachment['id'],
- 'connector': connector}})
+ body = {'os-force_detach': {'attachment_id': attachment['id'],
+ 'connector': connector}}
+ req.body = jsonutils.dump_as_bytes(body)
# attach admin context to request
req.environ['cinder.context'] = ctx
# make request
volume['id'])
req.method = 'POST'
req.headers['content-type'] = 'application/json'
- req.body = jsonutils.dumps({'os-force_detach':
- {'attachment_id': 'fake'}})
+ body = {'os-force_detach': {'attachment_id': 'fake'}}
+ req.body = jsonutils.dump_as_bytes(body)
# attach admin context to request
req.environ['cinder.context'] = ctx
# make request
volume['id'])
req.method = 'POST'
req.headers['content-type'] = 'application/json'
- req.body = jsonutils.dumps({'os-force_detach':
- {'attachment_id': 'fake'}})
+ body = {'os-force_detach': {'attachment_id': 'fake'}}
+ req.body = jsonutils.dump_as_bytes(body)
# attach admin context to request
req.environ['cinder.context'] = ctx
# make request
volume['id'])
req.method = 'POST'
req.headers['content-type'] = 'application/json'
- req.body = jsonutils.dumps({'os-force_detach':
- {'attachment_id': 'fake',
- 'connector': connector}})
+ body = {'os-force_detach': {'attachment_id': 'fake',
+ 'connector': connector}}
+ req.body = jsonutils.dump_as_bytes(body)
# attach admin context to request
req.environ['cinder.context'] = ctx
volume['id'])
req.method = 'POST'
req.headers['content-type'] = 'application/json'
- req.body = jsonutils.dumps({'os-force_detach':
- {'attachment_id': 'fake',
- 'connector': connector}})
+ body = {'os-force_detach': {'attachment_id': 'fake',
+ 'connector': connector}}
+ req.body = jsonutils.dump_as_bytes(body)
# attach admin context to request
req.environ['cinder.context'] = ctx
# make request
req.headers['content-type'] = 'application/json'
body = {'os-migrate_volume': {'host': host,
'force_host_copy': force_host_copy}}
- req.body = jsonutils.dumps(body)
+ req.body = jsonutils.dump_as_bytes(body)
req.environ['cinder.context'] = ctx
resp = req.get_response(app())
# verify status
req.headers['content-type'] = 'application/json'
body = {'os-migrate_volume': {'host': host,
'force_host_copy': False}}
- req.body = jsonutils.dumps(body)
+ req.body = jsonutils.dump_as_bytes(body)
req.environ['cinder.context'] = ctx
resp = req.get_response(app())
# verify status
req.headers['content-type'] = 'application/json'
body = {'new_volume': new_volume['id'], 'error': error}
if no_body:
- req.body = jsonutils.dumps({'': body})
+ body = {'': body}
else:
- req.body = jsonutils.dumps({'os-migrate_volume_completion': body})
+ body = {'os-migrate_volume_completion': body}
+ req.body = jsonutils.dump_as_bytes(body)
req.environ['cinder.context'] = ctx
resp = req.get_response(app())
- resp_dict = ast.literal_eval(resp.body)
+ resp_dict = resp.json
# verify status
self.assertEqual(expected_status, resp.status_int)
if expected_id:
req = webob.Request.blank('/v2/fake/backups/%s/action' % id)
req.method = 'POST'
req.headers['Content-Type'] = 'application/json'
- req.body = jsonutils.dumps({'os-force_delete': {}})
+ req.body = jsonutils.dump_as_bytes({'os-force_delete': {}})
req.environ['cinder.context'] = ctx
res = req.get_response(app())
req = webob.Request.blank('/v2/fake/backups/%s/action' % id)
req.method = 'POST'
req.headers['Content-Type'] = 'application/json'
- req.body = jsonutils.dumps({'os-force_delete': {}})
+ req.body = jsonutils.dump_as_bytes({'os-force_delete': {}})
req.environ['cinder.context'] = ctx
res = req.get_response(app())
self.assertEqual(405, res.status_int)