def stub_snapshot_get_all_by_project(context, project_id): return [ stubs.stub_snapshot(1, display_name='backup1', status='available'), stubs.stub_snapshot(2, display_name='backup2', status='available'), stubs.stub_snapshot(3, display_name='backup3', status='creating'), ]
def stub_snapshot_get_all_by_project(context, project_id): return [ stubs.stub_snapshot(1, display_name='backup1', status='available'), stubs.stub_snapshot(2, display_name='backup2', status='available'), stubs.stub_snapshot(3, display_name='backup3', status='creating'), ]
def stub_snapshot_get(context, snapshot_id): snapshot = stubs.stub_snapshot(snapshot_id) if snapshot_id == 3: snapshot['status'] = 'error' elif snapshot_id == 1: snapshot['status'] = 'creating' elif snapshot_id == 7: snapshot['status'] = 'available' else: snapshot['status'] = 'creating' return snapshot
def stub_snapshot_get(context, snapshot_id): snapshot = stubs.stub_snapshot(snapshot_id) if snapshot_id == 3: snapshot['status'] = 'error' elif snapshot_id == 1: snapshot['status'] = 'creating' elif snapshot_id == 7: snapshot['status'] = 'available' else: snapshot['status'] = 'creating' return snapshot
def stub_snapshot_get(context, snapshot_id): snapshot = stubs.stub_snapshot(snapshot_id) if snapshot_id == 3: snapshot["status"] = "error" elif snapshot_id == 1: snapshot["status"] = "creating" elif snapshot_id == 7: snapshot["status"] = "available" else: snapshot["status"] = "creating" return snapshot
def test_force_delete_snapshot(self): ctx = context.RequestContext('admin', 'fake', True) snapshot = stubs.stub_snapshot(1, host='foo') self.stubs.Set(db, 'volume_get', lambda x, y: snapshot) self.stubs.Set(db, 'snapshot_get', lambda x, y: snapshot) self.stubs.Set(volume_api.API, 'delete_snapshot', lambda *x, **y: True) path = '/v2/fake/snapshots/%s/action' % snapshot['id'] req = webob.Request.blank(path) req.method = 'POST' req.headers['content-type'] = 'application/json' req.body = jsonutils.dumps({'os-force_delete': {}}) # attach admin context to request req.environ['cinder.context'] = ctx resp = req.get_response(app()) self.assertEqual(resp.status_int, 202)
def test_force_delete_snapshot(self): ctx = context.RequestContext('admin', 'fake', True) snapshot = stubs.stub_snapshot(1, host='foo') self.stubs.Set(db, 'volume_get', lambda x, y: snapshot) self.stubs.Set(db, 'snapshot_get', lambda x, y: snapshot) self.stubs.Set(volume_api.API, 'delete_snapshot', lambda *x, **y: True) path = '/v2/fake/snapshots/%s/action' % snapshot['id'] req = webob.Request.blank(path) req.method = 'POST' req.headers['content-type'] = 'application/json' req.body = jsonutils.dumps({'os-force_delete': {}}) # attach admin context to request req.environ['cinder.context'] = ctx resp = req.get_response(app()) self.assertEqual(resp.status_int, 202)
def test_force_delete_snapshot(self): ctx = context.RequestContext("admin", "fake", True) snapshot = stubs.stub_snapshot(1, host="foo") self.stubs.Set(db, "volume_get", lambda x, y: snapshot) self.stubs.Set(db, "snapshot_get", lambda x, y: snapshot) self.stubs.Set(volume_api.API, "delete_snapshot", lambda *x, **y: True) path = "/v2/fake/snapshots/%s/action" % snapshot["id"] req = webob.Request.blank(path) req.method = "POST" req.headers["content-type"] = "application/json" req.body = jsonutils.dumps({"os-force_delete": {}}) # attach admin context to request req.environ["cinder.context"] = ctx resp = req.get_response(app()) self.assertEqual(resp.status_int, 202)
def test_force_delete_snapshot(self, volume_get, snapshot_get, get_by_id, delete_snapshot): ctx = context.RequestContext('admin', 'fake', True) volume = stubs.stub_volume(1) snapshot = stubs.stub_snapshot(1) snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot) volume_get.return_value = volume snapshot_get.return_value = snapshot get_by_id.return_value = snapshot_obj path = '/v2/fake/snapshots/%s/action' % snapshot['id'] req = webob.Request.blank(path) req.method = 'POST' req.headers['content-type'] = 'application/json' req.body = jsonutils.dumps({'os-force_delete': {}}) # attach admin context to request req.environ['cinder.context'] = ctx resp = req.get_response(app()) self.assertEqual(resp.status_int, 202)
def test_force_delete_snapshot(self, volume_get, snapshot_get, get_by_id, delete_snapshot): ctx = context.RequestContext('admin', 'fake', True) volume = stubs.stub_volume(1) snapshot = stubs.stub_snapshot(1) snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot) volume_get.return_value = volume snapshot_get.return_value = snapshot get_by_id.return_value = snapshot_obj path = '/v2/fake/snapshots/%s/action' % snapshot['id'] req = webob.Request.blank(path) req.method = 'POST' req.headers['content-type'] = 'application/json' req.body = jsonutils.dumps({'os-force_delete': {}}) # attach admin context to request req.environ['cinder.context'] = ctx resp = req.get_response(app()) self.assertEqual(resp.status_int, 202)
def stub_snapshot_get_all_by_project(context, project_id): return [ stubs.stub_snapshot(1, display_name='backup1'), stubs.stub_snapshot(2, display_name='backup2'), stubs.stub_snapshot(3, display_name='backup3'), ]
def stub_snapshot_get_all_by_project(context, project_id): return [ stubs.stub_snapshot(1, volume_id='vol1', status='creating'), stubs.stub_snapshot(2, volume_id='vol1', status='available'), stubs.stub_snapshot(3, volume_id='vol2', status='available'), ]
def stub_snapshot_get_all_by_project(context, project_id): return [ stubs.stub_snapshot(1, display_name='backup1'), stubs.stub_snapshot(2, display_name='backup2'), stubs.stub_snapshot(3, display_name='backup3'), ]
def stub_snapshot_get_all_by_project(context, project_id): return [ stubs.stub_snapshot(1, volume_id='vol1', status='creating'), stubs.stub_snapshot(2, volume_id='vol1', status='available'), stubs.stub_snapshot(3, volume_id='vol2', status='available'), ]