From: Jenkins Date: Sun, 15 Sep 2013 22:46:31 +0000 (+0000) Subject: Merge "Using constant error codes instead of hard-coded" X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=abd3acafd687aca16e0c8dfa1b6013d5f68d8e9a;p=openstack-build%2Fneutron-build.git Merge "Using constant error codes instead of hard-coded" --- abd3acafd687aca16e0c8dfa1b6013d5f68d8e9a diff --cc neutron/tests/unit/test_db_plugin.py index b89743ccd,2b0220dc2..552400262 --- a/neutron/tests/unit/test_db_plugin.py +++ b/neutron/tests/unit/test_db_plugin.py @@@ -2968,25 -3006,9 +3010,26 @@@ class TestSubnetsV2(NeutronDbPluginV2Te 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: + with self.subnet( + network=network, + allocation_pools=[{'start': '10.0.0.100', + 'end': '10.0.0.253'}]) as subnet: + subnet_data = subnet['subnet'] + with self.port( + subnet=subnet, + fixed_ips=[{'subnet_id': subnet_data['id'], + 'ip_address': subnet_data['gateway_ip']}]): + data = {'subnet': {'gateway_ip': '10.0.0.99'}} + req = self.new_update_request('subnets', data, + subnet_data['id']) + res = req.get_response(self.api) + self.assertEqual(res.status_int, 409) + def test_update_subnet_inconsistent_ipv4_gatewayv6(self): with self.network() as network: with self.subnet(network=network) as subnet: @@@ -3452,39 -3480,8 +3501,39 @@@ 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) + with self.network() as network: + subnet = {'network_id': network['network']['id'], + 'cidr': '10.0.2.0/24', + 'ip_version': 4, + 'tenant_id': network['network']['tenant_id'], + 'gateway_ip': '10.0.2.1', + 'dns_nameservers': ['8.8.8.8'], + 'host_routes': [{'destination': '135.207.0.0/16', + 'nexthop': '1.2.3.4'}]} + plugin = NeutronManager.get_plugin() + e = self.assertRaises(exception, + plugin._validate_subnet, + context.get_admin_context( + load_admin_roles=False), + subnet) + self.assertThat( + str(e), + matchers.Not(matchers.Contains('built-in function id'))) + + def test_validate_subnet_dns_nameservers_exhausted(self): + self._helper_test_validate_subnet( + 'max_dns_nameservers', + q_exc.DNSNameServersExhausted) + + def test_validate_subnet_host_routes_exhausted(self): + self._helper_test_validate_subnet( + 'max_subnet_host_routes', + q_exc.HostRoutesExhausted) + class DbModelTestCase(base.BaseTestCase): """DB model tests."""