Example #1
0
    def test_start_command_bad_basedir(self):
        """
        test calling startCommand() with invalid basedir path
        """

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

        # call startCommand() and check that correct exit code is returned
        config = {"basedir": "dummy"}
        self.assertEqual(start.startCommand(config), 1, "unexpected exit code")

        # check that isWorkerDir was called with correct argument
        self.isWorkerDir.assert_called_once_with("dummy")
    def test_start_command_bad_basedir(self):
        """
        test calling startCommand() with invalid basedir path
        """

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

        # call startCommand() and check that correct exit code is returned
        config = {"basedir": "dummy"}
        self.assertEqual(start.startCommand(config), 1, "unexpected exit code")

        # check that isWorkerDir was called with correct argument
        self.isWorkerDir.assert_called_once_with("dummy")
Example #3
0
    def test_start_command_good(self):
        """
        test successful startCommand() call
        """

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

        # patch startWorker() to do nothing
        mocked_startWorker = mock.Mock(return_value=0)
        self.patch(start, "startWorker", mocked_startWorker)

        config = {"basedir": "dummy", "nodaemon": False, "quiet": False}
        self.assertEqual(start.startCommand(config), 0, "unexpected exit code")

        # check that isWorkerDir() and startWorker() were called
        # with correct argument
        self.isWorkerDir.assert_called_once_with("dummy")
        mocked_startWorker.assert_called_once_with(config["basedir"],
                                                   config["quiet"],
                                                   config["nodaemon"])
    def test_start_command_good(self):
        """
        test successful startCommand() call
        """

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

        # patch startWorker() to do nothing
        mocked_startWorker = mock.Mock(return_value=0)
        self.patch(start, "startWorker", mocked_startWorker)

        config = {"basedir": "dummy", "nodaemon": False, "quiet": False}
        self.assertEqual(start.startCommand(config), 0, "unexpected exit code")

        # check that isWorkerDir() and startWorker() were called
        # with correct argument
        self.isWorkerDir.assert_called_once_with("dummy")
        mocked_startWorker.assert_called_once_with(config["basedir"],
                                                   config["quiet"],
                                                   config["nodaemon"])