Esempio n. 1
0
    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")
Esempio n. 2
0
    def test_no_worker_running(self):
        """
        test calling restart() when no worker is running
        """
        # 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)

        # check that restart() calls startWorker() and outputs correct messages
        restart.restart(self.config)
        self.startWorker.assert_called_once_with(self.config["basedir"],
                                                 self.config["quiet"],
                                                 self.config["nodaemon"])

        self.assertStdoutEqual("no old worker process found to stop\n"
                               "now restarting worker process..\n")