Best Python code snippet using autotest_python
rpc_interface_unittest.py
Source:rpc_interface_unittest.py
...44 host = models.Host.objects.get(hostname='testhost')45 self.assertEquals(host.invalid, True)46 self.assertEquals(host.labels.count(), 0)47 self.assertEquals(host.aclgroup_set.count(), 0)48 def _common_entry_check(self, entry_dict):49 self.assertEquals(entry_dict['host']['hostname'], 'host1')50 self.assertEquals(entry_dict['job']['id'], 2)51 def test_get_host_queue_entries_and_special_tasks(self):52 host = self.hosts[0]53 job1 = self._create_job(hosts=[1])54 job2 = self._create_job(hosts=[1])55 entry1 = job1.hostqueueentry_set.all()[0]56 entry1.update_object(started_on=datetime.datetime(2009, 1, 2),57 execution_subdir='1-myuser/host1')58 entry2 = job2.hostqueueentry_set.all()[0]59 entry2.update_object(started_on=datetime.datetime(2009, 1, 3),60 execution_subdir='2-myuser/host1')61 task1 = models.SpecialTask.objects.create(62 host=host, task=models.SpecialTask.Task.VERIFY,63 time_started=datetime.datetime(2009, 1, 1), # ran before job 164 is_complete=True)65 task2 = models.SpecialTask.objects.create(66 host=host, task=models.SpecialTask.Task.VERIFY,67 queue_entry=entry2, # ran with job 268 is_active=True)69 task3 = models.SpecialTask.objects.create(70 host=host, task=models.SpecialTask.Task.VERIFY) # not yet run71 entries_and_tasks = (72 rpc_interface.get_host_queue_entries_and_special_tasks('host1'))73 paths = [entry['execution_path'] for entry in entries_and_tasks]74 self.assertEquals(paths, ['hosts/host1/3-verify',75 '2-myuser/host1',76 'hosts/host1/2-verify',77 '1-myuser/host1',78 'hosts/host1/1-verify'])79 verify2 = entries_and_tasks[2]80 self._common_entry_check(verify2)81 self.assertEquals(verify2['type'], 'Verify')82 self.assertEquals(verify2['status'], 'Running')83 self.assertEquals(verify2['execution_path'], 'hosts/host1/2-verify')84 entry2 = entries_and_tasks[1]85 self._common_entry_check(entry2)86 self.assertEquals(entry2['type'], 'Job')87 self.assertEquals(entry2['status'], 'Queued')88 self.assertEquals(entry2['started_on'], '2009-01-03 00:00:00')89if __name__ == '__main__':...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!