def test_pull_resource_not_found(self): resource_dict = _create_test_dict() resource_id = resource_dict['id'] self.cctxt_mock.call.return_value = None with testtools.ExpectedException(resources_rpc.ResourceNotFound): self.rpc.pull(self.context, FakeResource.obj_name(), resource_id)
def test_commit_raises_exception_on_timeout(self): transaction = impl_idl.NeutronOVSDBTransaction(mock.sentinel, mock.Mock(), 1) with self.assert_max_execution_time(10): with testtools.ExpectedException(exceptions.TimeoutException): transaction.commit()
def test_iterate_timeout_timeout(self, mock_sleep): message = "timeout test" with testtools.ExpectedException(exc.OpenStackCloudTimeout, message): for count in utils.iterate_timeout(0.1, message, wait=1): pass mock_sleep.assert_called_with(1.0)
def test_get_neigh_entries_no_namespace(self): with testtools.ExpectedException(ip_lib.NetworkNamespaceNotFound): ip_lib.dump_neigh_entries(4, namespace="nonexistent-netns")
def test_parse_mappings_fails_for_extra_separator(self): with testtools.ExpectedException(ValueError): self.parse(['key:val:junk'])
def test_construtor_raises_exception_for_negative_respawn_interval(self): with testtools.ExpectedException(ValueError): async_process.AsyncProcess(['fake'], respawn_interval=-1)
def test_port_rule_wrong_input(self): with testtools.ExpectedException(ValueError): utils.port_rule_masking(12, 5)
def test_illegal_str_delta(self, cfy_local): with testtools.ExpectedException(ValueError, ".*must be a number.*"): cfy_local.execute('scale', parameters={'scalable_entity_name': 'node', 'delta': 'not a number'})
def test_update_repository_bad(self, p_get_os_distrib): with testtools.ExpectedException( ex.NotImplementedException, 'Repository Update is not implemented for OS windows me.*'): ssh_remote._update_repository()
def test_get_vif_details_unsupported_net(self): segment = {api.NETWORK_TYPE: 'foo'} with testtools.ExpectedException(exc.SriovUnsupportedNetworkType): self.driver._get_vif_details(segment)
def test_no_node(self, cfy_local): with testtools.ExpectedException(ValueError, ".*mock was found.*"): cfy_local.execute( 'scale', parameters={'scalable_entity_name': 'mock'}) with testtools.ExpectedException(ValueError, ".*mock was found.*"): cfy_local.execute('scale_old', parameters={'node_id': 'mock'})
def test_edit_managed_records_failure(self): ctxt = context.DesignateContext(user='******', tenant='54321') with testtools.ExpectedException(exceptions.Forbidden): ctxt.edit_managed_records = True
def test_all_tenants_policy_failure(self): ctxt = context.DesignateContext(user='******', tenant='54321') with testtools.ExpectedException(exceptions.Forbidden): ctxt.all_tenants = True
def test_invalid_action(self): with testtools.ExpectedException(exceptions.BadAction, 'Unexpected action: BAD'): self.actor._validate_action('BAD')
def test_start_raises_exception_if_process_already_started(self): self.proc._is_running = True with testtools.ExpectedException(async_process.AsyncProcessException): self.proc.start()
def test_install_packages_bad(self, p_get_os_distrib): with testtools.ExpectedException( ex.NotImplementedException, 'Package Installation is not implemented for OS windows me.*'): ssh_remote._install_packages(('git', 'emacs', 'tree'))
def test_stop_raises_exception_if_already_started(self): with testtools.ExpectedException(async_process.AsyncProcessException): self.proc.stop()
def test_invalid_values(self): for addr in ('XXXX', 'ypp', 'g3:vvv'): with testtools.ExpectedException(netaddr.core.AddrFormatError): utils.AuthenticIPNetwork(addr)
def test_commit_raises_exception_on_timeout(self): transaction = impl_idl.OvsVsctlTransaction(mock.sentinel, mock.Mock(), 1) with testtools.ExpectedException(exceptions.TimeoutException): transaction.commit()
def test_not_urls(self): with testtools.ExpectedException(pkg_resources.RequirementParseError): list(requirement.to_reqs('file:///foo#egg=foo'))
def test_get_routing_table_no_namespace(self): with testtools.ExpectedException(ip_lib.NetworkNamespaceNotFound): ip_lib.get_routing_table(4, namespace="nonexistent-netns")
def test_does_not_parse(self): with testtools.ExpectedException(pkg_resources.RequirementParseError): requirement.parse_line(self.line)
def test_parse_mappings_fails_for_missing_value(self): with testtools.ExpectedException(ValueError): self.parse(['key:'])
def test_port_rule_masking_min_higher_than_max(self): port_min = 10 port_max = 5 with testtools.ExpectedException(ValueError): utils.port_rule_masking(port_min, port_max)
def test_parse_mappings_fails_for_duplicate_value(self): with testtools.ExpectedException(ValueError): self.parse(['key1:val', 'key2:val'])
def test_delete_stack_wait_failed(self): failed_stack = self.stack.copy() failed_stack['stack_status'] = 'DELETE_FAILED' marker_event = fakes.make_fake_stack_event(self.stack_id, self.stack_name, status='CREATE_COMPLETE') marker_qs = 'marker={e_id}&sort_dir=asc'.format( e_id=marker_event['id']) resolve = 'resolve_outputs=False' self.register_uris([ dict(method='GET', uri='{endpoint}/stacks/{id}?{resolve}'.format( endpoint=fakes.ORCHESTRATION_ENDPOINT, id=self.stack_id, resolve=resolve), status_code=302, headers=dict( location='{endpoint}/stacks/{name}/{id}?{resolve}'.format( endpoint=fakes.ORCHESTRATION_ENDPOINT, id=self.stack_id, name=self.stack_name, resolve=resolve))), dict(method='GET', uri='{endpoint}/stacks/{name}/{id}?{resolve}'.format( endpoint=fakes.ORCHESTRATION_ENDPOINT, id=self.stack_id, name=self.stack_name, resolve=resolve), json={"stack": self.stack}), dict(method='GET', uri='{endpoint}/stacks/{id}/events?{qs}'.format( endpoint=fakes.ORCHESTRATION_ENDPOINT, id=self.stack_id, qs='limit=1&sort_dir=desc'), complete_qs=True, json={"events": [marker_event]}), dict(method='DELETE', uri='{endpoint}/stacks/{id}'.format( endpoint=fakes.ORCHESTRATION_ENDPOINT, id=self.stack_id)), dict(method='GET', uri='{endpoint}/stacks/{id}/events?{qs}'.format( endpoint=fakes.ORCHESTRATION_ENDPOINT, id=self.stack_id, qs=marker_qs), complete_qs=True, json={ "events": [ fakes.make_fake_stack_event(self.stack_id, self.stack_name, status='DELETE_COMPLETE'), ] }), dict(method='GET', uri='{endpoint}/stacks/{id}?resolve_outputs=False'.format( endpoint=fakes.ORCHESTRATION_ENDPOINT, id=self.stack_id, name=self.stack_name), status_code=302, headers=dict( location='{endpoint}/stacks/{name}/{id}?{resolve}'.format( endpoint=fakes.ORCHESTRATION_ENDPOINT, id=self.stack_id, name=self.stack_name, resolve=resolve))), dict(method='GET', uri='{endpoint}/stacks/{name}/{id}?{resolve}'.format( endpoint=fakes.ORCHESTRATION_ENDPOINT, id=self.stack_id, name=self.stack_name, resolve=resolve), json={"stack": failed_stack}), ]) with testtools.ExpectedException( openstack.cloud.OpenStackCloudException): self.cloud.delete_stack(self.stack_id, wait=True) self.assert_calls()
def test_quotas_limit_check_with_invalid_quota_value(self): tenant_id = 'tenant_id1' with testtools.ExpectedException(exceptions.InvalidQuotaValue): quota.QUOTAS.limit_check(context.Context('', tenant_id), tenant_id, network=-2)
def test_get_not_exist_port_id(self): with testtools.ExpectedException(exceptions.MlnxException): self.manager.get_port_id_by_mac('no-such-mac')
def test_validate_min_ipv6_mtu(self): self.conf.set_override('network_device_mtu', 1200) with mock.patch('neutron.common.ipv6_utils.is_enabled') as ipv6_status: with testtools.ExpectedException(SystemExit): ipv6_status.return_value = True BaseChild(self.conf)
def test_invalid_type(self): self.is_valid_mock.return_value = False with testtools.ExpectedException( resources_rpc.InvalidResourceTypeClass): resources_rpc._validate_resource_type('foo')