Best Python code snippet using autotest_python
rpc_interface_unittest.py
Source: rpc_interface_unittest.py
...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'],138 profiles=['rhel6'])139 host = models.Host.objects.get(hostname='testhost')140 self.assertEquals(host.invalid, True)141 self.assertEquals(host.labels.count(), 0)142 self.assertEquals(host.aclgroup_set.count(), 0)143 def test_create_job_duplicate_hosts(self):144 self.assertRaises(model_logic.ValidationError, self._create_job_helper,145 hosts=[1, 1])146 def test_create_hostless_job(self):147 job_id = self._create_job_helper(hostless=True)148 job = models.Job.objects.get(pk=job_id)149 queue_entries = job.hostqueueentry_set.all()150 self.assertEquals(len(queue_entries), 1)151 self.assertEquals(queue_entries[0].host, None)152 self.assertEquals(queue_entries[0].meta_host, None)153 self.assertEquals(queue_entries[0].atomic_group, None)154 def _setup_special_tasks(self):155 host = self.hosts[0]156 job1 = self._create_job(hosts=[1])157 job2 = self._create_job(hosts=[1])158 entry1 = job1.hostqueueentry_set.all()[0]159 entry1.update_object(started_on=datetime.datetime(2009, 1, 2),160 execution_subdir='host1')161 entry2 = job2.hostqueueentry_set.all()[0]162 entry2.update_object(started_on=datetime.datetime(2009, 1, 3),163 execution_subdir='host1')164 self.task1 = models.SpecialTask.objects.create(165 host=host, task=models.SpecialTask.Task.VERIFY,166 time_started=datetime.datetime(2009, 1, 1), # ran before job 1167 is_complete=True, requested_by=models.User.current_user())168 self.task2 = models.SpecialTask.objects.create(169 host=host, task=models.SpecialTask.Task.VERIFY,170 queue_entry=entry2, # ran with job 2171 is_active=True, requested_by=models.User.current_user())172 self.task3 = models.SpecialTask.objects.create(173 host=host, task=models.SpecialTask.Task.VERIFY,174 requested_by=models.User.current_user()) # not yet run175 def test_get_special_tasks(self):176 self._setup_special_tasks()177 tasks = rpc_interface.get_special_tasks(host__hostname='host1',178 queue_entry__isnull=True)179 self.assertEquals(len(tasks), 2)180 self.assertEquals(tasks[0]['task'], models.SpecialTask.Task.VERIFY)181 self.assertEquals(tasks[0]['is_active'], False)182 self.assertEquals(tasks[0]['is_complete'], True)183 def test_get_latest_special_task(self):184 # a particular usage of get_special_tasks()185 self._setup_special_tasks()186 self.task2.time_started = datetime.datetime(2009, 1, 2)187 self.task2.save()188 tasks = rpc_interface.get_special_tasks(189 host__hostname='host1', task=models.SpecialTask.Task.VERIFY,190 time_started__isnull=False, sort_by=['-time_started'],191 query_limit=1)192 self.assertEquals(len(tasks), 1)193 self.assertEquals(tasks[0]['id'], 2)194 def _common_entry_check(self, entry_dict):195 self.assertEquals(entry_dict['host']['hostname'], 'host1')196 self.assertEquals(entry_dict['job']['id'], 2)197 def test_get_host_queue_entries_and_special_tasks(self):198 self._setup_special_tasks()199 entries_and_tasks = (200 rpc_interface.get_host_queue_entries_and_special_tasks('host1'))201 paths = [entry['execution_path'] for entry in entries_and_tasks]202 self.assertEquals(paths, ['hosts/host1/3-verify',203 '2-autotest_system/host1',204 'hosts/host1/2-verify',205 '1-autotest_system/host1',206 'hosts/host1/1-verify'])207 verify2 = entries_and_tasks[2]208 self._common_entry_check(verify2)209 self.assertEquals(verify2['type'], 'Verify')210 self.assertEquals(verify2['status'], 'Running')211 self.assertEquals(verify2['execution_path'], 'hosts/host1/2-verify')212 entry2 = entries_and_tasks[1]213 self._common_entry_check(entry2)214 self.assertEquals(entry2['type'], 'Job')215 self.assertEquals(entry2['status'], 'Queued')216 self.assertEquals(entry2['started_on'], '2009-01-03 00:00:00')217 def test_view_invalid_host(self):218 # RPCs used by View Host page should work for invalid hosts219 self._create_job_helper(hosts=[1], profiles=['N/A'])220 self.hosts[0].delete()221 self.assertEquals(1, rpc_interface.get_num_hosts(hostname='host1',222 valid_only=False))223 data = rpc_interface.get_hosts(hostname='host1', valid_only=False)224 self.assertEquals(1, len(data))225 self.assertEquals(1, rpc_interface.get_num_host_queue_entries(226 host__hostname='host1'))227 data = rpc_interface.get_host_queue_entries(host__hostname='host1')228 self.assertEquals(1, len(data))229 count = rpc_interface.get_num_host_queue_entries_and_special_tasks(230 hostname='host1')231 self.assertEquals(1, count)232 data = rpc_interface.get_host_queue_entries_and_special_tasks(233 hostname='host1')...
Check out the latest blogs from LambdaTest on this topic:
Before we discuss Scala testing, let us understand the fundamentals of Scala and how this programming language is a preferred choice for your development requirements.The popularity and usage of Scala are rapidly rising, evident by the ever-increasing open positions for Scala developers.
So, now that the first installment of this two fold article has been published (hence you might have an idea of what Agile Testing is not in my opinion), I’ve started feeling the pressure to explain what Agile Testing actually means to me.
Did you know that according to Statista, the number of smartphone users will reach 18.22 billion by 2025? Let’s face it, digital transformation is skyrocketing and will continue to do so. This swamps the mobile app development market with various options and gives rise to the need for the best mobile app testing tools
As a developer, checking the cross browser compatibility of your CSS properties is of utmost importance when building your website. I have often found myself excited to use a CSS feature only to discover that it’s still not supported on all browsers. Even if it is supported, the feature might be experimental and not work consistently across all browsers. Ask any front-end developer about using a CSS feature whose support is still in the experimental phase in most prominent web browsers. ????
The count of mobile users is on a steep rise. According to the research, by 2025, it is expected to reach 7.49 billion users worldwide. 70% of all US digital media time comes from mobile apps, and to your surprise, the average smartphone owner uses ten apps per day and 30 apps each month.
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!!