How to use test_parse_no_add_on method in autotest

Best Python code snippet using autotest_python

topic_common_unittest.py

Source:topic_common_unittest.py Github

copy

Full Screen

...358 'verbose': False,359 'debug': False}, options)360 self.assertEqual(leftover, [])361 flist.clean()362 def test_parse_no_add_on(self):363 flist = cli_mock.create_file('host1\nhost2\nleft2')364 sys.argv = ['atest', '--web', 'fooweb', '--parse', '-g',365 '--kill-on-failure', 'left1', 'left2', '-M', flist.name]366 self.atest.parser.add_option('-M', '--mlist', type='string')367 item_info = topic_common.item_parse_info(attribute_name='hosts',368 filename_option='mlist')369 (options, leftover) = self.atest.parse([item_info])370 self.assertEqualNoOrder(self.atest.hosts,371 ['left2', 'host1', 'host2'])372 self.assertEqual({'mlist': flist.name,373 'web_server': 'fooweb',374 'parse': True,375 'parse_delim': '|',376 'kill_on_failure': True,377 'verbose': False,378 'debug': True}, options)379 self.assertEqual(leftover, ['left1', 'left2'])380 flist.clean()381 def test_parse_add_on_first(self):382 flist = cli_mock.create_file('host1\nhost2\nleft2')383 ulist = cli_mock.create_file('user1\nuser2\nuser3\n')384 sys.argv = ['atest', '-g', '--parse', '--ulist', ulist.name,385 '-u', 'myuser,youruser',386 '--kill-on-failure', 'left1', 'left2', '-M', flist.name]387 self.atest.parser.add_option('-M', '--mlist', type='string')388 self.atest.parser.add_option('-U', '--ulist', type='string')389 self.atest.parser.add_option('-u', '--user', type='string')390 host_info = topic_common.item_parse_info(attribute_name='hosts',391 filename_option='mlist',392 use_leftover=True)393 user_info = topic_common.item_parse_info(attribute_name='users',394 inline_option='user',395 filename_option='ulist')396 (options, leftover) = self.atest.parse([host_info, user_info])397 self.assertEqualNoOrder(self.atest.hosts,398 ['left1', 'left2', 'host1', 'host2'])399 self.assertEqualNoOrder(self.atest.users,400 ['user1', 'user2', 'user3',401 'myuser', 'youruser'])402 self.assertEqual({'mlist': flist.name,403 'ulist': ulist.name,404 'user': 'myuser,youruser',405 'web_server': None,406 'parse': True,407 'parse_delim': '|',408 'kill_on_failure': True,409 'verbose': False,410 'debug': True}, options)411 self.assertEqual(leftover, [])412 flist.clean()413 ulist.clean()414 def test_parse_add_on_second(self):415 flist = cli_mock.create_file('host1\nhost2\nleft2')416 ulist = cli_mock.create_file('user1\nuser2\nuser3\n')417 sys.argv = ['atest', '-g', '--parse', '-U', ulist.name,418 '-u', 'myuser,youruser',419 '--kill-on-failure', 'left1', 'left2', '-M', flist.name]420 self.atest.parser.add_option('-M', '--mlist', type='string')421 self.atest.parser.add_option('-U', '--ulist', type='string')422 self.atest.parser.add_option('-u', '--user', type='string')423 host_info = topic_common.item_parse_info(attribute_name='hosts',424 filename_option='mlist',425 use_leftover=True)426 user_info = topic_common.item_parse_info(attribute_name='users',427 inline_option='user',428 filename_option='ulist')429 (options, leftover) = self.atest.parse([host_info, user_info])430 self.assertEqualNoOrder(self.atest.hosts,431 ['left1', 'left2', 'host1', 'host2'])432 self.assertEqualNoOrder(self.atest.users,433 ['user1', 'user2', 'user3',434 'myuser', 'youruser'])435 self.assertEqual({'mlist': flist.name,436 'ulist': ulist.name,437 'user': 'myuser,youruser',438 'web_server': None,439 'parse': True,440 'parse_delim': '|',441 'kill_on_failure': True,442 'verbose': False,443 'debug': True}, options)444 self.assertEqual(leftover, [])445 flist.clean()446 ulist.clean()447 def test_parse_all_opts(self):448 flist = cli_mock.create_file('host1\nhost2\nleft2')449 ulist = cli_mock.create_file('user1\nuser2\nuser3\n')450 sys.argv = ['atest', '-g', '--parse', '--ulist', ulist.name,451 '-u', 'myuser,youruser',452 '--kill-on-failure', '-M', flist.name, 'left1', 'left2']453 self.atest.parser.add_option('-M', '--mlist', type='string')454 self.atest.parser.add_option('-U', '--ulist', type='string')455 self.atest.parser.add_option('-u', '--user', type='string')456 host_info = topic_common.item_parse_info(attribute_name='hosts',457 filename_option='mlist',458 use_leftover=True)459 user_info = topic_common.item_parse_info(attribute_name='users',460 inline_option='user',461 filename_option='ulist')462 (options, leftover) = self.atest.parse([host_info, user_info])463 self.assertEqualNoOrder(self.atest.hosts,464 ['left1', 'left2', 'host1', 'host2'])465 self.assertEqualNoOrder(self.atest.users,466 ['user1', 'user2', 'user3',467 'myuser', 'youruser'])468 self.assertEqual({'mlist': flist.name,469 'ulist': ulist.name,470 'user': 'myuser,youruser',471 'web_server': None,472 'parse': True,473 'parse_delim': '|',474 'kill_on_failure': True,475 'verbose': False,476 'debug': True}, options)477 self.assertEqual(leftover, [])478 flist.clean()479 ulist.clean()480 def test_parse_no_add_on(self):481 flist = cli_mock.create_file('host1\nhost2\nleft2')482 ulist = cli_mock.create_file('user1\nuser2\nuser3\n')483 sys.argv = ['atest', '-U', ulist.name,484 '--kill-on-failure', '-M', flist.name]485 self.atest.parser.add_option('-M', '--mlist', type='string')486 self.atest.parser.add_option('-U', '--ulist', type='string')487 self.atest.parser.add_option('-u', '--user', type='string')488 host_info = topic_common.item_parse_info(attribute_name='hosts',489 filename_option='mlist',490 use_leftover=True)491 user_info = topic_common.item_parse_info(attribute_name='users',492 inline_option='user',493 filename_option='ulist')494 (options, leftover) = self.atest.parse([host_info, user_info])...

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 autotest 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