Best Python code snippet using autotest_python
scheduler_models_unittest.py
Source:scheduler_models_unittest.py  
...246        job = scheduler_models.Job.fetch('id = 1')[0]247        self.assertFalse(job._atomic_and_has_started())248        self._update_hqe("status='Starting'")249        self.assertFalse(job._atomic_and_has_started())250    def _check_special_task(self, task, task_type, queue_entry_id=None):251        self.assertEquals(task.task, task_type)252        self.assertEquals(task.host.id, 1)253        if queue_entry_id:254            self.assertEquals(task.queue_entry.id, queue_entry_id)255    def test_run_asynchronous(self):256        self._create_job(hosts=[1, 2])257        task = self._test_pre_job_tasks_helper()258        self._check_special_task(task, models.SpecialTask.Task.VERIFY, 1)259    def test_run_asynchronous_skip_verify(self):260        job = self._create_job(hosts=[1, 2])261        job.run_verify = False262        job.save()263        task = self._test_pre_job_tasks_helper()264        self.assertEquals(task, None)265    def test_run_synchronous_verify(self):266        self._create_job(hosts=[1, 2], synchronous=True)267        task = self._test_pre_job_tasks_helper()268        self._check_special_task(task, models.SpecialTask.Task.VERIFY, 1)269    def test_run_synchronous_skip_verify(self):270        job = self._create_job(hosts=[1, 2], synchronous=True)271        job.run_verify = False272        job.save()273        task = self._test_pre_job_tasks_helper()274        self.assertEquals(task, None)275    def test_run_atomic_group_already_started(self):276        self._create_job(hosts=[5, 6], atomic_group=1, synchronous=True)277        self._update_hqe("status='Starting', execution_subdir=''")278        job = scheduler_models.Job.fetch('id = 1')[0]279        queue_entry = scheduler_models.HostQueueEntry.fetch('id = 1')[0]280        assert queue_entry.job is job281        self.assertEqual(None, job.run(queue_entry))282        self.god.check_playback()283    def test_reboot_before_always(self):284        job = self._create_job(hosts=[1])285        job.reboot_before = model_attributes.RebootBefore.ALWAYS286        job.save()287        task = self._test_pre_job_tasks_helper()288        self._check_special_task(task, models.SpecialTask.Task.CLEANUP)289    def _test_reboot_before_if_dirty_helper(self, expect_reboot):290        job = self._create_job(hosts=[1])291        job.reboot_before = model_attributes.RebootBefore.IF_DIRTY292        job.save()293        task = self._test_pre_job_tasks_helper()294        if expect_reboot:295            task_type = models.SpecialTask.Task.CLEANUP296        else:297            task_type = models.SpecialTask.Task.VERIFY298        self._check_special_task(task, task_type)299    def test_reboot_before_if_dirty(self):300        models.Host.smart_get(1).update_object(dirty=True)301        self._test_reboot_before_if_dirty_helper(True)302    def test_reboot_before_not_dirty(self):303        models.Host.smart_get(1).update_object(dirty=False)304        self._test_reboot_before_if_dirty_helper(False)305    def test_next_group_name(self):306        django_job = self._create_job(metahosts=[1])307        job = scheduler_models.Job(id=django_job.id)308        self.assertEqual('group0', job._next_group_name())309        for hqe in django_job.hostqueueentry_set.filter():310            hqe.execution_subdir = 'my_rack.group0'311            hqe.save()312        self.assertEqual('my_rack.group1', job._next_group_name('my/rack'))...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!!
