How to use run_complete method in autotest

Best Python code snippet using autotest_python

completion_test.py

Source:completion_test.py Github

copy

Full Screen

...58 self.assertEqual(c.COMP_WORDS, words)59 self.assertEqual(c.COMP_CWORD, cword)60 self.assertEqual(c.COMP_POINT, point)61class BashCompletionTest(unittest.TestCase):62 def run_complete(self, completion_file, program, command, expected):63 stdout, stderr = Completion().run(completion_file, program, command)64 print(stderr)65 self.assertEqual(stdout.decode('utf-8'), expected + '\n')66class TermiusTestCase(BashCompletionTest):67 program = 'termius'68 completion_file = 'contrib/completion/bash/termius'69 def test_nothing(self):70 self.run_complete(71 '',72 'complete connect fullclean group groups help host hosts '73 'identities identity info key keys login logout pfrule '74 'pfrules pull push snippet snippets sync tags settings'75 )76 def test_subcommand(self):77 self.run_complete('ho', 'host hosts')78 self.run_complete('grou', 'group groups')79 self.run_complete('i', 'identities identity info')80 def test_options_name(self):81 self.run_complete('host --ad', '--address')82 self.run_complete(83 'host -',84 '-h --help --log-file -t --tag -g --group -a --address -p '85 '--port -s --snippet --identity -u --username '86 '-i --identity-file -d --delete -L --label -S '87 '--strict-host-key-check -T --timeout --use-ssh-key '88 '-k --keep-alive-packages'89 )90 self.run_complete(91 'info -',92 '-h --help --log-file -G --group -H --host -M --no-merge '93 '-f --format -c --column --prefix --noindent '94 '--address --max-width'95 )96 def test_connect_host_label_and_ids(self):97 self.run_complete('connect', '')98 first = self.client.create_host('localhost', 'Asparagales')99 second = self.client.create_host('localhost', 'xanthorrhoeaceae')100 instances = (first, second)101 print((self.client.app_directory / 'storage').read_text())102 self.run_complete('connect ', ids_labels_completion(instances))103 self.run_complete('connect As', 'Asparagales')104 self.run_complete('connect xa', 'xanthorrhoeaceae')105 def test_connect_pfrule_label_and_ids(self):106 self.run_complete('connect', '')107 first_host = self.client.create_host('localhost', 'a')108 first = self.client.create_pfrule(first_host, 2222, 'Asparagales')109 second = self.client.create_pfrule(first_host, 2200, 'xanthorrhoeaceae')110 instances = (first, second)111 print((self.client.app_directory / 'storage').read_text())112 self.run_complete('connect -R ', ids_labels_completion(instances))113 self.run_complete('connect -R As', 'Asparagales')114 self.run_complete('connect -R xa', 'xanthorrhoeaceae')115 def test_info_host_label_and_ids(self):116 self.run_complete('info', '')117 first = self.client.create_host('localhost', 'Asparagales')118 second = self.client.create_host('localhost', 'xanthorrhoeaceae')119 instances = (first, second)120 self.run_complete('info ', ids_labels_completion(instances))121 self.run_complete('info As', 'Asparagales')122 self.run_complete('info xa', 'xanthorrhoeaceae')123 def test_identity_option(self):124 self.client.create_identity('Asparagales1', False)125 first = self.client.create_identity('Asparagales', True)126 second = self.client.create_identity('xanthorrhoeaceae', True)127 instances = (first, second)128 for i in ('host', 'group'):129 self.run_complete('{} --identity '.format(i),130 ids_labels_completion(instances))131 self.run_complete('{} --identity As'.format(i),132 'Asparagales')133 self.run_complete('{} --identity xa'.format(i),134 'xanthorrhoeaceae')135 def test_info_group_label_and_ids(self):136 self.run_complete('info', '')137 first = self.client.create_group('Asparagales')138 second = self.client.create_group('xanthorrhoeaceae')139 instances = (first, second)140 for option in ('-g', '--group'):141 subcommand = 'info {} '.format(option)142 self.run_complete(subcommand, ids_labels_completion(instances))143 self.run_complete(subcommand + ' As'.format(option), 'Asparagales')144 self.run_complete(subcommand + ' xa', 'xanthorrhoeaceae')145 def test_update_entity(self):146 entity = 'host'147 self.run_complete(entity, '')148 first = self.client.create_host('localhost', 'Asparagales')149 second = self.client.create_host('localhost', 'xanthorrhoeaceae')150 instances = (first, second)151 self.run_complete(entity + ' ', ids_labels_completion(instances))152 self.run_complete(entity + ' As', 'Asparagales')153 self.run_complete(entity + ' xa', 'xanthorrhoeaceae')154 def test_list_format_types(self):155 for subcommand in ('hosts', 'groups', 'tags', 'identities', 'snippets', 'pfrules', 'keys'):156 self.run_complete(subcommand + ' -f ', 'csv json table value yaml')157 self.run_complete(subcommand + ' --format ', 'csv json table value yaml')158 def run_complete(self, command, expected):159 super(TermiusTestCase, self).run_complete(160 self.completion_file, self.program, command, expected161 )162 def setUp(self):163 self.client = TermiusClient()164 def tearDown(self):165 self.client.clean()166class TermiusClient(object):167 def __init__(self):168 self.app_directory = Path('~/.termius/').expanduser()169 self.command_mock = Mock(**{'app.directory_path': self.app_directory})170 self.prepare()171 def create_identity(self, label, is_visible):172 return self._create_instance(173 Identity, label=label, is_visible=is_visible...

Full Screen

Full Screen

gohan_client_bash_completion_tests.py

Source:gohan_client_bash_completion_tests.py Github

copy

Full Screen

...28 self.assertEqual(c.COMP_WORDS, words)29 self.assertEqual(c.COMP_CWORD, cword)30 self.assertEqual(c.COMP_POINT, point)31class BashCompletionTest(unittest.TestCase):32 def run_complete(self, completion_file, program, command, expected):33 stdout,stderr = Completion().run(completion_file, program, command)34 self.assertEqual(stdout.decode("utf-8"), expected + '\n')35class GohanClientTestCases(BashCompletionTest):36 def test_1(self):37 self.run_complete("client p", "policy pet")38 def test_2(self):39 self.run_complete("client ", "version namespace event extension policy schema pet order")40 def test_3(self):41 self.run_complete("client pet","pet")42 def test_4(self):43 self.run_complete("client pet ","list show create set delete")44 def test_5(self):45 self.run_complete("client pet s","show set")46 def test_6(self):47 self.run_complete("client pet show -","--output-format --verbosity --fields --id --name --tenant_id --description --status")48 def test_7(self):49 self.run_complete("client pet show --fields ","id name tenant_id description status")50 def test_8(self):51 self.run_complete("client namespace show --fields ","id name description prefix parent version metadata")52 def test_9(self):53 self.run_complete("client namespace show --verbosity ","0 1 2")54 def test_10(self):55 self.run_complete("client policy show --fields ","id principal resource action effect condition")56 def test_11(self):57 self.run_complete("client policy something","" )58 def run_complete(self, command, expected):59 completion_file="gohan_client_bash_completion.sh"60 program="gohan"61 super(GohanClientTestCases, self).run_complete(completion_file, program, command, expected)62if (__name__=='__main__'):...

Full Screen

Full Screen

cmd_tool.py

Source:cmd_tool.py Github

copy

Full Screen

1import subprocess234def cmd(prefix, testcmd, suffix, itxt, rtime):56 runcmd = prefix + testcmd + suffix7 cmd_chain = runcmd.split(';')89 rout = ''1011 for i, c in enumerate(cmd_chain):1213 tcmd = c.strip()14 print('cmd_tool: run cmd {}: {}'.format(i, tcmd))1516 ctokens = c.split(' ')17 if len(ctokens[0]) < 1:18 ctokens = ctokens[1:]1920 # print('* ctokens:', ctokens)212223 run_complete = True24 try:25 prc = subprocess.run(ctokens,26 input=str.encode(itxt),27 stdout=subprocess.PIPE,28 stderr=subprocess.PIPE,29 timeout=rtime)3031 rout += str(prc.stdout, 'utf-8')3233 if len(prc.stderr) > 0:34 print('* cmd tool: stderr = \n', prc.stderr)35 run_complete = False36 return run_complete, rout373839 except Exception as e:40 print('* test case', i, ': exception: ' + str(e))4142 run_complete = False43 return run_complete, rout444546 # end try-except47 # end for48 return run_complete, rout4950if __name__ == '__main__':51 r1, r2 = cmd("./", "Q_aux2.exe Q1.txt", "", "dummyinput", 1)52 print('r1 = ', r1)53 print('r2 = ', r2)54 r1, r2 = cmd("", "g++ P4.cpp -o p.exe; ./p.exe", "; python readhead.py P4.cpp", "dummyinput", 1)55 print('r1 = ', r1) ...

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