def test_restart(self): """ test calling restart() when worker is running """ # patch basedir check to always succeed self.setupUpIsBuildworkerDir(True) # patch stopWorker() to do nothing mock_stopWorker = mock.Mock() 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.assertLogged("now restarting buildworker process..")
def test_no_worker_running(self): """ test calling restart() when no worker is running """ # patch basedir check to always succeed self.setupUpIsBuildworkerDir(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.assertLogged("no old buildworker process found to stop") self.assertLogged("now restarting buildworker process..")
def test_bad_basedir(self): """ test calling restart() with invalid basedir path """ # patch isBuildworkerDir() to fail self.setupUpIsBuildworkerDir(False) # call startCommand() and check that correct exit code is returned self.assertEqual(restart.restart(self.config), 1, "unexpected exit code") # check that isBuildworkerDir was called with correct argument self.isBuildworkerDir.assert_called_once_with(self.config["basedir"])