Best Python code snippet using autotest_python
rpc_interface_unittest.py
Source:rpc_interface_unittest.py
...102 def test_get_jobs_filters(self):103 HqeStatus = models.HostQueueEntry.Status104 def create_two_host_job():105 return self._create_job(hosts=[1, 2])106 def set_hqe_statuses(job, first_status, second_status):107 entries = job.hostqueueentry_set.all()108 entries[0].update_object(status=first_status)109 entries[1].update_object(status=second_status)110 queued = create_two_host_job()111 queued_and_running = create_two_host_job()112 set_hqe_statuses(queued_and_running, HqeStatus.QUEUED,113 HqeStatus.RUNNING)114 running_and_complete = create_two_host_job()115 set_hqe_statuses(running_and_complete, HqeStatus.RUNNING,116 HqeStatus.COMPLETED)117 complete = create_two_host_job()118 set_hqe_statuses(complete, HqeStatus.COMPLETED, HqeStatus.COMPLETED)119 started_but_inactive = create_two_host_job()120 set_hqe_statuses(started_but_inactive, HqeStatus.QUEUED,121 HqeStatus.COMPLETED)122 parsing = create_two_host_job()123 set_hqe_statuses(parsing, HqeStatus.PARSING, HqeStatus.PARSING)124 def check_job_ids(actual_job_dicts, expected_jobs):125 self.assertEquals(126 set(job_dict['id'] for job_dict in actual_job_dicts),127 set(job.id for job in expected_jobs))128 check_job_ids(rpc_interface.get_jobs(not_yet_run=True), [queued])129 check_job_ids(rpc_interface.get_jobs(running=True),130 [queued_and_running, running_and_complete,131 started_but_inactive, parsing])132 check_job_ids(rpc_interface.get_jobs(finished=True), [complete])133 def _create_job_helper(self, **kwargs):134 return rpc_interface.create_job('test', 'Medium', 'control file',135 'Server', **kwargs)136 def test_one_time_hosts(self):137 job = self._create_job_helper(one_time_hosts=['testhost'],...
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!!