本文整理匯總了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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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())
示例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)
示例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'])
示例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)
示例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'])
示例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))
示例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)
示例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)
示例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)