3 """Tests for autotest_lib.scheduler.drones."""
8 from autotest_lib
.client
.common_lib
import utils
9 from autotest_lib
.client
.common_lib
.test_utils
import mock
, unittest
10 from autotest_lib
.scheduler
import drones
11 from autotest_lib
.server
.hosts
import ssh_host
14 class RemoteDroneTest(unittest
.TestCase
):
16 self
.god
= mock
.mock_god()
17 self
._mock
_host
= self
.god
.create_mock_class(ssh_host
.SSHHost
,
19 self
.god
.stub_function(drones
.drone_utility
, 'create_host')
26 def test_unreachable(self
):
27 drones
.drone_utility
.create_host
.expect_call('fakehost').and_return(
29 self
._mock
_host
.is_up
.expect_call().and_return(False)
30 self
.assertRaises(drones
.DroneUnreachable
,
31 drones
._RemoteDrone
, 'fakehost')
34 def test_execute_calls_impl(self
):
35 self
.god
.stub_with(drones
._RemoteDrone
, '_drone_utility_path',
36 'mock-drone-utility-path')
37 drones
.drone_utility
.create_host
.expect_call('fakehost').and_return(
39 self
._mock
_host
.is_up
.expect_call().and_return(True)
41 mock_result
= utils
.CmdResult(stdout
=cPickle
.dumps('mock return'))
42 self
._mock
_host
.run
.expect_call(
43 'python mock-drone-utility-path',
44 stdin
=cPickle
.dumps(mock_calls
), stdout_tee
=None,
45 connect_timeout
=mock
.is_instance_comparator(int)).and_return(
48 drone
= drones
._RemoteDrone
('fakehost')
49 self
.assertEqual('mock return', drone
._execute
_calls
_impl
(mock_calls
))
50 self
.god
.check_playback()
53 if __name__
== '__main__':