How to use _expect_host_keyval method in autotest

Best Python code snippet using autotest_python

version_0_unittest.py

Source:version_0_unittest.py Github

copy

Full Screen

...17 self.god.stub_function(version_0.job, 'find_hostname')18 self.god.stub_function(models.test, 'parse_host_keyval')19 def tearDown(self):20 self.god.unstub_all()21 def _expect_host_keyval(self, hostname, platform=None):22 return_dict = {}23 if platform:24 return_dict['platform'] = platform25 return_dict['labels'] = (platform + ',other_label,' +26 'model%%3A%s' % platform)27 (models.test.parse_host_keyval.expect_call('.', hostname)28 .and_return(return_dict))29 def test_load_from_dir_simple(self):30 models.job.read_keyval.expect_call('.').and_return(31 dict(self.keyval_return))32 self._expect_host_keyval('abc123', 'my_platform')33 job = version_0.job.load_from_dir('.')34 self.assertEqual('janet', job['user'])35 self.assertEqual('steeltown', job['label'])36 self.assertEqual('abc123', job['machine'])37 self.assertEqual('my_platform', job['machine_group'])38 self.god.check_playback()39 def _setup_two_machines(self):40 raw_keyval = dict(self.keyval_return)41 raw_keyval['hostname'] = 'easyas,abc123'42 models.job.read_keyval.expect_call('.').and_return(raw_keyval)43 def test_load_from_dir_two_machines(self):44 self._setup_two_machines()45 version_0.job.find_hostname.expect_call('.').and_raises(46 version_0.NoHostnameError('find_hostname stubbed out'))47 self._expect_host_keyval('easyas', 'platform')48 self._expect_host_keyval('abc123', 'platform')49 job = version_0.job.load_from_dir('.')50 self.assertEqual('easyas,abc123', job['machine'])51 self.assertEqual('platform', job['machine_group'])52 self.god.check_playback()53 def test_load_from_dir_two_machines_with_find_hostname(self):54 self._setup_two_machines()55 version_0.job.find_hostname.expect_call('.').and_return('foo')56 self._expect_host_keyval('foo')57 job = version_0.job.load_from_dir('.')58 self.assertEqual('foo', job['machine'])59 self.god.check_playback()60 def test_load_from_dir_two_machines_different_platforms(self):61 self._setup_two_machines()62 version_0.job.find_hostname.expect_call('.').and_raises(63 version_0.NoHostnameError('find_hostname stubbed out'))64 self._expect_host_keyval('easyas', 'platformZ')65 self._expect_host_keyval('abc123', 'platformA')66 job = version_0.job.load_from_dir('.')67 self.assertEqual('easyas,abc123', job['machine'])68 self.assertEqual('platformA,platformZ', job['machine_group'])69 self.god.check_playback()70 def test_load_from_dir_one_machine_group_name(self):71 raw_keyval = dict(self.keyval_return)72 raw_keyval['host_group_name'] = 'jackson five'73 models.job.read_keyval.expect_call('.').and_return(raw_keyval)74 self._expect_host_keyval('abc123')75 job = version_0.job.load_from_dir('.')76 self.assertEqual('janet', job['user'])77 self.assertEqual('abc123', job['machine'])78 self.god.check_playback()79 def test_load_from_dir_multi_machine_group_name(self):80 raw_keyval = dict(self.keyval_return)81 raw_keyval['user'] = 'michael'82 raw_keyval['hostname'] = 'abc123,dancingmachine'83 raw_keyval['host_group_name'] = 'jackson five'84 models.job.read_keyval.expect_call('.').and_return(raw_keyval)85 self._expect_host_keyval('jackson five')86 job = version_0.job.load_from_dir('.')87 self.assertEqual('michael', job['user'])88 # The host_group_name is used instead because machine appeared to be89 # a comma separated list.90 self.assertEqual('jackson five', job['machine'])91 self.god.check_playback()92 def test_load_from_dir_no_machine_group_name(self):93 raw_keyval = dict(self.keyval_return)94 del raw_keyval['hostname']95 raw_keyval['host_group_name'] = 'jackson five'96 models.job.read_keyval.expect_call('.').and_return(raw_keyval)97 self._expect_host_keyval('jackson five')98 job = version_0.job.load_from_dir('.')99 # The host_group_name is used because there is no machine.100 self.assertEqual('jackson five', job['machine'])101 self.god.check_playback()102class test_status_line(unittest.TestCase):103 statuses = ["GOOD", "WARN", "FAIL", "ABORT"]104 def test_handles_start(self):105 line = version_0.status_line(0, "START", "----", "test",106 "", {})107 self.assertEquals(line.type, "START")108 self.assertEquals(line.status, None)109 def test_fails_info(self):110 self.assertRaises(AssertionError,111 version_0.status_line, 0, "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