

def test_hosting_device_policy(self):
    device_id = 'device_XYZ'
    with self.hosting_device_template() as hdt:
        hdt_id = hdt['hosting_device_template']['id']
        tenant_id = hdt['hosting_device_template']['tenant_id']
        with self.port(subnet=self._mgmt_subnet) as mgmt_port:
            mgmt_port_id = mgmt_port['port']['id']
            creds = device_manager_test_support._uuid()
            with self.hosting_device(device_id=device_id, template_id=hdt_id, management_port_id=mgmt_port_id, credentials_id=creds) as hd:
                hd_id = hd['hosting_device']['id']
                self._create_hosting_device(self.fmt, hdt_id, mgmt_port_id, True, webob.exc.HTTPForbidden.code, tenant_id=tenant_id, set_context=True)
                non_admin_ctx = n_context.Context('', tenant_id)
                self._show('hosting_devices', hd_id, webob.exc.HTTPNotFound.code, non_admin_ctx)
                self._update('hosting_devices', hd_id, {
                    'hosting_device': {
                        'name': 'new_name',
                    },
                }, webob.exc.HTTPForbidden.code, non_admin_ctx)
                self._delete('hosting_devices', hd_id, webob.exc.HTTPNotFound.code, non_admin_ctx)
                req = self.new_show_request('hosting_devices', hd_id, self.fmt, 'get_hosting_device_config')
                req.environ['neutron.context'] = non_admin_ctx
                res = req.get_response(self._api_for_resource('hosting_devices'))
                self.assertEqual(webob.exc.HTTPNotFound.code, res.status_int)

dataset/ETHPy150Open openstack/networking-cisco/networking_cisco/tests/unit/cisco/device_manager/test_db_device_manager.py TestDeviceManagerDBPlugin.test_hosting_device_policy/original