예제 #1
0
    def test_change_config(self):
        task_server = self.task_server

        tc = TaskComputer(task_server, use_docker_manager=False)
        tc.docker_manager = mock.Mock(spec=DockerManager, hypervisor=None)

        tc.use_docker_manager = False
        tc.change_config(mock.Mock(), in_background=False)
        assert not tc.docker_manager.update_config.called

        tc.use_docker_manager = True

        def _update_config(status_callback, *_, **__):
            status_callback()

        tc.docker_manager.update_config = _update_config

        tc.counting_task = True
        tc.change_config(mock.Mock(), in_background=False)

        # pylint: disable=unused-argument
        def _update_config_2(status_callback, done_callback, *_, **__):
            done_callback(False)

        tc.docker_manager.update_config = _update_config_2

        tc.counting_task = None
        tc.change_config(mock.Mock(), in_background=False)
예제 #2
0
    def test_change_config(self):
        task_server = mock.MagicMock()
        task_server.config_desc = config_desc()

        tc = TaskComputer("ABC", task_server, use_docker_machine_manager=False)
        tc.docker_manager = mock.Mock()

        tc.use_docker_machine_manager = False
        tc.change_config(mock.Mock(), in_background=False)
        assert not tc.docker_manager.update_config.called

        tc.use_docker_machine_manager = True
        tc.docker_manager.update_config = lambda x, y, z: x()

        tc.counting_task = True
        tc.change_config(mock.Mock(), in_background=False)

        tc.docker_manager.update_config = lambda x, y, z: y()

        tc.counting_task = False
        tc.change_config(mock.Mock(), in_background=False)