示例#1
0
    def test_successful_stop(self):
        """
        test calling stop() 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)

        stop.stop(self.config)
        mock_stopWorker.assert_called_once_with(self.config["basedir"],
                                               self.config["quiet"],
                                               "TERM")
示例#2
0
    def test_no_worker_running(self):
        """
        test calling stop() when no worker is running
        """
        self.setUpLogging()

        # 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)

        stop.stop(self.config)

        self.assertLogged("buildworker not running")
示例#3
0
    def test_bad_basedir(self):
        """
        test calling stop() with invalid basedir path
        """

        # patch isBuildworkerDir() to fail
        self.setupUpIsBuildworkerDir(False)

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

        # check that isBuildworkerDir was called with correct argument
        self.isBuildworkerDir.assert_called_once_with(self.config["basedir"])