当前位置: 首页>>代码示例>>Python>>正文


Python exceptions.BadRequest方法代码示例

本文整理汇总了Python中tempest.lib.exceptions.BadRequest方法的典型用法代码示例。如果您正苦于以下问题:Python exceptions.BadRequest方法的具体用法?Python exceptions.BadRequest怎么用?Python exceptions.BadRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tempest.lib.exceptions的用法示例。


在下文中一共展示了exceptions.BadRequest方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_network_with_bad_dns_search_domain

# 需要导入模块: from tempest.lib import exceptions [as 别名]
# 或者: from tempest.lib.exceptions import BadRequest [as 别名]
def create_network_with_bad_dns_search_domain(
            self, dns_search_domain="[email protected]"):
        networks_client = self.networks_client
        subnets_client = self.subnets_client
        network_name = data_utils.rand_name('dns-sear-negative')
        resp = networks_client.create_network(name=network_name)
        network = resp.get('network', resp)
        self.addCleanup(test_utils.call_and_ignore_notfound_exc,
                        networks_client.delete_network,
                        network['id'])
        subnet_cfg = {
            'client': subnets_client,
            'name': network_name,
            'dns_search_domain': dns_search_domain}
        # should trigger exception of BadRequest with message:
        # Invalid input for dns_search_domain: ...
        resp = self.create_subnet(network, **subnet_cfg)
        subnet = resp.get('subnet', resp)
        return (network, subnet) 
开发者ID:openstack,项目名称:vmware-nsx-tempest-plugin,代码行数:21,代码来源:test_dns_search_domain_negative.py

示例2: test_update_direct_port_w_flat_net_wout_port_configs_negative

# 需要导入模块: from tempest.lib import exceptions [as 别名]
# 或者: from tempest.lib.exceptions import BadRequest [as 别名]
def test_update_direct_port_w_flat_net_wout_port_configs_negative(self):
        """
        Create a flat network. Create an openstack port with vnic-type normal.
        Update port to set vnic-type to direct, without required port settings.
        Update should fail on a bad request since prereq is not met.
        """
        test_flat_net = self._create_flat_network()
        test_port_name = data_utils.rand_name('test-port-')
        orig_post = {'name': test_port_name}
        LOG.debug("create NORMAL port: %s", str(orig_post))
        test_port = self.create_port(network_id=test_flat_net['id'],
                                     **orig_post)
        self.addCleanup(test_utils.call_and_ignore_notfound_exc,
                        self.delete_port, test_port['port']['id'])
        post_body = {'binding:vnic_type': 'direct'}
        LOG.debug("update port to be DIRECT: %s", str(orig_post))
        self.assertEqual(test_port['port']['binding:vnic_type'], 'normal',
                         "Orig port should be vnic-type NORMAL")
        self.assertRaises(ex.BadRequest, self.update_port,
                          test_port['port']['id'], **post_body) 
开发者ID:openstack,项目名称:vmware-nsx-tempest-plugin,代码行数:22,代码来源:test_port_types.py

示例3: test_update_direct_port_wout_flat_net_with_port_configs_negative

# 需要导入模块: from tempest.lib import exceptions [as 别名]
# 或者: from tempest.lib.exceptions import BadRequest [as 别名]
def test_update_direct_port_wout_flat_net_with_port_configs_negative(self):
        """
        Create a network. Create a normal openstack port. Update port to direct
        vnic-type. Update should fail since flat net prereq is not met
        """
        net_name = data_utils.rand_name('test-net')
        net_body = self.create_network(name=net_name)
        test_net = net_body['network']
        self.addCleanup(test_utils.call_and_ignore_notfound_exc,
                        self.delete_network, test_net['id'])
        test_port_name = data_utils.rand_name('test-port-')
        orig_post = {'name': test_port_name}
        LOG.debug("create NORMAL port: %s", str(orig_post))
        test_port = self.create_port(network_id=test_net['id'],
                                     **orig_post)
        self.addCleanup(test_utils.call_and_ignore_notfound_exc,
                        self.delete_port, test_port['port']['id'])
        post_body = {'port_security_enabled': 'False',
                     'security_groups': [],
                     'binding:vnic_type': 'direct'}
        self.assertRaises(ex.BadRequest, self.update_port,
                          test_port['port']['id'], **post_body) 
开发者ID:openstack,项目名称:vmware-nsx-tempest-plugin,代码行数:24,代码来源:test_port_types.py

示例4: _test_router_nat_when_floating_ips_active_on_network

# 需要导入模块: from tempest.lib import exceptions [as 别名]
# 或者: from tempest.lib.exceptions import BadRequest [as 别名]
def _test_router_nat_when_floating_ips_active_on_network(self):
        """Expect raise condition when floating ips are active on
           on network and tenant try to disable NAT
        """
        snat = True
        self._setup_network_topo(enable_snat=snat)
        nsx_router = self.nsx.get_logical_router(
            self.router['name'], self.router['id'])
        self.assertNotEqual(nsx_router, None)
        self.assertEqual(nsx_router['router_type'], 'TIER1')
        self._check_network_internal_connectivity(network=self.network)
        self._check_network_vm_connectivity(network=self.network)
        self._check_nonat_network_connectivity(should_connect=False)
        # Update router to disable snat and disassociate floating ip
        external_gateway_info = {
            'network_id': CONF.network.public_network_id,
            'enable_snat': (not snat)}
        self.assertRaises(exceptions.BadRequest, self._update_router,
                          self.router['id'],
                          self.cmgr_adm.routers_client,
                          external_gateway_info) 
开发者ID:openstack,项目名称:vmware-nsx-tempest-plugin,代码行数:23,代码来源:test_router_nonat_ops.py

示例5: test_update_protocol_from_identity_provider_unknown_mapping

# 需要导入模块: from tempest.lib import exceptions [as 别名]
# 或者: from tempest.lib.exceptions import BadRequest [as 别名]
def test_update_protocol_from_identity_provider_unknown_mapping(self):
        idp_id, mapping_id = self._create_identity_provider_and_mapping()

        # Add a protocol to the identity provider
        protocol_id = data_utils.rand_uuid_hex()
        self._create_protocol(idp_id, protocol_id, mapping_id)

        # Update the identity provider protocol using a non existent
        # mapping_id
        new_mapping_id = data_utils.rand_uuid_hex()
        self.assertRaises(
            lib_exc.BadRequest,
            self.idps_client.update_protocol_mapping,
            idp_id,
            protocol_id,
            new_mapping_id) 
开发者ID:openstack,项目名称:keystone-tempest-plugin,代码行数:18,代码来源:test_identity_providers.py

示例6: test_service_provider_create_with_bad_attributes

# 需要导入模块: from tempest.lib import exceptions [as 别名]
# 或者: from tempest.lib.exceptions import BadRequest [as 别名]
def test_service_provider_create_with_bad_attributes(self):
        sp_id = data_utils.rand_uuid_hex()
        sp_ref = fixtures.sp_ref()

        # The auth_url must follow a URL regex
        sp_ref['auth_url'] = data_utils.rand_uuid_hex()
        self.assertRaises(
            lib_exc.BadRequest,
            self.sps_client.create_service_provider,
            sp_id,
            **sp_ref)

        sp_ref = fixtures.sp_ref()

        # The sp_url must follow a URL regex
        sp_ref['sp_url'] = data_utils.rand_uuid_hex()
        self.assertRaises(
            lib_exc.BadRequest,
            self.sps_client.create_service_provider,
            sp_id,
            **sp_ref) 
开发者ID:openstack,项目名称:keystone-tempest-plugin,代码行数:23,代码来源:test_service_providers.py

示例7: test_service_provider_update_with_bad_attributes_fails

# 需要导入模块: from tempest.lib import exceptions [as 别名]
# 或者: from tempest.lib.exceptions import BadRequest [as 别名]
def test_service_provider_update_with_bad_attributes_fails(self):
        sp_id = data_utils.rand_uuid_hex()
        self._create_sp(sp_id, fixtures.sp_ref())

        # The auth_url must follow a URL regex
        self.assertRaises(
            lib_exc.BadRequest,
            self.sps_client.update_service_provider,
            sp_id,
            auth_url=data_utils.rand_uuid_hex())

        # The sp_url must follow a URL regex
        self.assertRaises(
            lib_exc.BadRequest,
            self.sps_client.update_service_provider,
            sp_id,
            auth_url=data_utils.rand_uuid_hex()) 
开发者ID:openstack,项目名称:keystone-tempest-plugin,代码行数:19,代码来源:test_service_providers.py

示例8: test_update_volume_target_replace_error

# 需要导入模块: from tempest.lib import exceptions [as 别名]
# 或者: from tempest.lib.exceptions import BadRequest [as 别名]
def test_update_volume_target_replace_error(self):
        """Fail when updating a volume target on node with power on state."""
        new_volume_id = data_utils.rand_name('volume_id')

        patch = [{'path': '/volume_id',
                  'op': 'replace',
                  'value': new_volume_id}]

        # Powering on the Node before updating a volume target.
        self.client.set_node_power_state(self.node['uuid'], 'power on')

        regex_str = (r'.*The requested action \\\\"volume target '
                     r'update\\\\" can not be performed on node*')

        self.assertRaisesRegex(lib_exc.BadRequest,
                               regex_str,
                               self.client.update_volume_target,
                               self.volume_target['uuid'],
                               patch) 
开发者ID:openstack,项目名称:ironic-tempest-plugin,代码行数:21,代码来源:test_volume_target.py

示例9: test_delete_volume_connector_error

# 需要导入模块: from tempest.lib import exceptions [as 别名]
# 或者: from tempest.lib.exceptions import BadRequest [as 别名]
def test_delete_volume_connector_error(self):
        """Delete a volume connector

        Fail when deleting a volume connector on node
        with powered on state.
        """

        # Powering on the Node before deleting a volume connector.
        self.client.set_node_power_state(self.node['uuid'], 'power on')

        regex_str = (r'.*The requested action \\\\"volume connector '
                     r'deletion\\\\" can not be performed on node*')

        self.assertRaisesRegex(lib_exc.BadRequest,
                               regex_str,
                               self.delete_volume_connector,
                               self.volume_connector['uuid']) 
开发者ID:openstack,项目名称:ironic-tempest-plugin,代码行数:19,代码来源:test_volume_connector.py

示例10: test_update_volume_connector_replace_error

# 需要导入模块: from tempest.lib import exceptions [as 别名]
# 或者: from tempest.lib.exceptions import BadRequest [as 别名]
def test_update_volume_connector_replace_error(self):
        """Updating a volume connector.

        Fail when updating a volume connector on node
        with power on state.
        """

        new_connector_id = data_utils.rand_name('connector_id')

        patch = [{'path': '/connector_id',
                  'op': 'replace',
                  'value': new_connector_id}]

        # Powering on the Node before updating a volume connector.
        self.client.set_node_power_state(self.node['uuid'], 'power on')

        regex_str = (r'.*The requested action \\\\"volume connector '
                     r'update\\\\" can not be performed on node*')
        self.assertRaisesRegex(lib_exc.BadRequest,
                               regex_str,
                               self.client.update_volume_connector,
                               self.volume_connector['uuid'],
                               patch) 
开发者ID:openstack,项目名称:ironic-tempest-plugin,代码行数:25,代码来源:test_volume_connector.py

示例11: test_list_virtual_interfaces

# 需要导入模块: from tempest.lib import exceptions [as 别名]
# 或者: from tempest.lib.exceptions import BadRequest [as 别名]
def test_list_virtual_interfaces(self):
        """Test list virtual interfaces, part of os-virtual-interfaces.

        If Neutron is available, then call the API and expect it to fail
        with a 400 BadRequest (policy enforcement is done before that happens).

        For more information, see:
        https://developer.openstack.org/api-ref/compute/#servers-virtual-interfaces-servers-os-virtual-interfaces-deprecated
        """
        self.rbac_utils.switch_role(self, toggle_rbac_role=True)
        if CONF.service_available.neutron:
            msg = "Listing virtual interfaces is not supported by this cloud."
            with self.assertRaisesRegex(lib_exc.BadRequest, msg):
                self.servers_client.list_virtual_interfaces(self.server['id'])
        else:
            self.servers_client.list_virtual_interfaces(self.server['id']) 
开发者ID:openstack,项目名称:patrole,代码行数:18,代码来源:test_server_misc_policy_actions_rbac.py

示例12: test_create_recordset_invalid

# 需要导入模块: from tempest.lib import exceptions [as 别名]
# 或者: from tempest.lib.exceptions import BadRequest [as 别名]
def test_create_recordset_invalid(self, name, type, records):
        if name is not None:
            recordset_name = name + "." + self.zone['name']

        else:
            recordset_name = self.zone['name']

        recordset_data = {
            'name': recordset_name,
            'type': type,
            'records': records,
        }

        LOG.info('Attempt to create a invalid Recordset')
        self.assertRaises(lib_exc.BadRequest,
            lambda: self.client.create_recordset(
                self.zone['id'], recordset_data)) 
开发者ID:openstack,项目名称:designate-tempest-plugin,代码行数:19,代码来源:test_recordset.py

示例13: test_create_audit_with_wrong_audit_template

# 需要导入模块: from tempest.lib import exceptions [as 别名]
# 或者: from tempest.lib.exceptions import BadRequest [as 别名]
def test_create_audit_with_wrong_audit_template(self):
        audit_params = dict(
            audit_template_uuid='INVALID',
            audit_type='ONESHOT',
        )

        self.assertRaises(
            exceptions.BadRequest, self.create_audit, **audit_params) 
开发者ID:openstack,项目名称:watcher-tempest-plugin,代码行数:10,代码来源:test_audit.py

示例14: test_create_audit_with_invalid_state

# 需要导入模块: from tempest.lib import exceptions [as 别名]
# 或者: from tempest.lib.exceptions import BadRequest [as 别名]
def test_create_audit_with_invalid_state(self):
        _, goal = self.client.show_goal("dummy")
        _, audit_template = self.create_audit_template(goal['uuid'])

        audit_params = dict(
            audit_template_uuid=audit_template['uuid'],
            state='INVALID',
        )

        self.assertRaises(
            exceptions.BadRequest, self.create_audit, **audit_params) 
开发者ID:openstack,项目名称:watcher-tempest-plugin,代码行数:13,代码来源:test_audit.py

示例15: test_create_dns_search_domain_negative

# 需要导入模块: from tempest.lib import exceptions [as 别名]
# 或者: from tempest.lib.exceptions import BadRequest [as 别名]
def test_create_dns_search_domain_negative(self):
        self.assertRaises(exceptions.BadRequest,
                          self.create_network_with_bad_dns_search_domain) 
开发者ID:openstack,项目名称:vmware-nsx-tempest-plugin,代码行数:5,代码来源:test_dns_search_domain_negative.py


注:本文中的tempest.lib.exceptions.BadRequest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。