def test_successful_stop(self):
        """
        test calling stop() when worker is running
        """

        # patch basedir check to always succeed
        self.setupUpIsWorkerDir(True)

        # patch stopWorker() to do nothing
        mock_stopWorker = mock.Mock()
        self.patch(stop, "stopWorker", mock_stopWorker)

        stop.stop(self.config)
        mock_stopWorker.assert_called_once_with(self.config["basedir"],
                                                self.config["quiet"], "TERM")
    def test_successful_stop(self):
        """
        test calling stop() when worker is running
        """

        # patch basedir check to always succeed
        self.setupUpIsWorkerDir(True)

        # patch stopWorker() to do nothing
        mock_stopWorker = mock.Mock()
        self.patch(stop, "stopWorker", mock_stopWorker)

        stop.stop(self.config)
        mock_stopWorker.assert_called_once_with(self.config["basedir"],
                                                self.config["quiet"],
                                                "TERM")
    def test_no_worker_running(self):
        """
        test calling stop() when no worker is running
        """
        self.setUpStdoutAssertions()

        # patch basedir check to always succeed
        self.setupUpIsWorkerDir(True)

        # patch stopWorker() to raise an exception
        mock_stopWorker = mock.Mock(side_effect=stop.WorkerNotRunning())
        self.patch(stop, "stopWorker", mock_stopWorker)

        stop.stop(self.config)

        self.assertStdoutEqual("worker not running\n")
    def test_no_worker_running(self):
        """
        test calling stop() when no worker is running
        """
        self.setUpStdoutAssertions()

        # patch basedir check to always succeed
        self.setupUpIsWorkerDir(True)

        # patch stopWorker() to raise an exception
        mock_stopWorker = mock.Mock(side_effect=stop.WorkerNotRunning())
        self.patch(stop, "stopWorker", mock_stopWorker)

        stop.stop(self.config)

        self.assertStdoutEqual("worker not running\n")
    def test_successful_stop(self):
        """
        test calling stop() when slave is running
        """

        # patch basedir check to always succeed
        self.setupUpIsBuildslaveDir(True)

        # patch stopSlave() to do nothing
        mock_stopSlave = mock.Mock()
        self.patch(stop, "stopSlave", mock_stopSlave)

        stop.stop(self.config)
        mock_stopSlave.assert_called_once_with(self.config["basedir"],
                                               self.config["quiet"],
                                               "TERM")
    def test_no_slave_running(self):
        """
        test calling stop() when no slave is running
        """
        self.setUpLogging()

        # patch basedir check to always succeed
        self.setupUpIsBuildslaveDir(True)

        # patch stopSlave() to raise an exception
        mock_stopSlave = mock.Mock(side_effect=stop.SlaveNotRunning())
        self.patch(stop, "stopSlave", mock_stopSlave)

        stop.stop(self.config)

        self.assertLogged("buildslave not running")
Beispiel #7
0
    def test_bad_basedir(self):
        """
        test calling stop() with invalid basedir path
        """

        # patch isWorkerDir() to fail
        self.setupUpIsWorkerDir(False)

        # call startCommand() and check that correct exit code is returned
        self.assertEqual(stop.stop(self.config), 1, "unexpected exit code")

        # check that isWorkerDir was called with correct argument
        self.isWorkerDir.assert_called_once_with(self.config["basedir"])
    def test_bad_basedir(self):
        """
        test calling stop() with invalid basedir path
        """

        # patch isWorkerDir() to fail
        self.setupUpIsWorkerDir(False)

        # call startCommand() and check that correct exit code is returned
        self.assertEqual(stop.stop(self.config), 1, "unexpected exit code")

        # check that isWorkerDir was called with correct argument
        self.isWorkerDir.assert_called_once_with(self.config["basedir"])
Beispiel #9
0
    def test_failed_stop(self):
        """
        test failing stop()
        """

        # patch basedir check to always succeed
        self.setupUpIsWorkerDir(True)

        # patch stopWorker() to do nothing
        mock_stopWorker = mock.Mock(return_value=17)
        self.patch(stop, "stopWorker", mock_stopWorker)

        exit_code = stop.stop(self.config)
        self.assertEqual(exit_code, 17)
        mock_stopWorker.assert_called_once_with(self.config["basedir"],
                                                self.config["quiet"], "TERM")
Beispiel #10
0
    def test_failed_stop(self):
        """
        test failing stop()
        """

        # patch basedir check to always succeed
        self.setupUpIsWorkerDir(True)

        # patch stopWorker() to do nothing
        mock_stopWorker = mock.Mock(return_value=17)
        self.patch(stop, "stopWorker", mock_stopWorker)

        exit_code = stop.stop(self.config)
        self.assertEqual(exit_code, 17)
        mock_stopWorker.assert_called_once_with(self.config["basedir"],
                                                self.config["quiet"],
                                                "TERM")