diff --git a/neutron/tests/unit/test_db_plugin.py b/neutron/tests/unit/test_db_plugin.py index b89743ccd9..5524002627 100644 --- a/neutron/tests/unit/test_db_plugin.py +++ b/neutron/tests/unit/test_db_plugin.py @@ -403,7 +403,7 @@ class NeutronDbPluginV2TestCase(testlib_api.WebTestCase): # in a uniform way (we do it differently for ports, subnets, and nets # Things can go wrong - raise HTTP exc with res code only # so it can be caught by unit tests - if res.status_int >= 400: + if res.status_int >= webob.exc.HTTPClientError.code: raise webob.exc.HTTPClientError(code=res.status_int) return self.deserialize(fmt, res) @@ -423,7 +423,7 @@ class NeutronDbPluginV2TestCase(testlib_api.WebTestCase): shared=shared) # Things can go wrong - raise HTTP exc with res code only # so it can be caught by unit tests - if res.status_int >= 400: + if res.status_int >= webob.exc.HTTPClientError.code: raise webob.exc.HTTPClientError(code=res.status_int) return self.deserialize(fmt, res) @@ -431,7 +431,7 @@ class NeutronDbPluginV2TestCase(testlib_api.WebTestCase): res = self._create_port(fmt, net_id, expected_res_status, **kwargs) # Things can go wrong - raise HTTP exc with res code only # so it can be caught by unit tests - if res.status_int >= 400: + if res.status_int >= webob.exc.HTTPClientError.code: raise webob.exc.HTTPClientError(code=res.status_int) return self.deserialize(fmt, res) @@ -490,17 +490,19 @@ class NeutronDbPluginV2TestCase(testlib_api.WebTestCase): patched_plugin.side_effect = second_call return orig(*args, **kwargs) - def _validate_behavior_on_bulk_failure(self, res, collection, errcode=400): + def _validate_behavior_on_bulk_failure( + self, res, collection, + errcode=webob.exc.HTTPClientError.code): self.assertEqual(res.status_int, errcode) req = self.new_list_request(collection) res = req.get_response(self.api) - self.assertEqual(res.status_int, 200) + self.assertEqual(res.status_int, webob.exc.HTTPOk.code) items = self.deserialize(self.fmt, res) self.assertEqual(len(items[collection]), 0) def _validate_behavior_on_bulk_success(self, res, collection, names=['test_0', 'test_1']): - self.assertEqual(res.status_int, 201) + self.assertEqual(res.status_int, webob.exc.HTTPCreated.code) items = self.deserialize(self.fmt, res)[collection] self.assertEqual(len(items), 2) self.assertEqual(items[0]['name'], 'test_0') @@ -691,15 +693,15 @@ class TestBasicGet(NeutronDbPluginV2TestCase): class TestV2HTTPResponse(NeutronDbPluginV2TestCase): def test_create_returns_201(self): res = self._create_network(self.fmt, 'net2', True) - self.assertEqual(res.status_int, 201) + self.assertEqual(res.status_int, webob.exc.HTTPCreated.code) def test_list_returns_200(self): req = self.new_list_request('networks') res = req.get_response(self.api) - self.assertEqual(res.status_int, 200) + self.assertEqual(res.status_int, webob.exc.HTTPOk.code) def _check_list_with_fields(self, res, field_name): - self.assertEqual(res.status_int, 200) + self.assertEqual(res.status_int, webob.exc.HTTPOk.code) body = self.deserialize(self.fmt, res) # further checks: 1 networks self.assertEqual(len(body['networks']), 1) @@ -749,14 +751,14 @@ class TestV2HTTPResponse(NeutronDbPluginV2TestCase): with self.network() as net: req = self.new_show_request('networks', net['network']['id']) res = req.get_response(self.api) - self.assertEqual(res.status_int, 200) + self.assertEqual(res.status_int, webob.exc.HTTPOk.code) def test_delete_returns_204(self): res = self._create_network(self.fmt, 'net1', True) net = self.deserialize(self.fmt, res) req = self.new_delete_request('networks', net['network']['id']) res = req.get_response(self.api) - self.assertEqual(res.status_int, 204) + self.assertEqual(res.status_int, webob.exc.HTTPNoContent.code) def test_update_returns_200(self): with self.network() as net: @@ -764,7 +766,7 @@ class TestV2HTTPResponse(NeutronDbPluginV2TestCase): {'network': {'name': 'steve'}}, net['network']['id']) res = req.get_response(self.api) - self.assertEqual(res.status_int, 200) + self.assertEqual(res.status_int, webob.exc.HTTPOk.code) def test_update_invalid_json_400(self): with self.network() as net: @@ -772,12 +774,12 @@ class TestV2HTTPResponse(NeutronDbPluginV2TestCase): '{{"name": "aaa"}}', net['network']['id']) res = req.get_response(self.api) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, webob.exc.HTTPClientError.code) def test_bad_route_404(self): req = self.new_list_request('doohickeys') res = req.get_response(self.api) - self.assertEqual(res.status_int, 404) + self.assertEqual(res.status_int, webob.exc.HTTPNotFound.code) class TestPortsV2(NeutronDbPluginV2TestCase): @@ -803,14 +805,14 @@ class TestPortsV2(NeutronDbPluginV2TestCase): port_req = self.new_create_request('ports', data) res = port_req.get_response(self.api) - self.assertEqual(res.status_int, 403) + self.assertEqual(res.status_int, webob.exc.HTTPForbidden.code) def test_create_port_public_network(self): keys = [('admin_state_up', True), ('status', self.port_create_status)] with self.network(shared=True) as network: port_res = self._create_port(self.fmt, network['network']['id'], - 201, + webob.exc.HTTPCreated.code, tenant_id='another_tenant', set_context=True) port = self.deserialize(self.fmt, port_res) @@ -828,7 +830,7 @@ class TestPortsV2(NeutronDbPluginV2TestCase): 'ip_address': '10.0.0.2'}])] port_res = self._create_port(self.fmt, network['network']['id'], - 201, + webob.exc.HTTPCreated.code, tenant_id='another_tenant', set_context=True) port = self.deserialize(self.fmt, port_res) @@ -871,10 +873,10 @@ class TestPortsV2(NeutronDbPluginV2TestCase): res = self._create_port_bulk(self.fmt, 2, net['network']['id'], 'test', True, override=overrides) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, webob.exc.HTTPClientError.code) req = self.new_list_request('ports') res = req.get_response(self.api) - self.assertEqual(res.status_int, 200) + self.assertEqual(res.status_int, webob.exc.HTTPOk.code) ports = self.deserialize(self.fmt, res) self.assertEqual(len(ports['ports']), 0) @@ -904,7 +906,9 @@ class TestPortsV2(NeutronDbPluginV2TestCase): 'test', True) # We expect a 500 as we injected a fault in the plugin - self._validate_behavior_on_bulk_failure(res, 'ports', 500) + self._validate_behavior_on_bulk_failure( + res, 'ports', webob.exc.HTTPServerError.code + ) def test_create_ports_bulk_native_plugin_failure(self): if self._skip_native_bulk: @@ -923,7 +927,8 @@ class TestPortsV2(NeutronDbPluginV2TestCase): res = self._create_port_bulk(self.fmt, 2, net['network']['id'], 'test', True, context=ctx) # We expect a 500 as we injected a fault in the plugin - self._validate_behavior_on_bulk_failure(res, 'ports', 500) + self._validate_behavior_on_bulk_failure( + res, 'ports', webob.exc.HTTPServerError.code) def test_list_ports(self): # for this test we need to enable overlapping ips @@ -1068,13 +1073,13 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s with self.port() as port: req = self.new_show_request('port', self.fmt, port['port']['id']) res = req.get_response(self.api) - self.assertEqual(res.status_int, 404) + self.assertEqual(res.status_int, webob.exc.HTTPNotFound.code) def test_delete_port_public_network(self): with self.network(shared=True) as network: port_res = self._create_port(self.fmt, network['network']['id'], - 201, + webob.exc.HTTPCreated.code, tenant_id='another_tenant', set_context=True) @@ -1110,14 +1115,14 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s data = {'port': {'device_id': None}} req = self.new_update_request('ports', data, port['port']['id']) res = req.get_response(self.api) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, webob.exc.HTTPClientError.code) def test_delete_network_if_port_exists(self): with self.port() as port: req = self.new_delete_request('networks', port['port']['network_id']) res = req.get_response(self.api) - self.assertEqual(res.status_int, 409) + self.assertEqual(res.status_int, webob.exc.HTTPConflict.code) def test_delete_network_port_exists_owned_by_network(self): res = self._create_network(fmt=self.fmt, name='net', @@ -1127,7 +1132,7 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s self._create_port(self.fmt, network_id, device_owner='network:dhcp') req = self.new_delete_request('networks', network_id) res = req.get_response(self.api) - self.assertEqual(res.status_int, 204) + self.assertEqual(res.status_int, webob.exc.HTTPNoContent.code) def test_update_port_delete_ip(self): with self.subnet() as subnet: @@ -1149,7 +1154,7 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s data = self.deserialize(self.fmt, res) msg = str(q_exc.IpAddressGenerationFailure(net_id=id)) self.assertEqual(data['NeutronError'], msg) - self.assertEqual(res.status_int, 409) + self.assertEqual(res.status_int, webob.exc.HTTPConflict.code) def test_update_port_update_ip(self): """Test update of port IP. @@ -1246,7 +1251,7 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s kwargs = {"mac_address": mac} net_id = port['port']['network_id'] res = self._create_port(self.fmt, net_id=net_id, **kwargs) - self.assertEqual(res.status_int, 409) + self.assertEqual(res.status_int, webob.exc.HTTPConflict.code) def test_mac_generation(self): cfg.CONF.set_override('base_mac', "12:34:56:00:00:00") @@ -1282,7 +1287,8 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s network = self.deserialize(self.fmt, res) net_id = network['network']['id'] res = self._create_port(self.fmt, net_id=net_id) - self.assertEqual(res.status_int, 503) + self.assertEqual(res.status_int, + webob.exc.HTTPServiceUnavailable.code) def test_requested_duplicate_ip(self): with self.subnet() as subnet: @@ -1296,7 +1302,7 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s 'ip_address': ips[0]['ip_address']}]} net_id = port['port']['network_id'] res = self._create_port(self.fmt, net_id=net_id, **kwargs) - self.assertEqual(res.status_int, 409) + self.assertEqual(res.status_int, webob.exc.HTTPConflict.code) def test_requested_subnet_delete(self): with self.subnet() as subnet: @@ -1308,7 +1314,7 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s req = self.new_delete_request('subnet', subnet['subnet']['id']) res = req.get_response(self.api) - self.assertEqual(res.status_int, 404) + self.assertEqual(res.status_int, webob.exc.HTTPNotFound.code) def test_requested_subnet_id(self): with self.subnet() as subnet: @@ -1343,7 +1349,8 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s subnet2['subnet']['id']}]} net_id = port['port']['network_id'] res = self._create_port(self.fmt, net_id=net_id, **kwargs) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, + webob.exc.HTTPClientError.code) def test_overlapping_subnets(self): with self.subnet() as subnet: @@ -1355,7 +1362,7 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s cidr='10.0.0.225/28', ip_version=4, gateway_ip=ATTR_NOT_SPECIFIED) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, webob.exc.HTTPClientError.code) def test_requested_subnet_id_v4_and_v6(self): with self.subnet() as subnet: @@ -1454,7 +1461,7 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s net_id = port['port']['network_id'] res = self._create_port(self.fmt, net_id=net_id, **kwargs) port2 = self.deserialize(self.fmt, res) - self.assertEqual(res.status_int, 404) + self.assertEqual(res.status_int, webob.exc.HTTPNotFound.code) # Test invalid IP address on specified subnet_id kwargs = {"fixed_ips": @@ -1463,7 +1470,8 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s net_id = port['port']['network_id'] res = self._create_port(self.fmt, net_id=net_id, **kwargs) port2 = self.deserialize(self.fmt, res) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, + webob.exc.HTTPClientError.code) # Test invalid addresses - IP's not on subnet or network # address or broadcast address @@ -1473,7 +1481,8 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s kwargs = {"fixed_ips": [{'ip_address': ip}]} res = self._create_port(self.fmt, net_id=net_id, **kwargs) port2 = self.deserialize(self.fmt, res) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, + webob.exc.HTTPClientError.code) # Enable allocation of gateway address kwargs = {"fixed_ips": @@ -1495,7 +1504,7 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s 'ip_address': '1011.0.0.5'}]} net_id = subnet['subnet']['network_id'] res = self._create_port(self.fmt, net_id=net_id, **kwargs) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, webob.exc.HTTPClientError.code) def test_requested_split(self): with self.subnet() as subnet: @@ -1541,7 +1550,7 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s 'ip_address': '10.0.0.5'}]} net_id = subnet['subnet']['network_id'] res = self._create_port(self.fmt, net_id=net_id, **kwargs) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, webob.exc.HTTPClientError.code) def test_fixed_ip_invalid_subnet_id(self): with self.subnet() as subnet: @@ -1550,7 +1559,7 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s 'ip_address': '10.0.0.5'}]} net_id = subnet['subnet']['network_id'] res = self._create_port(self.fmt, net_id=net_id, **kwargs) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, webob.exc.HTTPClientError.code) def test_fixed_ip_invalid_ip(self): with self.subnet() as subnet: @@ -1559,7 +1568,7 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s 'ip_address': '10.0.0.55555'}]} net_id = subnet['subnet']['network_id'] res = self._create_port(self.fmt, net_id=net_id, **kwargs) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, webob.exc.HTTPClientError.code) def test_requested_ips_only(self): with self.subnet() as subnet: @@ -1626,7 +1635,7 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s 'fixed_ips': []}} port_req = self.new_create_request('ports', data) res = port_req.get_response(self.api) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, webob.exc.HTTPClientError.code) def test_invalid_mac_address(self): with self.network() as network: @@ -1637,7 +1646,7 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s 'fixed_ips': []}} port_req = self.new_create_request('ports', data) res = port_req.get_response(self.api) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, webob.exc.HTTPClientError.code) def test_update_fixed_ip_lease_expiration_invalid_address(self): cfg.CONF.set_override('dhcp_lease_duration', 10) @@ -1687,7 +1696,8 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s {'subnet_id': subnet['subnet']['id']}]} net_id = subnet['subnet']['network_id'] res = self._create_port(self.fmt, net_id=net_id, **kwargs) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, + webob.exc.HTTPClientError.code) def test_update_max_fixed_ips_exceeded(self): with self.subnet(gateway_ip='10.0.0.3', @@ -1705,7 +1715,8 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s req = self.new_update_request('ports', data, port['port']['id']) res = req.get_response(self.api) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, + webob.exc.HTTPClientError.code) class TestNetworksV2(NeutronDbPluginV2TestCase): @@ -1736,7 +1747,8 @@ class TestNetworksV2(NeutronDbPluginV2TestCase): tenant_id="another_tenant", set_context=True): pass - self.assertEqual(ctx_manager.exception.code, 403) + self.assertEqual(ctx_manager.exception.code, + webob.exc.HTTPForbidden.code) def test_update_network(self): with self.network() as network: @@ -1757,7 +1769,7 @@ class TestNetworksV2(NeutronDbPluginV2TestCase): req.environ['neutron.context'] = context.Context('', 'somebody') res = req.get_response(self.api) # The API layer always returns 404 on updates in place of 403 - self.assertEqual(res.status_int, 404) + self.assertEqual(res.status_int, webob.exc.HTTPNotFound.code) def test_update_network_set_shared(self): with self.network(shared=False) as network: @@ -1788,7 +1800,7 @@ class TestNetworksV2(NeutronDbPluginV2TestCase): with self.network(shared=True) as network: res1 = self._create_port(self.fmt, network['network']['id'], - 201, + webob.exc.HTTPCreated.code, tenant_id=network['network']['tenant_id'], set_context=True) data = {'network': {'shared': False}} @@ -1804,14 +1816,15 @@ class TestNetworksV2(NeutronDbPluginV2TestCase): with self.network(shared=True) as network: res1 = self._create_port(self.fmt, network['network']['id'], - 201, + webob.exc.HTTPCreated.code, tenant_id='somebody_else', set_context=True) data = {'network': {'shared': False}} req = self.new_update_request('networks', data, network['network']['id']) - self.assertEqual(req.get_response(self.api).status_int, 409) + self.assertEqual(req.get_response(self.api).status_int, + webob.exc.HTTPConflict.code) port1 = self.deserialize(self.fmt, res1) self._delete('ports', port1['port']['id']) @@ -1819,19 +1832,20 @@ class TestNetworksV2(NeutronDbPluginV2TestCase): with self.network(shared=True) as network: res1 = self._create_port(self.fmt, network['network']['id'], - 201, + webob.exc.HTTPCreated.code, tenant_id='somebody_else', set_context=True) res2 = self._create_port(self.fmt, network['network']['id'], - 201, + webob.exc.HTTPCreated.code, tenant_id=network['network']['tenant_id'], set_context=True) data = {'network': {'shared': False}} req = self.new_update_request('networks', data, network['network']['id']) - self.assertEqual(req.get_response(self.api).status_int, 409) + self.assertEqual(req.get_response(self.api).status_int, + webob.exc.HTTPConflict.code) port1 = self.deserialize(self.fmt, res1) port2 = self.deserialize(self.fmt, res2) self._delete('ports', port1['port']['id']) @@ -1841,20 +1855,21 @@ class TestNetworksV2(NeutronDbPluginV2TestCase): with self.network(shared=True) as network: res1 = self._create_port(self.fmt, network['network']['id'], - 201, + webob.exc.HTTPCreated.code, tenant_id='somebody_else', set_context=True) self._create_subnet(self.fmt, network['network']['id'], '10.0.0.0/24', - 201, + webob.exc.HTTPCreated.code, tenant_id=network['network']['tenant_id'], set_context=True) data = {'network': {'shared': False}} req = self.new_update_request('networks', data, network['network']['id']) - self.assertEqual(req.get_response(self.api).status_int, 409) + self.assertEqual(req.get_response(self.api).status_int, + webob.exc.HTTPConflict.code) port1 = self.deserialize(self.fmt, res1) self._delete('ports', port1['port']['id']) @@ -1871,7 +1886,9 @@ class TestNetworksV2(NeutronDbPluginV2TestCase): quota = 4 cfg.CONF.set_override('quota_network', quota, group='QUOTAS') res = self._create_network_bulk(self.fmt, quota + 1, 'test', True) - self._validate_behavior_on_bulk_failure(res, 'networks', errcode=409) + self._validate_behavior_on_bulk_failure( + res, 'networks', + errcode=webob.exc.HTTPConflict.code) def test_create_networks_bulk_tenants_and_quotas(self): if self._skip_native_bulk: @@ -1888,7 +1905,7 @@ class TestNetworksV2(NeutronDbPluginV2TestCase): 'tenant_id': 't1'}}] res = self._create_bulk_from_list(self.fmt, 'network', networks) - self.assertEqual(res.status_int, 201) + self.assertEqual(res.status_int, webob.exc.HTTPCreated.code) def test_create_networks_bulk_tenants_and_quotas_fail(self): if self._skip_native_bulk: @@ -1907,7 +1924,7 @@ class TestNetworksV2(NeutronDbPluginV2TestCase): 'tenant_id': 't1'}}] res = self._create_bulk_from_list(self.fmt, 'network', networks) - self.assertEqual(res.status_int, 409) + self.assertEqual(res.status_int, webob.exc.HTTPConflict.code) def test_create_networks_bulk_emulated(self): real_has_attr = hasattr @@ -1927,10 +1944,10 @@ class TestNetworksV2(NeutronDbPluginV2TestCase): res = self._create_network_bulk(self.fmt, 2, 'test', True, override={1: {'admin_state_up': 'doh'}}) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, webob.exc.HTTPClientError.code) req = self.new_list_request('networks') res = req.get_response(self.api) - self.assertEqual(res.status_int, 200) + self.assertEqual(res.status_int, webob.exc.HTTPOk.code) nets = self.deserialize(self.fmt, res) self.assertEqual(len(nets['networks']), 0) @@ -1956,7 +1973,9 @@ class TestNetworksV2(NeutronDbPluginV2TestCase): patched_plugin.side_effect = side_effect res = self._create_network_bulk(self.fmt, 2, 'test', True) # We expect a 500 as we injected a fault in the plugin - self._validate_behavior_on_bulk_failure(res, 'networks', 500) + self._validate_behavior_on_bulk_failure( + res, 'networks', webob.exc.HTTPServerError.code + ) def test_create_networks_bulk_native_plugin_failure(self): if self._skip_native_bulk: @@ -1972,7 +1991,9 @@ class TestNetworksV2(NeutronDbPluginV2TestCase): patched_plugin.side_effect = side_effect res = self._create_network_bulk(self.fmt, 2, 'test', True) # We expect a 500 as we injected a fault in the plugin - self._validate_behavior_on_bulk_failure(res, 'networks', 500) + self._validate_behavior_on_bulk_failure( + res, 'networks', webob.exc.HTTPServerError.code + ) def test_list_networks(self): with contextlib.nested(self.network(), @@ -2008,7 +2029,7 @@ class TestNetworksV2(NeutronDbPluginV2TestCase): 'networks', params='sort_key=provider:segmentation_id&sort_dir=asc') res = req.get_response(self.api) - self.assertEqual(400, res.status_int) + self.assertEqual(webob.exc.HTTPClientError.code, res.status_int) def test_list_networks_with_sort_remote_key_native_returns_400(self): if self._skip_native_sorting: @@ -2023,7 +2044,7 @@ class TestNetworksV2(NeutronDbPluginV2TestCase): req = self.new_list_request( 'networks', params='sort_key=subnets&sort_dir=asc') res = req.get_response(self.api) - self.assertEqual(400, res.status_int) + self.assertEqual(webob.exc.HTTPClientError.code, res.status_int) def test_list_networks_with_sort_emulated(self): helper_patcher = mock.patch( @@ -2161,7 +2182,7 @@ class TestNetworksV2(NeutronDbPluginV2TestCase): req = self.new_list_request('networks', params='admin_state_up=fake') res = req.get_response(self.api) - self.assertEqual(400, res.status_int) + self.assertEqual(webob.exc.HTTPClientError.code, res.status_int) def test_list_shared_networks_with_non_admin_user(self): with contextlib.nested(self.network(shared=False, @@ -2195,10 +2216,15 @@ class TestNetworksV2(NeutronDbPluginV2TestCase): subnet['subnet']['id']) def test_invalid_admin_status(self): - value = [[7, False, 400], [True, True, 201], ["True", True, 201], - ["true", True, 201], [1, True, 201], ["False", False, 201], - [False, False, 201], ["false", False, 201], - ["7", False, 400]] + value = [[7, False, webob.exc.HTTPClientError.code], + [True, True, webob.exc.HTTPCreated.code], + ["True", True, webob.exc.HTTPCreated.code], + ["true", True, webob.exc.HTTPCreated.code], + [1, True, webob.exc.HTTPCreated.code], + ["False", False, webob.exc.HTTPCreated.code], + [False, False, webob.exc.HTTPCreated.code], + ["false", False, webob.exc.HTTPCreated.code], + ["7", False, webob.exc.HTTPClientError.code]] for v in value: data = {'network': {'name': 'net', 'admin_state_up': v[0], @@ -2206,7 +2232,7 @@ class TestNetworksV2(NeutronDbPluginV2TestCase): network_req = self.new_create_request('networks', data) req = network_req.get_response(self.api) self.assertEqual(req.status_int, v[2]) - if v[2] == 201: + if v[2] == webob.exc.HTTPCreated.code: res = self.deserialize(self.fmt, req) self.assertEqual(res['network']['admin_state_up'], v[1]) @@ -2283,7 +2309,8 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): gateway_ip=gateway_ip_2, cidr=cidr_2): pass - self.assertEqual(ctx_manager.exception.code, 400) + self.assertEqual(ctx_manager.exception.code, + webob.exc.HTTPClientError.code) def test_create_subnet_bad_V4_cidr(self): with self.network() as network: @@ -2294,7 +2321,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): 'gateway_ip': '10.0.2.1'}} subnet_req = self.new_create_request('subnets', data) res = subnet_req.get_response(self.api) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, webob.exc.HTTPClientError.code) def test_create_subnet_bad_V6_cidr(self): with self.network() as network: @@ -2305,7 +2332,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): 'gateway_ip': 'fe80::1'}} subnet_req = self.new_create_request('subnets', data) res = subnet_req.get_response(self.api) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, webob.exc.HTTPClientError.code) def test_create_2_subnets_overlapping_cidr_allowed_returns_200(self): cidr_1 = '10.0.0.0/23' @@ -2325,7 +2352,8 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): with contextlib.nested(self.subnet(cidr=cidr_1), self.subnet(cidr=cidr_2)): pass - self.assertEqual(ctx_manager.exception.code, 400) + self.assertEqual(ctx_manager.exception.code, + webob.exc.HTTPClientError.code) def test_create_subnets_bulk_native(self): if self._skip_native_bulk: @@ -2377,7 +2405,9 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): net['network']['id'], 'test') # We expect a 500 as we injected a fault in the plugin - self._validate_behavior_on_bulk_failure(res, 'subnets', 500) + self._validate_behavior_on_bulk_failure( + res, 'subnets', webob.exc.HTTPServerError.code + ) def test_create_subnets_bulk_native_plugin_failure(self): if self._skip_native_bulk: @@ -2396,7 +2426,9 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): 'test') # We expect a 500 as we injected a fault in the plugin - self._validate_behavior_on_bulk_failure(res, 'subnets', 500) + self._validate_behavior_on_bulk_failure( + res, 'subnets', webob.exc.HTTPServerError.code + ) def test_delete_subnet(self): gateway_ip = '10.0.0.1' @@ -2409,7 +2441,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): cidr, ip_version=4) req = self.new_delete_request('subnets', subnet['subnet']['id']) res = req.get_response(self.api) - self.assertEqual(res.status_int, 204) + self.assertEqual(res.status_int, webob.exc.HTTPNoContent.code) def test_delete_subnet_port_exists_owned_by_network(self): gateway_ip = '10.0.0.1' @@ -2425,7 +2457,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): device_owner='network:dhcp') req = self.new_delete_request('subnets', subnet['subnet']['id']) res = req.get_response(self.api) - self.assertEqual(res.status_int, 204) + self.assertEqual(res.status_int, webob.exc.HTTPNoContent.code) def test_delete_subnet_port_exists_owned_by_other(self): with self.subnet() as subnet: @@ -2434,7 +2466,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): req = self.new_delete_request('subnets', id) res = req.get_response(self.api) data = self.deserialize(self.fmt, res) - self.assertEqual(res.status_int, 409) + self.assertEqual(res.status_int, webob.exc.HTTPConflict.code) msg = str(q_exc.SubnetInUse(subnet_id=id)) self.assertEqual(data['NeutronError'], msg) @@ -2448,7 +2480,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): self._make_subnet(self.fmt, network, gateway_ip, cidr, ip_version=4) req = self.new_delete_request('networks', network['network']['id']) res = req.get_response(self.api) - self.assertEqual(res.status_int, 204) + self.assertEqual(res.status_int, webob.exc.HTTPNoContent.code) def test_create_subnet_bad_tenant(self): with self.network() as network: @@ -2460,7 +2492,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): subnet_req = self.new_create_request('subnets', data) res = subnet_req.get_response(self.api) - self.assertEqual(res.status_int, 403) + self.assertEqual(res.status_int, webob.exc.HTTPForbidden.code) def test_create_subnet_bad_cidr(self): with self.network() as network: @@ -2483,7 +2515,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): 'gateway_ip': '10.0.2.1'}} subnet_req = self.new_create_request('subnets', data) res = subnet_req.get_response(self.api) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, webob.exc.HTTPClientError.code) def test_create_subnet_bad_ip_version_null(self): with self.network() as network: @@ -2495,7 +2527,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): 'gateway_ip': '10.0.2.1'}} subnet_req = self.new_create_request('subnets', data) res = subnet_req.get_response(self.api) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, webob.exc.HTTPClientError.code) def test_create_subnet_bad_uuid(self): with self.network() as network: @@ -2507,7 +2539,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): 'gateway_ip': '10.0.2.1'}} subnet_req = self.new_create_request('subnets', data) res = subnet_req.get_response(self.api) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, webob.exc.HTTPClientError.code) def test_create_subnet_bad_boolean(self): with self.network() as network: @@ -2520,7 +2552,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): 'gateway_ip': '10.0.2.1'}} subnet_req = self.new_create_request('subnets', data) res = subnet_req.get_response(self.api) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, webob.exc.HTTPClientError.code) def test_create_subnet_bad_pools(self): with self.network() as network: @@ -2543,7 +2575,8 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): 'allocation_pools': pool}} subnet_req = self.new_create_request('subnets', data) res = subnet_req.get_response(self.api) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, + webob.exc.HTTPClientError.code) def test_create_subnet_bad_nameserver(self): with self.network() as network: @@ -2561,7 +2594,8 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): 'dns_nameservers': nameservers}} subnet_req = self.new_create_request('subnets', data) res = subnet_req.get_response(self.api) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, + webob.exc.HTTPClientError.code) def test_create_subnet_bad_hostroutes(self): with self.network() as network: @@ -2582,7 +2616,8 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): 'host_routes': hostroutes}} subnet_req = self.new_create_request('subnets', data) res = subnet_req.get_response(self.api) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, + webob.exc.HTTPClientError.code) def test_create_subnet_defaults(self): gateway = '10.0.0.1' @@ -2632,7 +2667,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): self._create_subnet(self.fmt, network['network']['id'], '10.0.0.0/24', - 400, + webob.exc.HTTPClientError.code, gateway_ip='100.0.0.1') def test_create_subnet_gw_of_network_force_on_returns_400(self): @@ -2641,7 +2676,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): self._create_subnet(self.fmt, network['network']['id'], '10.0.0.0/24', - 400, + webob.exc.HTTPClientError.code, gateway_ip='10.0.0.0') def test_create_subnet_gw_bcast_force_on_returns_400(self): @@ -2650,7 +2685,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): self._create_subnet(self.fmt, network['network']['id'], '10.0.0.0/24', - 400, + webob.exc.HTTPClientError.code, gateway_ip='10.0.0.255') def test_create_subnet_with_allocation_pool(self): @@ -2693,7 +2728,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): kwargs = {"fixed_ips": [{'subnet_id': subnet['subnet']['id'], 'ip_address': '10.0.0.10'}]} res = self._create_port(self.fmt, net_id=net_id, **kwargs) - self.assertEqual(res.status_int, 201) + self.assertEqual(res.status_int, webob.exc.HTTPCreated.code) port = self.deserialize(self.fmt, res) # delete the port self._delete('ports', port['port']['id']) @@ -2702,7 +2737,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): kwargs = {"fixed_ips": [{'subnet_id': subnet['subnet']['id'], 'ip_address': '10.0.0.1'}]} res = self._create_port(self.fmt, net_id=net_id, **kwargs) - self.assertEqual(res.status_int, 201) + self.assertEqual(res.status_int, webob.exc.HTTPCreated.code) port = self.deserialize(self.fmt, res) # delete the port self._delete('ports', port['port']['id']) @@ -2760,7 +2795,8 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): webob.exc.HTTPClientError) as ctx_manager: self._test_create_subnet(cidr=cidr, allocation_pools=allocation_pools) - self.assertEqual(ctx_manager.exception.code, 409) + self.assertEqual(ctx_manager.exception.code, + webob.exc.HTTPConflict.code) def test_create_subnet_gateway_in_allocation_pool_returns_409(self): gateway_ip = '10.0.0.50' @@ -2772,7 +2808,8 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): self._test_create_subnet(gateway_ip=gateway_ip, cidr=cidr, allocation_pools=allocation_pools) - self.assertEqual(ctx_manager.exception.code, 409) + self.assertEqual(ctx_manager.exception.code, + webob.exc.HTTPConflict.code) def test_create_subnet_overlapping_allocation_pools_returns_409(self): gateway_ip = '10.0.0.1' @@ -2786,7 +2823,8 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): self._test_create_subnet(gateway_ip=gateway_ip, cidr=cidr, allocation_pools=allocation_pools) - self.assertEqual(ctx_manager.exception.code, 409) + self.assertEqual(ctx_manager.exception.code, + webob.exc.HTTPConflict.code) def test_create_subnet_invalid_allocation_pool_returns_400(self): gateway_ip = '10.0.0.1' @@ -2798,7 +2836,8 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): self._test_create_subnet(gateway_ip=gateway_ip, cidr=cidr, allocation_pools=allocation_pools) - self.assertEqual(ctx_manager.exception.code, 400) + self.assertEqual(ctx_manager.exception.code, + webob.exc.HTTPClientError.code) def test_create_subnet_out_of_range_allocation_pool_returns_400(self): gateway_ip = '10.0.0.1' @@ -2810,7 +2849,8 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): self._test_create_subnet(gateway_ip=gateway_ip, cidr=cidr, allocation_pools=allocation_pools) - self.assertEqual(ctx_manager.exception.code, 400) + self.assertEqual(ctx_manager.exception.code, + webob.exc.HTTPClientError.code) def test_create_subnet_shared_returns_400(self): cidr = '10.0.0.0/24' @@ -2818,7 +2858,8 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): webob.exc.HTTPClientError) as ctx_manager: self._test_create_subnet(cidr=cidr, shared=True) - self.assertEqual(ctx_manager.exception.code, 400) + self.assertEqual(ctx_manager.exception.code, + webob.exc.HTTPClientError.code) def test_create_subnet_inconsistent_ipv6_cidrv4(self): with self.network() as network: @@ -2828,7 +2869,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): 'tenant_id': network['network']['tenant_id']}} subnet_req = self.new_create_request('subnets', data) res = subnet_req.get_response(self.api) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, webob.exc.HTTPClientError.code) def test_create_subnet_inconsistent_ipv4_cidrv6(self): with self.network() as network: @@ -2838,7 +2879,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): 'tenant_id': network['network']['tenant_id']}} subnet_req = self.new_create_request('subnets', data) res = subnet_req.get_response(self.api) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, webob.exc.HTTPClientError.code) def test_create_subnet_inconsistent_ipv4_gatewayv6(self): with self.network() as network: @@ -2849,7 +2890,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): 'tenant_id': network['network']['tenant_id']}} subnet_req = self.new_create_request('subnets', data) res = subnet_req.get_response(self.api) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, webob.exc.HTTPClientError.code) def test_create_subnet_inconsistent_ipv6_gatewayv4(self): with self.network() as network: @@ -2860,7 +2901,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): 'tenant_id': network['network']['tenant_id']}} subnet_req = self.new_create_request('subnets', data) res = subnet_req.get_response(self.api) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, webob.exc.HTTPClientError.code) def test_create_subnet_inconsistent_ipv6_dns_v4(self): with self.network() as network: @@ -2871,7 +2912,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): 'tenant_id': network['network']['tenant_id']}} subnet_req = self.new_create_request('subnets', data) res = subnet_req.get_response(self.api) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, webob.exc.HTTPClientError.code) def test_create_subnet_inconsistent_ipv4_hostroute_dst_v6(self): host_routes = [{'destination': 'fe80::0/48', @@ -2884,7 +2925,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): 'tenant_id': network['network']['tenant_id']}} subnet_req = self.new_create_request('subnets', data) res = subnet_req.get_response(self.api) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, webob.exc.HTTPClientError.code) def test_create_subnet_inconsistent_ipv4_hostroute_np_v6(self): host_routes = [{'destination': '172.16.0.0/24', @@ -2897,7 +2938,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): 'tenant_id': network['network']['tenant_id']}} subnet_req = self.new_create_request('subnets', data) res = subnet_req.get_response(self.api) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, webob.exc.HTTPClientError.code) def test_update_subnet_no_gateway(self): with self.subnet() as subnet: @@ -2958,7 +2999,8 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): req = self.new_update_request('subnets', data, subnet['subnet']['id']) res = req.get_response(self.api) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, + webob.exc.HTTPClientError.code) def test_update_subnet_gw_outside_cidr_force_on_returns_400(self): cfg.CONF.set_override('force_gateway_on_subnet', True) @@ -2968,7 +3010,8 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): req = self.new_update_request('subnets', data, subnet['subnet']['id']) res = req.get_response(self.api) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, + webob.exc.HTTPClientError.code) def test_update_subnet_gw_ip_in_use_returns_409(self): with self.network() as network: @@ -2994,7 +3037,8 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): req = self.new_update_request('subnets', data, subnet['subnet']['id']) res = req.get_response(self.api) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, + webob.exc.HTTPClientError.code) def test_update_subnet_inconsistent_ipv6_gatewayv4(self): with self.network() as network: @@ -3004,7 +3048,8 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): req = self.new_update_request('subnets', data, subnet['subnet']['id']) res = req.get_response(self.api) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, + webob.exc.HTTPClientError.code) def test_update_subnet_inconsistent_ipv4_dns_v6(self): dns_nameservers = ['fe80::1'] @@ -3014,7 +3059,8 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): req = self.new_update_request('subnets', data, subnet['subnet']['id']) res = req.get_response(self.api) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, + webob.exc.HTTPClientError.code) def test_update_subnet_inconsistent_ipv6_hostroute_dst_v4(self): host_routes = [{'destination': 'fe80::0/48', @@ -3026,7 +3072,8 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): req = self.new_update_request('subnets', data, subnet['subnet']['id']) res = req.get_response(self.api) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, + webob.exc.HTTPClientError.code) def test_update_subnet_inconsistent_ipv6_hostroute_np_v4(self): host_routes = [{'destination': '172.16.0.0/24', @@ -3038,7 +3085,8 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): req = self.new_update_request('subnets', data, subnet['subnet']['id']) res = req.get_response(self.api) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, + webob.exc.HTTPClientError.code) def test_update_subnet_gateway_in_allocation_pool_returns_409(self): allocation_pools = [{'start': '10.0.0.2', 'end': '10.0.0.254'}] @@ -3050,7 +3098,8 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): req = self.new_update_request('subnets', data, subnet['subnet']['id']) res = req.get_response(self.api) - self.assertEqual(res.status_int, 409) + self.assertEqual(res.status_int, + webob.exc.HTTPConflict.code) def test_show_subnet(self): with self.network() as network: @@ -3215,7 +3264,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): subnet_req = self.new_create_request('subnets', data) res = subnet_req.get_response(self.api) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, webob.exc.HTTPClientError.code) def test_invalid_subnet(self): with self.network() as network: @@ -3227,7 +3276,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): subnet_req = self.new_create_request('subnets', data) res = subnet_req.get_response(self.api) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, webob.exc.HTTPClientError.code) def test_invalid_ip_address(self): with self.network() as network: @@ -3239,7 +3288,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): subnet_req = self.new_create_request('subnets', data) res = subnet_req.get_response(self.api) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, webob.exc.HTTPClientError.code) def test_invalid_uuid(self): with self.network() as network: @@ -3251,7 +3300,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): subnet_req = self.new_create_request('subnets', data) res = subnet_req.get_response(self.api) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, webob.exc.HTTPClientError.code) def test_create_subnet_with_one_dns(self): gateway_ip = '10.0.0.1' @@ -3287,7 +3336,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): subnet_req = self.new_create_request('subnets', data) res = subnet_req.get_response(self.api) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, webob.exc.HTTPClientError.code) def test_create_subnet_with_one_host_route(self): gateway_ip = '10.0.0.1' @@ -3334,7 +3383,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): subnet_req = self.new_create_request('subnets', data) res = subnet_req.get_response(self.api) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, webob.exc.HTTPClientError.code) def test_update_subnet_dns(self): with self.subnet() as subnet: @@ -3366,7 +3415,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): req = self.new_update_request('subnets', data, subnet['subnet']['id']) res = req.get_response(self.api) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, webob.exc.HTTPClientError.code) def test_update_subnet_route(self): with self.subnet() as subnet: @@ -3403,7 +3452,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): req = self.new_update_request('subnets', data, subnet['subnet']['id']) res = req.get_response(self.api) - self.assertEqual(res.status_int, 400) + self.assertEqual(res.status_int, webob.exc.HTTPClientError.code) def test_delete_subnet_with_dns(self): gateway_ip = '10.0.0.1' @@ -3418,7 +3467,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): dns_nameservers=dns_nameservers) req = self.new_delete_request('subnets', subnet['subnet']['id']) res = req.get_response(self.api) - self.assertEqual(res.status_int, 204) + self.assertEqual(res.status_int, webob.exc.HTTPNoContent.code) def test_delete_subnet_with_route(self): gateway_ip = '10.0.0.1' @@ -3434,7 +3483,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): host_routes=host_routes) req = self.new_delete_request('subnets', subnet['subnet']['id']) res = req.get_response(self.api) - self.assertEqual(res.status_int, 204) + self.assertEqual(res.status_int, webob.exc.HTTPNoContent.code) def test_delete_subnet_with_dns_and_route(self): gateway_ip = '10.0.0.1' @@ -3452,7 +3501,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): host_routes=host_routes) req = self.new_delete_request('subnets', subnet['subnet']['id']) res = req.get_response(self.api) - self.assertEqual(res.status_int, 204) + self.assertEqual(res.status_int, webob.exc.HTTPNoContent.code) def _helper_test_validate_subnet(self, option, exception): cfg.CONF.set_override(option, 0)