How to use ineligible_hosts_for_entry method in autotest

Best Python code snippet using autotest_python

metahost_scheduler_unittest.py

Source: metahost_scheduler_unittest.py Github

copy

Full Screen

1#!/​usr/​bin/​python2try:3 import autotest.common as common # pylint: disable=W06114except ImportError:5 import common # pylint: disable=W06116import unittest7from autotest.client.shared.test_utils import mock8from autotest.frontend import setup_django_environment # pylint: disable=W06119from autotest.frontend import setup_test_environment # pylint: disable=W061110from autotest.scheduler import metahost_scheduler, scheduler_models11class LabelMetahostSchedulerTest(unittest.TestCase):12 def setUp(self):13 self.god = mock.mock_god()14 self.scheduling_utility = self.god.create_mock_class(15 metahost_scheduler.HostSchedulingUtility, 'utility')16 self.metahost_scheduler = metahost_scheduler.LabelMetahostScheduler()17 def tearDown(self):18 self.god.unstub_all()19 def entry(self):20 return self.god.create_mock_class(scheduler_models.HostQueueEntry,21 'entry')22 def test_can_schedule_metahost(self):23 entry = self.entry()24 entry.meta_host = None25 self.assertFalse(self.metahost_scheduler.can_schedule_metahost(entry))26 entry.meta_host = 127 self.assert_(self.metahost_scheduler.can_schedule_metahost(entry))28 def test_schedule_metahost(self):29 entry = self.entry()30 entry.meta_host = 131 host = object()32 self.scheduling_utility.hosts_in_label.expect_call(1).and_return(33 [2, 3, 4, 5])34 # 2 is in ineligible_hosts35 (self.scheduling_utility.ineligible_hosts_for_entry.expect_call(entry)36 .and_return([2]))37 self.scheduling_utility.is_host_usable.expect_call(2).and_return(True)38 # 3 is unusable39 self.scheduling_utility.is_host_usable.expect_call(3).and_return(False)40 self.scheduling_utility.remove_host_from_label.expect_call(3, 1)41 # 4 is ineligible for the job42 self.scheduling_utility.is_host_usable.expect_call(4).and_return(True)43 (self.scheduling_utility.is_host_eligible_for_job.expect_call(4, entry)44 .and_return(False))45 # 5 runs46 self.scheduling_utility.is_host_usable.expect_call(5).and_return(True)47 (self.scheduling_utility.is_host_eligible_for_job.expect_call(5, entry)48 .and_return(True))49 self.scheduling_utility.remove_host_from_label.expect_call(5, 1)50 self.scheduling_utility.pop_host.expect_call(5).and_return(host)51 entry.set_host.expect_call(host)52 self.metahost_scheduler.schedule_metahost(entry,53 self.scheduling_utility)54 self.god.check_playback()55 def test_no_hosts(self):56 entry = self.entry()57 entry.meta_host = 158 self.scheduling_utility.hosts_in_label.expect_call(1).and_return(())59 (self.scheduling_utility.ineligible_hosts_for_entry.expect_call(entry)60 .and_return(()))61 self.metahost_scheduler.schedule_metahost(entry,62 self.scheduling_utility)63 self.god.check_playback()64if __name__ == '__main__':...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Scala Testing: A Comprehensive Guide

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.

What Agile Testing (Actually) Is

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.

How To Choose The Right Mobile App Testing Tools

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

A Complete Guide To CSS Houdini

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. ????

Appium Testing Tutorial For Mobile Applications

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.

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