try:
result_values.append(convert_to(value))
except exceptions.InvalidInput as e:
- raise webob.exc.HTTPUnprocessableEntity(str(e))
+ raise webob.exc.HTTPBadRequest(str(e))
else:
result_values.append(value)
if result_values:
if is_required and attr not in res_dict:
msg = _("Failed to parse request. Required "
" attribute '%s' not specified") % attr
- raise webob.exc.HTTPUnprocessableEntity(msg)
+ raise webob.exc.HTTPBadRequest(msg)
if not attr_vals['allow_post'] and attr in res_dict:
msg = _("Attribute '%s' not allowed in POST" % attr)
- raise webob.exc.HTTPUnprocessableEntity(msg)
+ raise webob.exc.HTTPBadRequest(msg)
if attr_vals['allow_post']:
res_dict[attr] = res_dict.get(attr,
for attr, attr_vals in attr_info.iteritems():
if attr in res_dict and not attr_vals['allow_put']:
msg = _("Cannot update read-only attribute %s") % attr
- raise webob.exc.HTTPUnprocessableEntity(msg)
+ raise webob.exc.HTTPBadRequest(msg)
for attr, attr_vals in attr_info.iteritems():
# Convert values if necessary
msg_dict = dict(attr=attr, reason=res)
msg = _("Invalid input for %(attr)s. "
"Reason: %(reason)s.") % msg_dict
- raise webob.exc.HTTPUnprocessableEntity(msg)
+ raise webob.exc.HTTPBadRequest(msg)
return body
def _validate_network_tenant_ownership(self, request, resource_item):
data = {'port': {'what': 'who', 'tenant_id': _uuid()}}
res = self.api.post_json(_get_path('ports'), data,
expect_errors=True)
- self.assertEqual(res.status_int, 422)
+ self.assertEqual(res.status_int, 400)
def test_create_readonly_attr(self):
data = {'network': {'name': 'net1', 'tenant_id': _uuid(),
'status': "ACTIVE"}}
res = self.api.post_json(_get_path('networks'), data,
expect_errors=True)
- self.assertEqual(res.status_int, 422)
+ self.assertEqual(res.status_int, 400)
def test_create_bulk(self):
data = {'networks': [{'name': 'net1',
data = {'ports': [{'what': 'who', 'tenant_id': _uuid()}]}
res = self.api.post_json(_get_path('ports'), data,
expect_errors=True)
- self.assertEqual(res.status_int, 422)
+ self.assertEqual(res.status_int, 400)
def test_create_bulk_partial_body(self):
data = {'ports': [{'device_id': 'device_1',
{'tenant_id': _uuid()}]}
res = self.api.post_json(_get_path('ports'), data,
expect_errors=True)
- self.assertEqual(res.status_int, 422)
+ self.assertEqual(res.status_int, 400)
def test_create_attr_not_specified(self):
net_id = _uuid()
data = {'network': {'status': "NANANA"}}
res = self.api.put_json(_get_path('networks', id=_uuid()), data,
expect_errors=True)
- self.assertEqual(res.status_int, 422)
+ self.assertEqual(res.status_int, 400)
class V2Views(unittest.TestCase):
'fixed_ips': []}}
port_req = self.new_create_request('ports', data)
res = port_req.get_response(self.api)
- self.assertEquals(res.status_int, 422)
+ self.assertEquals(res.status_int, 400)
def test_default_allocation_expiration(self):
cfg.CONF.set_override('dhcp_lease_duration', 120)
req = self.new_list_request('networks',
params='admin_state_up=fake')
res = req.get_response(self.api)
- self.assertEquals(422, res.status_int)
+ self.assertEquals(400, res.status_int)
def test_show_network(self):
with self.network(name='net1') as net:
allocation_pools=allocation_pools)
self.assertEquals(ctx_manager.exception.code, 400)
- def test_create_subnet_shared_returns_422(self):
+ def test_create_subnet_shared_returns_400(self):
cidr = '10.0.0.0/24'
with self.assertRaises(webob.exc.HTTPClientError) as ctx_manager:
self._test_create_subnet(cidr=cidr,
shared=True)
- self.assertEquals(ctx_manager.exception.code, 422)
+ self.assertEquals(ctx_manager.exception.code, 400)
def test_update_subnet(self):
with self.subnet() as subnet:
self.assertEqual(res['subnet']['gateway_ip'],
data['subnet']['gateway_ip'])
- def test_update_subnet_shared_returns_422(self):
+ def test_update_subnet_shared_returns_400(self):
with self.network(shared=True) as network:
with self.subnet(network=network) as subnet:
data = {'subnet': {'shared': True}}
req = self.new_update_request('subnets', data,
subnet['subnet']['id'])
res = req.get_response(self.api)
- self.assertEqual(res.status_int, 422)
+ self.assertEqual(res.status_int, 400)
def test_show_subnet(self):
with self.network() as network:
subnet_req = self.new_create_request('subnets', data)
res = subnet_req.get_response(self.api)
- self.assertEquals(res.status_int, 422)
+ self.assertEquals(res.status_int, 400)
def test_invalid_subnet(self):
with self.network() as network:
subnet_req = self.new_create_request('subnets', data)
res = subnet_req.get_response(self.api)
- self.assertEquals(res.status_int, 422)
+ self.assertEquals(res.status_int, 400)
def test_invalid_ip_address(self):
with self.network() as network:
subnet_req = self.new_create_request('subnets', data)
res = subnet_req.get_response(self.api)
- self.assertEquals(res.status_int, 422)
+ self.assertEquals(res.status_int, 400)
def test_invalid_uuid(self):
with self.network() as network:
subnet_req = self.new_create_request('subnets', data)
res = subnet_req.get_response(self.api)
- self.assertEquals(res.status_int, 422)
+ self.assertEquals(res.status_int, 400)
def test_create_subnet_with_one_dns(self):
gateway_ip = '10.0.0.1'
private_sub['subnet']['id'],
None)
- def test_create_floatingip_invalid_floating_network_id_returns_422(self):
+ def test_create_floatingip_invalid_floating_network_id_returns_400(self):
# API-level test - no need to create all objects for l3 plugin
res = self._create_floatingip('json', 'iamnotanuuid',
utils.str_uuid(), '192.168.0.1')
- self.assertEqual(res.status_int, 422)
+ self.assertEqual(res.status_int, 400)
- def test_create_floatingip_invalid_floating_port_id_returns_422(self):
+ def test_create_floatingip_invalid_floating_port_id_returns_400(self):
# API-level test - no need to create all objects for l3 plugin
res = self._create_floatingip('json', utils.str_uuid(),
'iamnotanuuid', '192.168.0.1')
- self.assertEqual(res.status_int, 422)
+ self.assertEqual(res.status_int, 400)
- def test_create_floatingip_invalid_fixed_ip_address_returns_422(self):
+ def test_create_floatingip_invalid_fixed_ip_address_returns_400(self):
# API-level test - no need to create all objects for l3 plugin
res = self._create_floatingip('json', utils.str_uuid(),
utils.str_uuid(), 'iamnotnanip')
- self.assertEqual(res.status_int, 422)
+ self.assertEqual(res.status_int, 400)
def test_list_nets_external(self):
with self.network() as n1: