How to use _test_pre_job_tasks_helper method in autotest

Best Python code snippet using autotest_python

scheduler_models_unittest.py

Source:scheduler_models_unittest.py Github

copy

Full Screen

...256 task = models.SpecialTask(**kwargs)257 task.save()258 self._tasks.append(task)259 self.god.stub_with(models.SpecialTask.objects, 'create', _mock_create)260 def _test_pre_job_tasks_helper(self,261 reboot_before=model_attributes.RebootBefore.ALWAYS):262 """263 Calls HQE._do_schedule_pre_job_tasks() and returns the created special264 task265 """266 self._tasks = []267 queue_entry = scheduler_models.HostQueueEntry.fetch('id = 1')[0]268 queue_entry.job.reboot_before = reboot_before269 queue_entry._do_schedule_pre_job_tasks()270 return self._tasks271 def test_job_request_abort(self):272 django_job = self._create_job(hosts=[5, 6])273 job = scheduler_models.Job(django_job.id)274 job.request_abort()275 django_hqes = list(models.HostQueueEntry.objects.filter(job=job.id))276 for hqe in django_hqes:277 self.assertTrue(hqe.aborted)278 def _check_special_tasks(self, tasks, task_types):279 self.assertEquals(len(tasks), len(task_types))280 for task, (task_type, queue_entry_id) in zip(tasks, task_types):281 self.assertEquals(task.task, task_type)282 self.assertEquals(task.host.id, 1)283 if queue_entry_id:284 self.assertEquals(task.queue_entry.id, queue_entry_id)285 def test_run_asynchronous(self):286 self._create_job(hosts=[1, 2])287 tasks = self._test_pre_job_tasks_helper()288 self._check_special_tasks(tasks, [(models.SpecialTask.Task.RESET, 1)])289 def test_run_asynchronous_skip_verify(self):290 job = self._create_job(hosts=[1, 2])291 job.run_verify = False292 job.save()293 tasks = self._test_pre_job_tasks_helper()294 self._check_special_tasks(tasks, [(models.SpecialTask.Task.RESET, 1)])295 def test_run_synchronous_verify(self):296 self._create_job(hosts=[1, 2], synchronous=True)297 tasks = self._test_pre_job_tasks_helper()298 self._check_special_tasks(tasks, [(models.SpecialTask.Task.RESET, 1)])299 def test_run_synchronous_skip_verify(self):300 job = self._create_job(hosts=[1, 2], synchronous=True)301 job.run_verify = False302 job.save()303 tasks = self._test_pre_job_tasks_helper()304 self._check_special_tasks(tasks, [(models.SpecialTask.Task.RESET, 1)])305 def test_run_asynchronous_do_not_reset(self):306 job = self._create_job(hosts=[1, 2])307 job.run_reset = False308 job.run_verify = False309 job.save()310 tasks = self._test_pre_job_tasks_helper()311 self.assertEquals(tasks, [])312 def test_run_synchronous_do_not_reset_no_RebootBefore(self):313 job = self._create_job(hosts=[1, 2], synchronous=True)314 job.reboot_before = model_attributes.RebootBefore.NEVER315 job.save()316 tasks = self._test_pre_job_tasks_helper(317 reboot_before=model_attributes.RebootBefore.NEVER)318 self._check_special_tasks(tasks, [(models.SpecialTask.Task.VERIFY, 1)])319 def test_run_asynchronous_do_not_reset(self):320 job = self._create_job(hosts=[1, 2], synchronous=False)321 job.reboot_before = model_attributes.RebootBefore.NEVER322 job.save()323 tasks = self._test_pre_job_tasks_helper(324 reboot_before=model_attributes.RebootBefore.NEVER)325 self._check_special_tasks(tasks, [(models.SpecialTask.Task.VERIFY, 1)])326 def test_reboot_before_always(self):327 job = self._create_job(hosts=[1])328 job.reboot_before = model_attributes.RebootBefore.ALWAYS329 job.save()330 tasks = self._test_pre_job_tasks_helper()331 self._check_special_tasks(tasks, [332 (models.SpecialTask.Task.RESET, None)333 ])334 def _test_reboot_before_if_dirty_helper(self):335 job = self._create_job(hosts=[1])336 job.reboot_before = model_attributes.RebootBefore.IF_DIRTY337 job.save()338 tasks = self._test_pre_job_tasks_helper()339 task_types = [(models.SpecialTask.Task.RESET, None)]340 self._check_special_tasks(tasks, task_types)341 def test_reboot_before_if_dirty(self):342 models.Host.smart_get(1).update_object(dirty=True)343 self._test_reboot_before_if_dirty_helper()344 def test_reboot_before_not_dirty(self):345 models.Host.smart_get(1).update_object(dirty=False)346 self._test_reboot_before_if_dirty_helper()347if __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