def create_remote_drone(self, hostname):
        """Create and initialize a Remote Drone.

        @param hostname: The name of the host for the remote drone.

        @return: A remote drone instance.
        """
        drones.drone_utility.create_host.expect_call(hostname).and_return(
            self._mock_host)
        self._mock_host.is_up.expect_call().and_return(True)
        return drones._RemoteDrone(hostname, timestamp_remote_calls=False)
Exemplo n.º 2
0
    def test_execute_calls_impl(self):
        self.god.stub_with(drones._RemoteDrone, "_drone_utility_path", "mock-drone-utility-path")
        drones.drone_utility.create_host.expect_call("fakehost").and_return(self._mock_host)
        self._mock_host.is_up.expect_call().and_return(True)
        mock_calls = ("foo",)
        mock_result = utils.CmdResult(stdout=cPickle.dumps("mock return"))
        self._mock_host.run.expect_call(
            "python mock-drone-utility-path",
            stdin=cPickle.dumps(mock_calls),
            stdout_tee=None,
            connect_timeout=mock.is_instance_comparator(int),
        ).and_return(mock_result)

        drone = drones._RemoteDrone("fakehost")
        self.assertEqual("mock return", drone._execute_calls_impl(mock_calls))
        self.god.check_playback()
Exemplo n.º 3
0
 def test_execute_calls_impl(self):
     self.god.stub_with(drones._RemoteDrone, '_drone_utility_path',
                        self.drone_utility_path)
     drones.drone_utility.create_host.expect_call('fakehost').and_return(
         self._mock_host)
     self._mock_host.is_up.expect_call().and_return(True)
     mock_calls = ('foo', )
     mock_result = utils.CmdResult(stdout=cPickle.dumps('mock return'))
     self._mock_host.run.expect_call(
         'python %s' % self.drone_utility_path,
         stdin=cPickle.dumps(mock_calls),
         stdout_tee=None,
         connect_timeout=mock.is_instance_comparator(int)).and_return(
             mock_result)
     drone = drones._RemoteDrone('fakehost', timestamp_remote_calls=False)
     self.assertEqual('mock return', drone._execute_calls_impl(mock_calls))
     self.god.check_playback()
Exemplo n.º 4
0
 def test_execute_queued_calls(self):
     self.god.stub_with(drones._RemoteDrone, '_drone_utility_path',
                        self.drone_utility_path)
     drones.drone_utility.create_host.expect_call('fakehost').and_return(
         self._mock_host)
     self._mock_host.is_up.expect_call().and_return(True)
     drone = drones._RemoteDrone('fakehost', timestamp_remote_calls=False)
     mock_return = {}
     mock_return['results'] = ['mock return']
     mock_return['warnings'] = []
     drone.queue_call('foo')
     mock_result = utils.CmdResult(stdout=cPickle.dumps(mock_return))
     self._mock_host.run.expect_call(
         'python %s' % self.drone_utility_path,
         stdin=cPickle.dumps(drone.get_calls()),
         stdout_tee=None,
         connect_timeout=mock.is_instance_comparator(int)).and_return(
             mock_result)
     self.assertEqual(mock_return['results'], drone.execute_queued_calls())
     self.god.check_playback()