]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Merge "Using constant error codes instead of hard-coded"
authorJenkins <jenkins@review.openstack.org>
Sun, 15 Sep 2013 22:46:31 +0000 (22:46 +0000)
committerGerrit Code Review <review@openstack.org>
Sun, 15 Sep 2013 22:46:31 +0000 (22:46 +0000)
1  2 
neutron/tests/unit/test_db_plugin.py

index b89743ccd9c9153ecc2a2e628349866c8ba98354,2b0220dc248074396bb7df5a3fe491230b1bb816..5524002627a0446d1dc83651d2a2e9fbde7c821c
@@@ -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:
                                     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."""