Best Python code snippet using stestr_python
test_shell.py
Source:test_shell.py
...63 def test_unknown_auth_strategy(self):64 self.useFixture(fixtures.FakeLogger(level=logging.DEBUG))65 stdout, stderr = self.shell('--os-auth-strategy fake probe-list')66 self.assertFalse(stdout)67 def test_build_option_parser(self):68 neutron_shell = debug_shell.NeutronDebugShell(69 openstack_shell.NEUTRON_API_VERSION)70 result = neutron_shell.build_option_parser('descr', '2.0')71 self.assertTrue(isinstance(result, argparse.ArgumentParser))72 def test_endpoint_option(self):73 shell = debug_shell.NeutronDebugShell(74 openstack_shell.NEUTRON_API_VERSION)75 parser = shell.build_option_parser('descr', '2.0')76 os_endpoints = ['public', 'publicURL']77 # Neither $OS_ENDPOINT_TYPE nor --os-endpoint-type78 namespace = parser.parse_args([])79 self.assertIn(namespace.os_endpoint_type, os_endpoints)80 # --endpoint-type but not $OS_ENDPOINT_TYPE81 namespace = parser.parse_args(['--os-endpoint-type=admin'])82 self.assertEqual('admin', namespace.os_endpoint_type)83 def test_endpoint_environment_variable(self):84 fixture = fixtures.EnvironmentVariable("OS_ENDPOINT_TYPE",85 "public")86 self.useFixture(fixture)87 shell = debug_shell.NeutronDebugShell(88 openstack_shell.NEUTRON_API_VERSION)89 parser = shell.build_option_parser('descr', '2.0')90 # $OS_ENDPOINT_TYPE but not --endpoint-type91 namespace = parser.parse_args([])92 self.assertEqual("public", namespace.os_endpoint_type)93 # --endpoint-type and $OS_ENDPOINT_TYPE94 namespace = parser.parse_args(['--endpoint-type=admin'])95 self.assertEqual('admin', namespace.endpoint_type)96 def test_timeout_option(self):97 shell = debug_shell.NeutronDebugShell(98 openstack_shell.NEUTRON_API_VERSION)99 parser = shell.build_option_parser('descr', '2.0')100 # Neither $OS_ENDPOINT_TYPE nor --endpoint-type101 namespace = parser.parse_args([])102 self.assertIsNone(namespace.http_timeout)103 # --endpoint-type but not $OS_ENDPOINT_TYPE104 namespace = parser.parse_args(['--http-timeout=50'])105 self.assertEqual(50, namespace.http_timeout)106 def test_timeout_environment_variable(self):107 fixture = fixtures.EnvironmentVariable("OS_NETWORK_TIMEOUT",108 "50")109 self.useFixture(fixture)110 shell = debug_shell.NeutronDebugShell(111 openstack_shell.NEUTRON_API_VERSION)112 parser = shell.build_option_parser('descr', '2.0')113 namespace = parser.parse_args([])...
test_cmd.py
Source:test_cmd.py
...11 with modified_environ(12 'VAULT_AGENT_ADDR',13 ):14 app = cmd.HvacApp()15 parser = app.build_option_parser('DESCRIPTION', 'version-1')16 args = parser.parse_args([17 '--token', token_value18 ])19 assert args.address == cmd.DEFAULT_VAULT_ADDR20 addr = 'ADDR'21 with modified_environ(22 'VAULT_AGENT_ADDR',23 ):24 app = cmd.HvacApp()25 parser = app.build_option_parser('DESCRIPTION', 'version-1')26 args = parser.parse_args([27 '--token', token_value,28 '--agent-address', addr,29 ])30 assert args.address == addr31 ignored = 'SHOULD BE IGNORED'32 with modified_environ(33 VAULT_ADDR=ignored,34 VAULT_AGENT_ADDR=addr,35 ):36 app = cmd.HvacApp()37 parser = app.build_option_parser('DESCRIPTION', 'version-1')38 args = parser.parse_args([39 '--token', token_value40 ])41 assert args.address == addr42def test_parse_args():43 token_value = 'TOKEN'44 with modified_environ(45 'VAULT_ADDR',46 'VAULT_SKIP_VERIFY',47 'VAULT_CACERT',48 'VAULT_CLIENT_CERT',49 'VAULT_CLIENT_KEY',50 ):51 app = cmd.HvacApp()52 parser = app.build_option_parser('DESCRIPTION', 'version-1')53 args = parser.parse_args([54 '--token', token_value55 ])56 assert args.token == token_value57 assert args.address == cmd.DEFAULT_VAULT_ADDR58 assert args.tls_skip_verify is False59 assert args.ca_cert is None60 assert args.client_cert is None61 assert args.client_key is None62 addr = 'ADDR'63 skip_verify = 'yes'64 cacert = 'CACERT'65 client_cert = 'CLIENT_CERT'66 client_key = 'CLIENT_KEY'67 with modified_environ(68 VAULT_ADDR=addr,69 VAULT_SKIP_VERIFY=skip_verify,70 VAULT_CACERT=cacert,71 VAULT_CLIENT_CERT=client_cert,72 VAULT_CLIENT_KEY=client_key,73 ):74 app = cmd.HvacApp()75 parser = app.build_option_parser('DESCRIPTION', 'version-1')76 args = parser.parse_args([77 '--token', token_value78 ])79 assert args.token == token_value80 assert args.address == addr81 assert args.tls_skip_verify is True82 assert args.ca_cert == cacert83 assert args.client_cert == client_cert84 assert args.client_key == client_key85 with modified_environ(86 'VAULT_ADDR',87 'VAULT_SKIP_VERIFY',88 'VAULT_CACERT',89 'VAULT_CLIENT_CERT',90 'VAULT_CLIENT_KEY',91 ):92 app = cmd.HvacApp()93 parser = app.build_option_parser('DESCRIPTION', 'version-1')94 args = parser.parse_args([95 '--token', token_value, '--ca-cert', cacert96 ])...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!