コード例 #1
0
    def test_upgradeSlave_updated(self):
        """
        test calling upgradeSlave() on an older buildbot.tac, that need to
        be updated
        """
        # patch basedir check to always succeed
        self.setupUpIsBuildslaveDir(True)

        # patch open() to return older buildbot.tac file
        self.setUpOpen(OLD_BUILDBOT_TAC)

        # call upgradeSlave() and check the success exit code is returned
        self.assertEqual(upgrade_slave.upgradeSlave(self.config), 0,
                         "unexpected exit code")

        # check message to the log
        self.assertLogged("buildbot.tac updated")

        # check calls to open()
        self.open.assert_has_calls(
            [mock.call(self.buildbot_tac),
             mock.call(self.buildbot_tac, "w")])

        # check that we wrote correct updated buildbot.tac file
        self.fileobj.write.assert_called_once_with(MODERN_BUILDBOT_TAC)
コード例 #2
0
    def test_upgradeSlave_bad_basedir(self):
        """
        test calling upgradeSlave() with bad base directory
        """
        # override isBuildslaveDir() to always fail
        self.setupUpIsBuildslaveDir(False)

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

        # check that isBuildslaveDir was called with correct argument
        self.isBuildslaveDir.assert_called_once_with("dummy")
コード例 #3
0
    def test_upgradeSlave_bad_basedir(self):
        """
        test calling upgradeSlave() with bad base directory
        """
        # override isBuildslaveDir() to always fail
        self.setupUpIsBuildslaveDir(False)

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

        # check that isBuildslaveDir was called with correct argument
        self.isBuildslaveDir.assert_called_once_with("dummy")
コード例 #4
0
    def test_upgradeSlave_updated(self):
        """
        test calling upgradeSlave() on an older buildbot.tac, that need to
        be updated
        """
        # patch basedir check to always succeed
        self.setupUpIsBuildslaveDir(True)

        # patch open() to return older buildbot.tac file
        self.setUpOpen(OLD_BUILDBOT_TAC)

        # call upgradeSlave() and check the success exit code is returned
        self.assertEqual(upgrade_slave.upgradeSlave(self.config), 0,
                         "unexpected exit code")

        # check message to stdout
        self.assertStdoutEqual("buildbot.tac updated\n")

        # check calls to open()
        self.open.assert_has_calls([mock.call(self.buildbot_tac),
                                    mock.call(self.buildbot_tac, "w")])

        # check that we wrote correct updated buildbot.tac file
        self.fileobj.write.assert_called_once_with(MODERN_BUILDBOT_TAC)
コード例 #5
0
    def test_upgradeSlave_no_changes(self):
        """
        test calling upgradeSlave() on a buildbot.tac that don't need to be
        upgraded
        """
        # patch basedir check to always succeed
        self.setupUpIsBuildslaveDir(True)

        # patch open() to return a modern buildbot.tac file
        self.setUpOpen(MODERN_BUILDBOT_TAC)

        # call upgradeSlave() and check the success exit code is returned
        self.assertEqual(upgrade_slave.upgradeSlave(self.config), 0,
                         "unexpected exit code")

        # check message to stdout
        self.assertStdoutEqual("No changes made\n")

        # check that open() was called with correct path
        self.open.assert_called_once_with(self.buildbot_tac)

        # check that no writes where made
        self.assertFalse(self.fileobj.write.called,
                         "unexpected write to buildbot.tac file")
コード例 #6
0
    def test_upgradeSlave_no_changes(self):
        """
        test calling upgradeSlave() on a buildbot.tac that don't need to be
        upgraded
        """
        # patch basedir check to always succeed
        self.setupUpIsBuildslaveDir(True)

        # patch open() to return a modern buildbot.tac file
        self.setUpOpen(MODERN_BUILDBOT_TAC)

        # call upgradeSlave() and check the success exit code is returned
        self.assertEqual(upgrade_slave.upgradeSlave(self.config), 0,
                         "unexpected exit code")

        # check message to the log
        self.assertLogged("No changes made")

        # check that open() was called with correct path
        self.open.assert_called_once_with(self.buildbot_tac)

        # check that no writes where made
        self.assertFalse(self.fileobj.write.called,
                         "unexpected write to buildbot.tac file")