How to use _parser_add_args method in tempest

Best Python code snippet using tempest_python

account_generator.py

Source:account_generator.py Github

copy

Full Screen

...171 os.rename(account_file, '.'.join((account_file, 'bak')))172 with open(account_file, 'w') as f:173 yaml.safe_dump(accounts, f, default_flow_style=False)174 LOG.info('%s generated successfully!', account_file)175def _parser_add_args(parser):176 parser.add_argument('-c', '--config-file',177 metavar='/etc/tempest.conf',178 help='path to tempest config file')179 parser.add_argument('--os-username',180 metavar='<auth-user-name>',181 default=os.environ.get('OS_USERNAME'),182 help='User should have permissions '183 'to create new user accounts and '184 'tenants. Defaults to env[OS_USERNAME].')185 parser.add_argument('--os-password',186 metavar='<auth-password>',187 default=os.environ.get('OS_PASSWORD'),188 help='Defaults to env[OS_PASSWORD].')189 parser.add_argument('--os-project-name',190 metavar='<auth-project-name>',191 default=os.environ.get('OS_PROJECT_NAME'),192 help='Defaults to env[OS_PROJECT_NAME].')193 parser.add_argument('--os-tenant-name',194 metavar='<auth-tenant-name>',195 default=os.environ.get('OS_TENANT_NAME'),196 help='Defaults to env[OS_TENANT_NAME].')197 parser.add_argument('--os-domain-name',198 metavar='<auth-domain-name>',199 default=os.environ.get('OS_DOMAIN_NAME'),200 help='Defaults to env[OS_DOMAIN_NAME].')201 parser.add_argument('--tag',202 default='',203 required=False,204 dest='tag',205 help='Resources tag')206 parser.add_argument('-r', '--concurrency',207 default=1,208 type=int,209 required=False,210 dest='concurrency',211 help='Concurrency count')212 parser.add_argument('--with-admin',213 action='store_true',214 dest='admin',215 help='Creates admin for each concurrent group')216 parser.add_argument('-i', '--identity-version',217 default=3,218 choices=[2, 3],219 type=int,220 required=False,221 dest='identity_version',222 help='Version of the Identity API to use')223 parser.add_argument('accounts',224 metavar='accounts_file.yaml',225 help='Output accounts yaml file')226def get_options():227 usage_string = ('tempest account-generator [-h] <ARG> ...\n\n'228 'To see help on specific argument, do:\n'229 'tempest account-generator <ARG> -h')230 parser = argparse.ArgumentParser(231 description=DESCRIPTION,232 formatter_class=argparse.ArgumentDefaultsHelpFormatter,233 usage=usage_string234 )235 _parser_add_args(parser)236 opts = parser.parse_args()237 return opts238class TempestAccountGenerator(command.Command):239 def get_parser(self, prog_name):240 parser = super(TempestAccountGenerator, self).get_parser(prog_name)241 _parser_add_args(parser)242 return parser243 def take_action(self, parsed_args):244 try:245 main(parsed_args)246 except Exception:247 LOG.exception("Failure generating test accounts.")248 traceback.print_exc()249 raise250 def get_description(self):251 return DESCRIPTION252def main(opts=None):253 setup_logging()254 if not opts:255 LOG.warning("Use of: 'tempest-account-generator' is deprecated, "...

Full Screen

Full Screen

argparse-cliff.py

Source:argparse-cliff.py Github

copy

Full Screen

...206 return207 route_code = kwargs.get('route_code')208 stream = self.route_codes[route_code]209 stream.write(file_bytes)210def _parser_add_args(parser):211 parser.add_argument(212 "-s", "--subunit", metavar="<subunit file>",213 nargs="?", type=argparse.FileType('rb'), default=sys.stdin,214 help="The path to the subunit output file.")215 parser.add_argument(216 "-n", "--non-subunit-name", metavar="<non subunit name>",217 default="pythonlogging",218 help="The name used in subunit to describe the file contents.")219 parser.add_argument(220 "-o", "--output-file", metavar="<output file>", default=None,221 help="The output file name for the json.")222 parser.add_argument(223 "-p", "--ports", metavar="<ports file>", default=None,224 help="A JSON file describing the ports for each service.")225 parser.add_argument(226 "-v", "--verbose", action='store_true', default=False,227 help="Add Request and Response header and body data to stdout.")228class ArgumentParser(argparse.ArgumentParser):229 def __init__(self):230 desc = "Outputs all HTTP calls a given test made that were logged."231 super(ArgumentParser, self).__init__(description=desc)232 self.prog = "subunit-describe-calls"233 _parser_add_args(self)234class TempestSubunitDescribeCalls(command.Command):235 def get_parser(self, prog_name):236 parser = super(TempestSubunitDescribeCalls, self).get_parser(prog_name)237 _parser_add_args(parser)238 return parser239 def take_action(self, parsed_args):240 try:241 return entry_point(parsed_args)242 except Exception:243 traceback.print_exc()244 return 0245def parse(stream, non_subunit_name, ports):246 if ports is not None and os.path.exists(ports):247 ports = json.loads(open(ports).read())248 url_parser = UrlParser(ports)249 suite = subunit.ByteStreamToStreamResult(250 stream, non_subunit_name=non_subunit_name)251 result = testtools.StreamToExtendedDecorator(url_parser)...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful