def _post_network_with_provider_attrs(self, ctx, expect_errors=False): data = self._prepare_net_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_entity_delete(self, entity): """Does the entity deletion based on naming convention.""" entity_id = str(uuid.uuid4()) path = self._resource_prefix + '/' if self._resource_prefix else '' path += self._plural_mappings.get(entity, entity + 's') if self._translate_resource_name: path = path.replace('_', '-') res = self.api.delete( test_api_v2._get_path(path, id=entity_id, fmt=self.fmt)) delete_entity = getattr(self.plugin.return_value, "delete_" + entity) delete_entity.assert_called_with(mock.ANY, entity_id) self.assertEqual(res.status_int, exc.HTTPNoContent.code)
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 _put_network_with_provider_attrs(self, ctx, expect_errors=False): data = self._prepare_net_data() env = {"neutron.context": ctx} instance = self.plugin.return_value instance.get_network.return_value = {"tenant_id": ctx.tenant_id, "shared": False} net_id = uuidutils.generate_uuid() res = self.api.put( test_api_v2._get_path("networks", id=net_id, fmt=self.fmt), self.serialize({"network": data}), extra_environ=env, expect_errors=expect_errors, ) return res, data, net_id
def _put_network_with_provider_attrs(self, ctx, expect_errors=False): data = self._prepare_net_data() env = {'neutron.context': ctx} instance = self.plugin.return_value instance.get_network.return_value = {'tenant_id': ctx.tenant_id, 'shared': False} net_id = uuidutils.generate_uuid() res = self.api.put(test_api_v2._get_path('networks', id=net_id, fmt=self.fmt), self.serialize({'network': data}), extra_environ=env, expect_errors=expect_errors) return res, data, net_id