'enforce_policy': True,
'is_visible': True},
SEGMENTATION_ID: {'allow_post': True, 'allow_put': True,
- 'convert_to': int,
+ 'convert_to': attributes.convert_to_int,
'enforce_policy': True,
'default': attributes.ATTR_NOT_SPECIFIED,
'is_visible': True},
expect_errors=expect_errors)
return res, data
+ def _post_network_with_bad_provider_attrs(self, ctx, bad_data,
+ expect_errors=False):
+ data = self._prepare_net_data()
+ data.update(bad_data)
+ env = {'neutron.context': ctx}
+ res = self.api.post(test_api_v2._get_path('networks', fmt=self.fmt),
+ self.serialize({'network': data}),
+ content_type='application/' + self.fmt,
+ extra_environ=env,
+ expect_errors=expect_errors)
+ return res, data
+
def test_network_create_with_provider_attrs(self):
ctx = context.get_admin_context()
ctx.tenant_id = 'an_admin'
network=exp_input)
self.assertEqual(res.status_int, web_exc.HTTPCreated.code)
+ def test_network_create_with_bad_provider_attrs_400(self):
+ ctx = context.get_admin_context()
+ ctx.tenant_id = 'an_admin'
+ bad_data = {pnet.SEGMENTATION_ID: "abc"}
+ res, _1 = self._post_network_with_bad_provider_attrs(ctx, bad_data,
+ True)
+ self.assertEqual(web_exc.HTTPBadRequest.code, res.status_int)
+
def test_network_update_with_provider_attrs(self):
ctx = context.get_admin_context()
ctx.tenant_id = 'an_admin'