Merge "Add "body=" argument to v3 API unit tests"
This commit is contained in:
commit
b63e2f4143
@ -351,9 +351,9 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
if override_controller:
|
||||
server = override_controller.create(req, body).obj['server']
|
||||
server = override_controller.create(req, body=body).obj['server']
|
||||
else:
|
||||
server = self.controller.create(req, body).obj['server']
|
||||
server = self.controller.create(req, body=body).obj['server']
|
||||
|
||||
def test_create_instance_with_availability_zone_disabled(self):
|
||||
availability_zone = [{'availability_zone': 'foo'}]
|
||||
@ -402,7 +402,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
agg = db.aggregate_create(admin_context,
|
||||
{'name': 'agg1'}, {'availability_zone': 'nova'})
|
||||
db.aggregate_host_add(admin_context, agg['id'], 'host1_zones')
|
||||
res = self.controller.create(req, body).obj
|
||||
res = self.controller.create(req, body=body).obj
|
||||
server = res['server']
|
||||
self.assertEqual(FAKE_UUID, server['id'])
|
||||
|
||||
@ -425,6 +425,6 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
req.method = 'POST'
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
res = self.controller.create(req, body).obj
|
||||
res = self.controller.create(req, body=body).obj
|
||||
server = res['server']
|
||||
self.assertEqual(FAKE_UUID, server['id'])
|
||||
|
@ -82,9 +82,9 @@ class BlockDeviceMappingTest(test.TestCase):
|
||||
req.body = jsonutils.dumps(body)
|
||||
|
||||
if override_controller:
|
||||
override_controller.create(req, body).obj['server']
|
||||
override_controller.create(req, body=body).obj['server']
|
||||
else:
|
||||
self.controller.create(req, body).obj['server']
|
||||
self.controller.create(req, body=body).obj['server']
|
||||
|
||||
def test_create_instance_with_block_device_mapping_disabled(self):
|
||||
bdm = [{'device_name': 'foo'}]
|
||||
|
@ -186,9 +186,9 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
if override_controller:
|
||||
server = override_controller.create(req, body).obj['server']
|
||||
server = override_controller.create(req, body=body).obj['server']
|
||||
else:
|
||||
server = self.controller.create(req, body).obj['server']
|
||||
server = self.controller.create(req, body=body).obj['server']
|
||||
|
||||
def test_create_instance_with_config_drive_disabled(self):
|
||||
params = {config_drive.ATTRIBUTE_NAME: "False"}
|
||||
@ -228,7 +228,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
req.method = 'POST'
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
res = self.controller.create(req, body).obj
|
||||
res = self.controller.create(req, body=body).obj
|
||||
|
||||
server = res['server']
|
||||
self.assertEqual(FAKE_UUID, server['id'])
|
||||
@ -255,7 +255,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.create, req, body)
|
||||
self.controller.create, req, body=body)
|
||||
|
||||
def test_create_instance_without_config_drive(self):
|
||||
image_href = '76fa36fc-c930-4bf3-8c8a-ea2a2420deb6'
|
||||
@ -276,7 +276,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
req.method = 'POST'
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
res = self.controller.create(req, body).obj
|
||||
res = self.controller.create(req, body=body).obj
|
||||
|
||||
server = res['server']
|
||||
self.assertEqual(FAKE_UUID, server['id'])
|
||||
|
@ -150,9 +150,9 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
if override_controller:
|
||||
server = override_controller.create(req, body).obj['server']
|
||||
server = override_controller.create(req, body=body).obj['server']
|
||||
else:
|
||||
server = self.controller.create(req, body).obj['server']
|
||||
server = self.controller.create(req, body=body).obj['server']
|
||||
|
||||
def test_create_instance_with_multiple_create_disabled(self):
|
||||
ret_res_id = True
|
||||
@ -229,7 +229,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.create,
|
||||
req,
|
||||
body)
|
||||
body=body)
|
||||
|
||||
def test_create_instance_invalid_negative_max(self):
|
||||
image_href = '76fa36fc-c930-4bf3-8c8a-ea2a2420deb6'
|
||||
@ -250,7 +250,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.create,
|
||||
req,
|
||||
body)
|
||||
body=body)
|
||||
|
||||
def test_create_instance_invalid_min_greater_than_max(self):
|
||||
image_href = '76fa36fc-c930-4bf3-8c8a-ea2a2420deb6'
|
||||
@ -272,7 +272,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.create,
|
||||
req,
|
||||
body)
|
||||
body=body)
|
||||
|
||||
def test_create_instance_invalid_alpha_min(self):
|
||||
image_href = '76fa36fc-c930-4bf3-8c8a-ea2a2420deb6'
|
||||
@ -293,7 +293,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.create,
|
||||
req,
|
||||
body)
|
||||
body=body)
|
||||
|
||||
def test_create_instance_invalid_alpha_max(self):
|
||||
image_href = '76fa36fc-c930-4bf3-8c8a-ea2a2420deb6'
|
||||
@ -314,7 +314,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.create,
|
||||
req,
|
||||
body)
|
||||
body=body)
|
||||
|
||||
def test_create_multiple_instances(self):
|
||||
"""Test creating multiple instances but not asking for
|
||||
@ -337,7 +337,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
req.method = 'POST'
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
res = self.controller.create(req, body).obj
|
||||
res = self.controller.create(req, body=body).obj
|
||||
|
||||
self.assertEqual(FAKE_UUID, res["server"]["id"])
|
||||
self._check_admin_password_len(res["server"])
|
||||
@ -364,7 +364,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
req.method = 'POST'
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
res = self.controller.create(req, body).obj
|
||||
res = self.controller.create(req, body=body).obj
|
||||
|
||||
self.assertEqual(FAKE_UUID, res["server"]["id"])
|
||||
self._check_admin_password_missing(res["server"])
|
||||
@ -400,7 +400,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
req.method = 'POST'
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
res = self.controller.create(req, body)
|
||||
res = self.controller.create(req, body=body)
|
||||
reservation_id = res.obj['servers_reservation']['reservation_id']
|
||||
self.assertNotEqual(reservation_id, "")
|
||||
self.assertIsNotNone(reservation_id)
|
||||
@ -472,7 +472,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.create, req, body)
|
||||
self.controller.create, req, body=body)
|
||||
|
||||
def test_create_multiple_instance_with_non_integer_min_count(self):
|
||||
image_href = '76fa36fc-c930-4bf3-8c8a-ea2a2420deb6'
|
||||
@ -493,4 +493,4 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.create, req, body)
|
||||
self.controller.create, req, body=body)
|
||||
|
@ -222,9 +222,9 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
if override_controller:
|
||||
server = override_controller.create(req, body).obj['server']
|
||||
server = override_controller.create(req, body=body).obj['server']
|
||||
else:
|
||||
server = self.controller.create(req, body).obj['server']
|
||||
server = self.controller.create(req, body=body).obj['server']
|
||||
|
||||
def test_create_instance_with_scheduler_hints_disabled(self):
|
||||
hints = {'a': 'b'}
|
||||
|
@ -285,9 +285,9 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
if override_controller:
|
||||
server = override_controller.create(req, body).obj['server']
|
||||
server = override_controller.create(req, body=body).obj['server']
|
||||
else:
|
||||
server = self.controller.create(req, body).obj['server']
|
||||
server = self.controller.create(req, body=body).obj['server']
|
||||
|
||||
def test_create_instance_with_security_group_enabled(self):
|
||||
group = 'foo'
|
||||
|
@ -270,7 +270,7 @@ class ServerActionsControllerTest(test.TestCase):
|
||||
}
|
||||
|
||||
req = fakes.HTTPRequestV3.blank(self.url)
|
||||
robj = self.controller._action_rebuild(req, FAKE_UUID, body)
|
||||
robj = self.controller._action_rebuild(req, FAKE_UUID, body=body)
|
||||
body = robj.obj
|
||||
|
||||
self.assertEqual(body['server']['image']['id'], '2')
|
||||
@ -297,7 +297,7 @@ class ServerActionsControllerTest(test.TestCase):
|
||||
}
|
||||
|
||||
req = fakes.HTTPRequestV3.blank('/v3/servers/a/action')
|
||||
self.controller._action_rebuild(req, FAKE_UUID, body)
|
||||
self.controller._action_rebuild(req, FAKE_UUID, body=body)
|
||||
self.assertEqual(info['image_href_in_call'], self.image_uuid)
|
||||
|
||||
def test_rebuild_instance_with_image_href_uses_uuid(self):
|
||||
@ -318,7 +318,7 @@ class ServerActionsControllerTest(test.TestCase):
|
||||
}
|
||||
|
||||
req = fakes.HTTPRequestV3.blank('/v3/servers/a/action')
|
||||
self.controller._action_rebuild(req, FAKE_UUID, body)
|
||||
self.controller._action_rebuild(req, FAKE_UUID, body=body)
|
||||
self.assertEqual(info['image_href_in_call'], self.image_uuid)
|
||||
|
||||
def test_rebuild_accepted_minimum_pass_disabled(self):
|
||||
@ -338,7 +338,7 @@ class ServerActionsControllerTest(test.TestCase):
|
||||
}
|
||||
|
||||
req = fakes.HTTPRequestV3.blank(self.url)
|
||||
robj = self.controller._action_rebuild(req, FAKE_UUID, body)
|
||||
robj = self.controller._action_rebuild(req, FAKE_UUID, body=body)
|
||||
body = robj.obj
|
||||
|
||||
self.assertEqual(body['server']['image']['id'], '2')
|
||||
@ -363,7 +363,7 @@ class ServerActionsControllerTest(test.TestCase):
|
||||
req = fakes.HTTPRequestV3.blank(self.url)
|
||||
self.assertRaises(webob.exc.HTTPConflict,
|
||||
self.controller._action_rebuild,
|
||||
req, FAKE_UUID, body)
|
||||
req, FAKE_UUID, body=body)
|
||||
|
||||
def test_rebuild_accepted_with_metadata(self):
|
||||
metadata = {'new': 'metadata'}
|
||||
@ -380,7 +380,7 @@ class ServerActionsControllerTest(test.TestCase):
|
||||
}
|
||||
|
||||
req = fakes.HTTPRequestV3.blank(self.url)
|
||||
body = self.controller._action_rebuild(req, FAKE_UUID, body).obj
|
||||
body = self.controller._action_rebuild(req, FAKE_UUID, body=body).obj
|
||||
|
||||
self.assertEqual(body['server']['metadata'], metadata)
|
||||
|
||||
@ -395,7 +395,7 @@ class ServerActionsControllerTest(test.TestCase):
|
||||
req = fakes.HTTPRequestV3.blank(self.url)
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller._action_rebuild,
|
||||
req, FAKE_UUID, body)
|
||||
req, FAKE_UUID, body=body)
|
||||
|
||||
def test_rebuild_with_too_large_metadata(self):
|
||||
body = {
|
||||
@ -410,7 +410,7 @@ class ServerActionsControllerTest(test.TestCase):
|
||||
req = fakes.HTTPRequestV3.blank(self.url)
|
||||
self.assertRaises(webob.exc.HTTPRequestEntityTooLarge,
|
||||
self.controller._action_rebuild, req,
|
||||
FAKE_UUID, body)
|
||||
FAKE_UUID, body=body)
|
||||
|
||||
def test_rebuild_bad_entity(self):
|
||||
body = {
|
||||
@ -422,7 +422,7 @@ class ServerActionsControllerTest(test.TestCase):
|
||||
req = fakes.HTTPRequestV3.blank(self.url)
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller._action_rebuild,
|
||||
req, FAKE_UUID, body)
|
||||
req, FAKE_UUID, body=body)
|
||||
|
||||
def test_rebuild_admin_password(self):
|
||||
return_server = fakes.fake_instance_get(image_ref='2',
|
||||
@ -437,7 +437,7 @@ class ServerActionsControllerTest(test.TestCase):
|
||||
}
|
||||
|
||||
req = fakes.HTTPRequestV3.blank(self.url)
|
||||
body = self.controller._action_rebuild(req, FAKE_UUID, body).obj
|
||||
body = self.controller._action_rebuild(req, FAKE_UUID, body=body).obj
|
||||
|
||||
self.assertEqual(body['server']['image']['id'], '2')
|
||||
self.assertEqual(body['server']['admin_password'], 'asdf')
|
||||
@ -459,7 +459,7 @@ class ServerActionsControllerTest(test.TestCase):
|
||||
}
|
||||
|
||||
req = fakes.HTTPRequestV3.blank(self.url)
|
||||
body = self.controller._action_rebuild(req, FAKE_UUID, body).obj
|
||||
body = self.controller._action_rebuild(req, FAKE_UUID, body=body).obj
|
||||
|
||||
self.assertEqual(body['server']['image']['id'], '2')
|
||||
self.assertNotIn('admin_password', body['server'])
|
||||
@ -479,7 +479,7 @@ class ServerActionsControllerTest(test.TestCase):
|
||||
req = fakes.HTTPRequestV3.blank(self.url)
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
self.controller._action_rebuild,
|
||||
req, FAKE_UUID, body)
|
||||
req, FAKE_UUID, body=body)
|
||||
|
||||
def test_rebuild_with_bad_image(self):
|
||||
body = {
|
||||
@ -490,7 +490,7 @@ class ServerActionsControllerTest(test.TestCase):
|
||||
req = fakes.HTTPRequestV3.blank(self.url)
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller._action_rebuild,
|
||||
req, FAKE_UUID, body)
|
||||
req, FAKE_UUID, body=body)
|
||||
|
||||
def test_rebuild_when_kernel_not_exists(self):
|
||||
|
||||
@ -518,7 +518,7 @@ class ServerActionsControllerTest(test.TestCase):
|
||||
req = fakes.HTTPRequestV3.blank(self.url)
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller._action_rebuild,
|
||||
req, FAKE_UUID, body)
|
||||
req, FAKE_UUID, body=body)
|
||||
|
||||
def test_rebuild_proper_kernel_ram(self):
|
||||
instance_meta = {'kernel_id': None, 'ramdisk_id': None}
|
||||
@ -561,7 +561,7 @@ class ServerActionsControllerTest(test.TestCase):
|
||||
},
|
||||
}
|
||||
req = fakes.HTTPRequestV3.blank(self.url)
|
||||
self.controller._action_rebuild(req, FAKE_UUID, body).obj
|
||||
self.controller._action_rebuild(req, FAKE_UUID, body=body).obj
|
||||
self.assertEqual(instance_meta['kernel_id'], '1')
|
||||
self.assertEqual(instance_meta['ramdisk_id'], '2')
|
||||
|
||||
@ -591,7 +591,7 @@ class ServerActionsControllerTest(test.TestCase):
|
||||
mox.IgnoreArg())
|
||||
self.mox.ReplayAll()
|
||||
|
||||
self.controller._action_rebuild(req, FAKE_UUID, body)
|
||||
self.controller._action_rebuild(req, FAKE_UUID, body=body)
|
||||
|
||||
def test_rebuild_preserve_ephemeral_true(self):
|
||||
self._test_rebuild_preserve_ephemeral(True)
|
||||
|
@ -1384,7 +1384,7 @@ class ServersControllerRebuildInstanceTest(ControllerTest):
|
||||
self.req.body = jsonutils.dumps(self.body)
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller._action_rebuild,
|
||||
self.req, FAKE_UUID, self.body)
|
||||
self.req, FAKE_UUID, body=self.body)
|
||||
|
||||
def test_rebuild_instance_with_metadata_key_too_long(self):
|
||||
self.body['rebuild']['metadata'][('a' * 260)] = 'world'
|
||||
@ -1392,7 +1392,7 @@ class ServersControllerRebuildInstanceTest(ControllerTest):
|
||||
self.req.body = jsonutils.dumps(self.body)
|
||||
self.assertRaises(webob.exc.HTTPRequestEntityTooLarge,
|
||||
self.controller._action_rebuild,
|
||||
self.req, FAKE_UUID, self.body)
|
||||
self.req, FAKE_UUID, body=self.body)
|
||||
|
||||
def test_rebuild_instance_with_metadata_value_too_long(self):
|
||||
self.body['rebuild']['metadata']['key1'] = ('a' * 260)
|
||||
@ -1400,7 +1400,7 @@ class ServersControllerRebuildInstanceTest(ControllerTest):
|
||||
self.req.body = jsonutils.dumps(self.body)
|
||||
self.assertRaises(webob.exc.HTTPRequestEntityTooLarge,
|
||||
self.controller._action_rebuild, self.req,
|
||||
FAKE_UUID, self.body)
|
||||
FAKE_UUID, body=self.body)
|
||||
|
||||
def test_rebuild_instance_fails_when_min_ram_too_small(self):
|
||||
# make min_ram larger than our instance ram size
|
||||
@ -1415,7 +1415,7 @@ class ServersControllerRebuildInstanceTest(ControllerTest):
|
||||
self.req.body = jsonutils.dumps(self.body)
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller._action_rebuild,
|
||||
self.req, FAKE_UUID, self.body)
|
||||
self.req, FAKE_UUID, body=self.body)
|
||||
|
||||
def test_rebuild_instance_fails_when_min_disk_too_small(self):
|
||||
# make min_disk larger than our instance disk size
|
||||
@ -1429,7 +1429,7 @@ class ServersControllerRebuildInstanceTest(ControllerTest):
|
||||
self.req.body = jsonutils.dumps(self.body)
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller._action_rebuild, self.req,
|
||||
FAKE_UUID, self.body)
|
||||
FAKE_UUID, body=self.body)
|
||||
|
||||
def test_rebuild_instance_image_too_large(self):
|
||||
# make image size larger than our instance disk size
|
||||
@ -1444,7 +1444,7 @@ class ServersControllerRebuildInstanceTest(ControllerTest):
|
||||
self.req.body = jsonutils.dumps(self.body)
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller._action_rebuild,
|
||||
self.req, FAKE_UUID, self.body)
|
||||
self.req, FAKE_UUID, body=self.body)
|
||||
|
||||
def test_rebuild_instance_name_all_blank(self):
|
||||
def fake_get_image(self, context, image_href):
|
||||
@ -1456,7 +1456,7 @@ class ServersControllerRebuildInstanceTest(ControllerTest):
|
||||
self.req.body = jsonutils.dumps(self.body)
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller._action_rebuild,
|
||||
self.req, FAKE_UUID, self.body)
|
||||
self.req, FAKE_UUID, body=self.body)
|
||||
|
||||
def test_rebuild_instance_with_deleted_image(self):
|
||||
def fake_get_image(self, context, image_href):
|
||||
@ -1469,7 +1469,7 @@ class ServersControllerRebuildInstanceTest(ControllerTest):
|
||||
self.req.body = jsonutils.dumps(self.body)
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller._action_rebuild,
|
||||
self.req, FAKE_UUID, self.body)
|
||||
self.req, FAKE_UUID, body=self.body)
|
||||
|
||||
def test_start(self):
|
||||
self.mox.StubOutWithMock(compute_api.API, 'start')
|
||||
@ -1579,7 +1579,7 @@ class ServersControllerUpdateTest(ControllerTest):
|
||||
'name': 'server_test',
|
||||
}}
|
||||
req = self._get_request(body, {'name': 'server_test'})
|
||||
res_dict = self.controller.update(req, FAKE_UUID, body)
|
||||
res_dict = self.controller.update(req, FAKE_UUID, body=body)
|
||||
|
||||
self.assertEqual(res_dict['server']['id'], FAKE_UUID)
|
||||
self.assertEqual(res_dict['server']['name'], 'server_test')
|
||||
@ -1587,7 +1587,7 @@ class ServersControllerUpdateTest(ControllerTest):
|
||||
def test_update_server_name(self):
|
||||
body = {'server': {'name': 'server_test'}}
|
||||
req = self._get_request(body, {'name': 'server_test'})
|
||||
res_dict = self.controller.update(req, FAKE_UUID, body)
|
||||
res_dict = self.controller.update(req, FAKE_UUID, body=body)
|
||||
|
||||
self.assertEqual(res_dict['server']['id'], FAKE_UUID)
|
||||
self.assertEqual(res_dict['server']['name'], 'server_test')
|
||||
@ -1596,7 +1596,7 @@ class ServersControllerUpdateTest(ControllerTest):
|
||||
body = {'server': {'name': 'x' * 256}}
|
||||
req = self._get_request(body, {'name': 'server_test'})
|
||||
self.assertRaises(webob.exc.HTTPBadRequest, self.controller.update,
|
||||
req, FAKE_UUID, body)
|
||||
req, FAKE_UUID, body=body)
|
||||
|
||||
def test_update_server_name_all_blank_spaces(self):
|
||||
self.stubs.Set(db, 'instance_get',
|
||||
@ -1607,7 +1607,7 @@ class ServersControllerUpdateTest(ControllerTest):
|
||||
body = {'server': {'name': ' ' * 64}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
self.assertRaises(webob.exc.HTTPBadRequest, self.controller.update,
|
||||
req, FAKE_UUID, body)
|
||||
req, FAKE_UUID, body=body)
|
||||
|
||||
def test_update_server_adminPass_ignored(self):
|
||||
inst_dict = dict(name='server_test', adminPass='bacon')
|
||||
@ -1630,7 +1630,7 @@ class ServersControllerUpdateTest(ControllerTest):
|
||||
req.method = 'PUT'
|
||||
req.content_type = "application/json"
|
||||
req.body = jsonutils.dumps(body)
|
||||
res_dict = self.controller.update(req, FAKE_UUID, body)
|
||||
res_dict = self.controller.update(req, FAKE_UUID, body=body)
|
||||
|
||||
self.assertEqual(res_dict['server']['id'], FAKE_UUID)
|
||||
self.assertEqual(res_dict['server']['name'], 'server_test')
|
||||
@ -1643,7 +1643,7 @@ class ServersControllerUpdateTest(ControllerTest):
|
||||
body = {'server': {'name': 'server_test'}}
|
||||
req = self._get_request(body)
|
||||
self.assertRaises(webob.exc.HTTPNotFound, self.controller.update,
|
||||
req, FAKE_UUID, body)
|
||||
req, FAKE_UUID, body=body)
|
||||
|
||||
def test_update_server_not_found_on_update(self):
|
||||
def fake_update(*args, **kwargs):
|
||||
@ -1653,7 +1653,7 @@ class ServersControllerUpdateTest(ControllerTest):
|
||||
body = {'server': {'name': 'server_test'}}
|
||||
req = self._get_request(body)
|
||||
self.assertRaises(webob.exc.HTTPNotFound, self.controller.update,
|
||||
req, FAKE_UUID, body)
|
||||
req, FAKE_UUID, body=body)
|
||||
|
||||
def test_update_server_policy_fail(self):
|
||||
rule = {'compute:update': common_policy.parse_rule('role:admin')}
|
||||
@ -1661,7 +1661,7 @@ class ServersControllerUpdateTest(ControllerTest):
|
||||
body = {'server': {'name': 'server_test'}}
|
||||
req = self._get_request(body, {'name': 'server_test'})
|
||||
self.assertRaises(exception.PolicyNotAuthorized,
|
||||
self.controller.update, req, FAKE_UUID, body)
|
||||
self.controller.update, req, FAKE_UUID, body=body)
|
||||
|
||||
|
||||
class ServerStatusTest(test.TestCase):
|
||||
@ -1896,7 +1896,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
self.body['server']['image_ref'] = image_uuid
|
||||
self.body['server']['flavor_ref'] = flavor
|
||||
self.req.body = jsonutils.dumps(self.body)
|
||||
server = self.controller.create(self.req, self.body).obj['server']
|
||||
server = self.controller.create(self.req, body=self.body).obj['server']
|
||||
self._check_admin_password_len(server)
|
||||
self.assertEqual(FAKE_UUID, server['id'])
|
||||
|
||||
@ -1925,7 +1925,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
self.req.body = jsonutils.dumps(self.body)
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.create,
|
||||
self.req, self.body)
|
||||
self.req, body=self.body)
|
||||
# TODO(cyeoh): bp-v3-api-unittests
|
||||
# This needs to be ported to the os-networks extension tests
|
||||
# def test_create_server_with_invalid_networks_parameter(self):
|
||||
@ -1962,7 +1962,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
with testtools.ExpectedException(
|
||||
webob.exc.HTTPBadRequest,
|
||||
'Image 76fa36fc-c930-4bf3-8c8a-ea2a2420deb6 is not active.'):
|
||||
self.controller.create(self.req, self.body)
|
||||
self.controller.create(self.req, body=self.body)
|
||||
|
||||
def test_create_server_image_too_large(self):
|
||||
# Get the fake image service so we can set the status to deleted
|
||||
@ -1984,13 +1984,13 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
with testtools.ExpectedException(
|
||||
webob.exc.HTTPBadRequest,
|
||||
"Flavor's disk is too small for requested image."):
|
||||
self.controller.create(self.req, self.body)
|
||||
self.controller.create(self.req, body=self.body)
|
||||
|
||||
def test_create_instance_image_ref_is_bookmark(self):
|
||||
image_href = 'http://localhost/images/%s' % self.image_uuid
|
||||
self.body['server']['image_ref'] = image_href
|
||||
self.req.body = jsonutils.dumps(self.body)
|
||||
res = self.controller.create(self.req, self.body).obj
|
||||
res = self.controller.create(self.req, body=self.body).obj
|
||||
|
||||
server = res['server']
|
||||
self.assertEqual(FAKE_UUID, server['id'])
|
||||
@ -2003,7 +2003,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
self.body['server']['flavor_ref'] = flavor_ref
|
||||
self.req.body = jsonutils.dumps(self.body)
|
||||
self.assertRaises(webob.exc.HTTPBadRequest, self.controller.create,
|
||||
self.req, self.body)
|
||||
self.req, body=self.body)
|
||||
|
||||
def test_create_instance_no_key_pair(self):
|
||||
fakes.stub_out_key_pair_funcs(self.stubs, have_key_pair=False)
|
||||
@ -2016,7 +2016,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
self.body['server'].update(params)
|
||||
self.req.body = jsonutils.dumps(self.body)
|
||||
self.req.headers["content-type"] = "application/json"
|
||||
self.controller.create(self.req, self.body).obj['server']
|
||||
self.controller.create(self.req, body=self.body).obj['server']
|
||||
|
||||
# TODO(cyeoh): bp-v3-api-unittests
|
||||
# This needs to be ported to the os-keypairs extension tests
|
||||
@ -2111,7 +2111,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
image_href = 'http://localhost/v2/fake/images/%s' % self.image_uuid
|
||||
self.body['server']['image_ref'] = image_href
|
||||
self.req.body = jsonutils.dumps(self.body)
|
||||
res = self.controller.create(self.req, self.body).obj
|
||||
res = self.controller.create(self.req, body=self.body).obj
|
||||
|
||||
server = res['server']
|
||||
self._check_admin_password_missing(server)
|
||||
@ -2124,7 +2124,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
self.body['server']['image_ref'] = image_href
|
||||
self.req.body = jsonutils.dumps(self.body)
|
||||
self.assertRaises(webob.exc.HTTPBadRequest, self.controller.create,
|
||||
self.req, self.body)
|
||||
self.req, body=self.body)
|
||||
|
||||
def test_create_instance_name_all_blank_spaces(self):
|
||||
# proper local hrefs must start with 'http://localhost/v2/'
|
||||
@ -2148,14 +2148,14 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.create, req, body)
|
||||
self.controller.create, req, body=body)
|
||||
|
||||
def test_create_instance(self):
|
||||
# proper local hrefs must start with 'http://localhost/v3/'
|
||||
image_href = 'http://localhost/v2/images/%s' % self.image_uuid
|
||||
self.body['server']['image_ref'] = image_href
|
||||
self.req.body = jsonutils.dumps(self.body)
|
||||
res = self.controller.create(self.req, self.body).obj
|
||||
res = self.controller.create(self.req, body=self.body).obj
|
||||
|
||||
server = res['server']
|
||||
self._check_admin_password_len(server)
|
||||
@ -2188,7 +2188,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
req.method = 'POST'
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
self.assertRaises(KeyError, self.controller.create, req, body)
|
||||
self.assertRaises(KeyError, self.controller.create, req, body=body)
|
||||
|
||||
def test_create_instance_pass_disabled(self):
|
||||
self.flags(enable_instance_password=False)
|
||||
@ -2196,7 +2196,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
image_href = 'http://localhost/v2/images/%s' % self.image_uuid
|
||||
self.body['server']['image_ref'] = image_href
|
||||
self.req.body = jsonutils.dumps(self.body)
|
||||
res = self.controller.create(self.req, self.body).obj
|
||||
res = self.controller.create(self.req, body=self.body).obj
|
||||
|
||||
server = res['server']
|
||||
self._check_admin_password_missing(server)
|
||||
@ -2209,7 +2209,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
self.body['server']['metadata']['vote'] = 'fiddletown'
|
||||
self.req.body = jsonutils.dumps(self.body)
|
||||
self.assertRaises(webob.exc.HTTPRequestEntityTooLarge,
|
||||
self.controller.create, self.req, self.body)
|
||||
self.controller.create, self.req, body=self.body)
|
||||
|
||||
def test_create_instance_metadata_key_too_long(self):
|
||||
self.flags(quota_metadata_items=1)
|
||||
@ -2219,7 +2219,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
|
||||
self.req.body = jsonutils.dumps(self.body)
|
||||
self.assertRaises(webob.exc.HTTPRequestEntityTooLarge,
|
||||
self.controller.create, self.req, self.body)
|
||||
self.controller.create, self.req, body=self.body)
|
||||
|
||||
def test_create_instance_metadata_value_too_long(self):
|
||||
self.flags(quota_metadata_items=1)
|
||||
@ -2228,7 +2228,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
self.body['server']['metadata'] = {'key1': ('a' * 260)}
|
||||
self.req.body = jsonutils.dumps(self.body)
|
||||
self.assertRaises(webob.exc.HTTPRequestEntityTooLarge,
|
||||
self.controller.create, self.req, self.body)
|
||||
self.controller.create, self.req, body=self.body)
|
||||
|
||||
def test_create_instance_metadata_key_blank(self):
|
||||
self.flags(quota_metadata_items=1)
|
||||
@ -2237,7 +2237,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
self.body['server']['metadata'] = {'': 'abcd'}
|
||||
self.req.body = jsonutils.dumps(self.body)
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.create, self.req, self.body)
|
||||
self.controller.create, self.req, body=self.body)
|
||||
|
||||
def test_create_instance_metadata_not_dict(self):
|
||||
self.flags(quota_metadata_items=1)
|
||||
@ -2246,7 +2246,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
self.body['server']['metadata'] = 'string'
|
||||
self.req.body = jsonutils.dumps(self.body)
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.create, self.req, self.body)
|
||||
self.controller.create, self.req, body=self.body)
|
||||
|
||||
def test_create_instance_metadata_key_not_string(self):
|
||||
self.flags(quota_metadata_items=1)
|
||||
@ -2255,7 +2255,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
self.body['server']['metadata'] = {1: 'test'}
|
||||
self.req.body = jsonutils.dumps(self.body)
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.create, self.req, self.body)
|
||||
self.controller.create, self.req, body=self.body)
|
||||
|
||||
def test_create_instance_metadata_value_not_string(self):
|
||||
self.flags(quota_metadata_items=1)
|
||||
@ -2264,7 +2264,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
self.body['server']['metadata'] = {'test': ['a', 'list']}
|
||||
self.req.body = jsonutils.dumps(self.body)
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.create, self.req, self.body)
|
||||
self.controller.create, self.req, body=self.body)
|
||||
|
||||
def test_create_user_data_malformed_bad_request(self):
|
||||
params = {'os-user-data:user_data': 'u1234'}
|
||||
@ -2277,12 +2277,12 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
self.body['server']['key_name'] = 'nonexistentkey'
|
||||
self.req.body = jsonutils.dumps(self.body)
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.create, self.req, self.body)
|
||||
self.controller.create, self.req, body=self.body)
|
||||
|
||||
def test_create_instance_valid_key_name(self):
|
||||
self.body['server']['key_name'] = 'key'
|
||||
self.req.body = jsonutils.dumps(self.body)
|
||||
res = self.controller.create(self.req, self.body).obj
|
||||
res = self.controller.create(self.req, body=self.body).obj
|
||||
|
||||
self.assertEqual(FAKE_UUID, res["server"]["id"])
|
||||
self._check_admin_password_len(res["server"])
|
||||
@ -2294,7 +2294,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
self.body['server']['flavor_ref'] = flavor_ref
|
||||
self.req.body = jsonutils.dumps(self.body)
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.create, self.req, self.body)
|
||||
self.controller.create, self.req, body=self.body)
|
||||
|
||||
def test_create_instance_invalid_flavor_id_int(self):
|
||||
image_href = 'http://localhost/v2/images/2'
|
||||
@ -2303,7 +2303,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
self.body['server']['flavor_ref'] = flavor_ref
|
||||
self.req.body = jsonutils.dumps(self.body)
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.create, self.req, self.body)
|
||||
self.controller.create, self.req, body=self.body)
|
||||
|
||||
def test_create_instance_bad_flavor_href(self):
|
||||
image_href = 'http://localhost/v2/images/2'
|
||||
@ -2312,7 +2312,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
self.body['server']['flavor_ref'] = flavor_ref
|
||||
self.req.body = jsonutils.dumps(self.body)
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.create, self.req, self.body)
|
||||
self.controller.create, self.req, body=self.body)
|
||||
|
||||
def test_create_instance_bad_href(self):
|
||||
image_href = 'asdf'
|
||||
@ -2320,11 +2320,11 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
self.req.body = jsonutils.dumps(self.body)
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.create, self.req, self.body)
|
||||
self.controller.create, self.req, body=self.body)
|
||||
|
||||
def test_create_instance_local_href(self):
|
||||
self.req.body = jsonutils.dumps(self.body)
|
||||
res = self.controller.create(self.req, self.body).obj
|
||||
res = self.controller.create(self.req, body=self.body).obj
|
||||
|
||||
server = res['server']
|
||||
self.assertEqual(FAKE_UUID, server['id'])
|
||||
@ -2333,7 +2333,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
self.body['server']['flavor_ref'] = 3
|
||||
self.body['server']['admin_password'] = 'testpass'
|
||||
self.req.body = jsonutils.dumps(self.body)
|
||||
res = self.controller.create(self.req, self.body).obj
|
||||
res = self.controller.create(self.req, body=self.body).obj
|
||||
|
||||
server = res['server']
|
||||
self.assertEqual(server['admin_password'],
|
||||
@ -2344,7 +2344,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
self.body['server']['flavor_ref'] = 3
|
||||
self.body['server']['admin_password'] = 'testpass'
|
||||
self.req.body = jsonutils.dumps(self.body)
|
||||
res = self.controller.create(self.req, self.body).obj
|
||||
res = self.controller.create(self.req, body=self.body).obj
|
||||
|
||||
server = res['server']
|
||||
self.assertIn('admin_password', self.body['server'])
|
||||
@ -2355,12 +2355,12 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
self.req.body = jsonutils.dumps(self.body)
|
||||
|
||||
# The fact that the action doesn't raise is enough validation
|
||||
self.controller.create(self.req, self.body)
|
||||
self.controller.create(self.req, body=self.body)
|
||||
|
||||
def test_create_location(self):
|
||||
selfhref = 'http://localhost/v2/fake/servers/%s' % FAKE_UUID
|
||||
self.req.body = jsonutils.dumps(self.body)
|
||||
robj = self.controller.create(self.req, self.body)
|
||||
robj = self.controller.create(self.req, body=self.body)
|
||||
|
||||
self.assertEqual(robj['Location'], selfhref)
|
||||
|
||||
@ -2370,7 +2370,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
self.body['server']['flavor_ref'] = 3
|
||||
self.req.body = jsonutils.dumps(self.body)
|
||||
try:
|
||||
self.controller.create(self.req, self.body).obj['server']
|
||||
self.controller.create(self.req, body=self.body).obj['server']
|
||||
self.fail('expected quota to be exceeded')
|
||||
except webob.exc.HTTPRequestEntityTooLarge as e:
|
||||
self.assertEqual(e.explanation, expected_msg)
|
||||
@ -2951,7 +2951,7 @@ class ServersInvalidRequestTestCase(test.TestCase):
|
||||
req.method = 'POST'
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.create, req, body)
|
||||
self.controller.create, req, body=body)
|
||||
|
||||
def test_create_server_no_body(self):
|
||||
self._invalid_server_create(body=None)
|
||||
@ -2969,7 +2969,7 @@ class ServersInvalidRequestTestCase(test.TestCase):
|
||||
req.method = 'PUT'
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.update, req, FAKE_UUID, body)
|
||||
self.controller.update, req, FAKE_UUID, body=body)
|
||||
|
||||
def test_update_server_no_body(self):
|
||||
self._invalid_server_create(body=None)
|
||||
|
@ -153,9 +153,9 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
if override_controller:
|
||||
server = override_controller.create(req, body).obj['server']
|
||||
server = override_controller.create(req, body=body).obj['server']
|
||||
else:
|
||||
server = self.controller.create(req, body).obj['server']
|
||||
server = self.controller.create(req, body=body).obj['server']
|
||||
|
||||
def test_create_instance_with_user_data_disabled(self):
|
||||
params = {user_data.ATTRIBUTE_NAME: base64.b64encode('fake')}
|
||||
@ -202,7 +202,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
req.method = 'POST'
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
res = self.controller.create(req, body).obj
|
||||
res = self.controller.create(req, body=body).obj
|
||||
|
||||
server = res['server']
|
||||
self.assertEqual(FAKE_UUID, server['id'])
|
||||
@ -229,4 +229,4 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.create, req, body)
|
||||
self.controller.create, req, body=body)
|
||||
|
Loading…
x
Reference in New Issue
Block a user