Best Python code snippet using autotest_python
scheduler_models_unittest.py
Source:scheduler_models_unittest.py
...143 host = scheduler_models.Host(id=test_host.id)144 platform, all_labels = host.platform_and_labels()145 self.assertIsNone(platform)146 self.assertEqual(all_labels, ['non_static_label', 'static_platform'])147 def test_cmp_for_sort(self):148 expected_order = [149 'alice', 'Host1', 'host2', 'host3', 'host09', 'HOST010',150 'host10', 'host11', 'yolkfolk']151 hostname_idx = list(scheduler_models.Host._fields).index('hostname')152 row = [None] * len(scheduler_models.Host._fields)153 hosts = []154 for hostname in expected_order:155 row[hostname_idx] = hostname156 hosts.append(scheduler_models.Host(row=row, new_record=True))157 host1 = hosts[expected_order.index('Host1')]158 host010 = hosts[expected_order.index('HOST010')]159 host10 = hosts[expected_order.index('host10')]160 host3 = hosts[expected_order.index('host3')]161 alice = hosts[expected_order.index('alice')]162 self.assertEqual(0, scheduler_models.Host.cmp_for_sort(host10, host10))163 self.assertEqual(1, scheduler_models.Host.cmp_for_sort(host10, host010))164 self.assertEqual(-1, scheduler_models.Host.cmp_for_sort(host010, host10))165 self.assertEqual(-1, scheduler_models.Host.cmp_for_sort(host1, host10))166 self.assertEqual(-1, scheduler_models.Host.cmp_for_sort(host1, host010))167 self.assertEqual(-1, scheduler_models.Host.cmp_for_sort(host3, host10))168 self.assertEqual(-1, scheduler_models.Host.cmp_for_sort(host3, host010))169 self.assertEqual(1, scheduler_models.Host.cmp_for_sort(host3, host1))170 self.assertEqual(-1, scheduler_models.Host.cmp_for_sort(host1, host3))171 self.assertEqual(-1, scheduler_models.Host.cmp_for_sort(alice, host3))172 self.assertEqual(1, scheduler_models.Host.cmp_for_sort(host3, alice))173 self.assertEqual(0, scheduler_models.Host.cmp_for_sort(alice, alice))174 hosts.sort(cmp=scheduler_models.Host.cmp_for_sort)175 self.assertEqual(expected_order, [h.hostname for h in hosts])176 hosts.reverse()177 hosts.sort(cmp=scheduler_models.Host.cmp_for_sort)178 self.assertEqual(expected_order, [h.hostname for h in hosts])179class HostQueueEntryTest(BaseSchedulerModelsTest):180 def _create_hqe(self, dependency_labels=(), **create_job_kwargs):181 job = self._create_job(**create_job_kwargs)182 for label in dependency_labels:183 job.dependency_labels.add(label)184 hqes = list(scheduler_models.HostQueueEntry.fetch(where='job_id=%d' % job.id))185 self.assertEqual(1, len(hqes))186 return hqes[0]187 def _check_hqe_labels(self, hqe, expected_labels):...
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!!