Exemplo n.º 1
0
    def createTestFolder(self, name):
        """An empty folder named ``name`` in the test folder."""
        assert name

        result = os.path.join(self.testFolderPath, name)
        _tools.makeEmptyFolder(result)
        return result
Exemplo n.º 2
0
    def setUpEmptyProject(self, project, testFolderPath=_BaseTestFolder):
        """
        Create a local repository for ``project``, possibly removing any existing repository
        before.
        """
        assert project
        assert testFolderPath

        self.project = project
        self.testFolderPath = testFolderPath
        self.scmWork = None

        _log.debug("clean up test folder at %r", self.testFolderPath)
        _tools.makeEmptyFolder(self.testFolderPath)
Exemplo n.º 3
0
    def testCanMessWithFolders(self):
        testFolderPath = tempfile.mkdtemp(prefix="scunch_test_")
        _tools.removeFolder(testFolderPath)
        self.assertFalse(os.path.exists(testFolderPath))

        _tools.makeFolder(testFolderPath)
        self.assertTrue(os.path.exists(testFolderPath))
        _tools.makeFolder(testFolderPath)

        _tools.removeFolder(testFolderPath)
        _tools.makeEmptyFolder(testFolderPath)
        _tools.makeEmptyFolder(testFolderPath)

        # Clean up.
        _tools.removeFolder(testFolderPath)
Exemplo n.º 4
0
    def testCanBeReset(self):
        self.setUpProject("testReset")

        # Modify a and add few files.
        addedFolderPath = self.scmWork.absolutePath("test folder to add", "addedFolder")
        addedPyPath = self.scmWork.absolutePath("test file to add", os.path.join("loops", "added.py"))
        forRangePyPath = self.scmWork.absolutePath("test file to remove", os.path.join("loops", "forRange.py"))
        whilePyPath = self.scmWork.absolutePath("test file to change", os.path.join("loops", "while.py"))

        # Add a folder and a file.
        _tools.makeEmptyFolder(addedFolderPath)
        self.writeTextFile(addedPyPath, ["# Just some added file."])

        # Remove a file
        os.remove(forRangePyPath)
        self.writeTextFile(whilePyPath, ["# Just some changed file."])

        self.scmWork.reset()
        self.assertFalse(os.path.exists(addedPyPath))
        self.assertTrue(os.path.exists(forRangePyPath))
        self.assertTrue(os.path.exists(whilePyPath))
        self.assertNonNormalStatus({})
Exemplo n.º 5
0
    def testPunchWithLowerCopy(self):
        self.setUpEmptyProject("punchWithLowerCopy")
        externalPunchWithLowerCopyPath = self.createTestFolder("externalPunchWithLowerCopy")

        def writeEmptyTxtFile(relativeFilePath):
            fullFilePath = os.path.join(externalPunchWithLowerCopyPath, relativeFilePath)
            self.writeTextFile(fullFilePath, [])

        def writeLowerTxtFile(relativeFolderPath=""):
            relativeFilePath = os.path.join(relativeFolderPath, "lower.txt")
            writeEmptyTxtFile(relativeFilePath)

        def writeMixedTxtFile(relativeFolderPath=""):
            relativeFilePath = os.path.join(relativeFolderPath, "MiXeD.tXt")
            writeEmptyTxtFile(relativeFilePath)

        def writeUpperTxtFile(relativeFolderPath=""):
            relativeFilePath = os.path.join(relativeFolderPath, "UPPER.TXT")
            writeEmptyTxtFile(relativeFilePath)

        def writeAllTxtFiles(relativeFolderPath=''):
            writeLowerTxtFile(relativeFolderPath)
            writeMixedTxtFile(relativeFolderPath)
            writeUpperTxtFile(relativeFolderPath)

        # Create test files and folders with names with different cases.
        writeAllTxtFiles()
        _tools.makeEmptyFolder(os.path.join(externalPunchWithLowerCopyPath, "lower"))
        writeAllTxtFiles('lower')
        _tools.makeEmptyFolder(os.path.join(externalPunchWithLowerCopyPath, "MiXeD"))
        writeAllTxtFiles('MiXeD')
        _tools.makeEmptyFolder(os.path.join(externalPunchWithLowerCopyPath, "UPPER"))
        writeAllTxtFiles('UPPER')

        lowerNamesPuncher = scunch.ScmPuncher(self.scmWork)
        lowerNamesPuncher.nameTransformation = scunch.LowerNameTransformation
        lowerNamesPuncher.punch(externalPunchWithLowerCopyPath)

        self.assertEqual(lowerNamesPuncher.workEntries, lowerNamesPuncher.externalEntries)

        self.assertNonNormalStatus({scunch.ScmStatus.Added: 15})
        self._testAfterPunch(externalPunchWithLowerCopyPath, names=scunch.LowerNameTransformation)
Exemplo n.º 6
0
 def testFailsOnMissingWorkCopy(self):
     nonWorkCopyFolderPath = os.path.join(_BaseTestFolder, 'testFailOnMissingWorkCopy')
     _tools.makeEmptyFolder(nonWorkCopyFolderPath)
     self.assertRaises(scunch.ScmError, scunch.createScmWork, nonWorkCopyFolderPath)