How to use parse_machine method in autotest

Best Python code snippet using autotest_python

base_utils_unittest.py

Source:base_utils_unittest.py Github

copy

Full Screen

...15 def test_form_cell_mappings(self):16 (ntuples, failures) = utils.form_ntuples_from_machines(self.machines)17 self.assertEquals(self.ntuples, ntuples)18 self.assertEquals(self.failures, failures)19 # parse_machine() test cases20 def test_parse_machine_good(self):21 '''test that parse_machine() is outputting the correct data'''22 gooddata = (('host', ('host', 'root', '', 22)),23 ('host:21', ('host', 'root', '', 21)),24 ('user@host', ('host', 'user', '', 22)),25 ('user:pass@host', ('host', 'user', 'pass', 22)),26 ('user:pass@host:1234', ('host', 'user', 'pass', 1234)),27 ('user:pass@10.3.2.1',28 ('10.3.2.1', 'user', 'pass', 22)),29 ('user:pass@10.3.2.1:1234',30 ('10.3.2.1', 'user', 'pass', 1234)),31 ('::1', ('::1', 'root', '', 22)),32 ('user:pass@abdc::ef', ('abdc::ef', 'user', 'pass', 22)),33 ('abdc::ef:99', ('abdc::ef:99', 'root', '', 22)),34 ('user:pass@[abdc::ef:99]',35 ('abdc::ef:99', 'user', 'pass', 22)),36 ('user:pass@[abdc::ef]:1234',37 ('abdc::ef', 'user', 'pass', 1234)),38 )39 for machine, result in gooddata:40 self.assertEquals(utils.parse_machine(machine), result)41 def test_parse_machine_override(self):42 '''Test that parse_machine() defaults can be overridden'''43 self.assertEquals(utils.parse_machine('host', 'bob', 'foo', 1234),44 ('host', 'bob', 'foo', 1234))45 def test_parse_machine_bad(self):46 '''test that bad data passed to parse_machine() will raise an exception'''47 baddata = ((':22', IndexError), # neglect to pass a hostname #148 ('user@', IndexError), # neglect to pass a hostname #249 ('user@:22', IndexError), # neglect to pass a hostname #350 (':pass@host', ValueError), # neglect to pass a username51 ('host:', ValueError), # empty port after hostname52 ('[1::2]:', ValueError), # empty port after IPv653 )54 for machine, exception in baddata:55 self.assertRaises(exception, utils.parse_machine, machine)56if __name__ == "__main__":...

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