def test_BranchRenaming_TargetBranchExist_ShouldBeSuccessful(self): with testhelper.createrepo(folderprefix="gitfunctionstestcase_"): branchname = "hello" Commiter.branch(branchname) self.assertEqual(0, Commiter.promotebranchtomaster(branchname)) time.sleep(1) self.assertEqual(0, Commiter.promotebranchtomaster(branchname))
def test_ExistingFileStartsWithUpperCase_RenameToLowerCase_ExpectGitRename(self): with testhelper.createrepo(folderprefix="gitfunctionstestcase_"): originalfilename = "AFileWithLowerStart" newfilename = "aFileWithLowerStart" self.simulateCreationAndRenameInGitRepo(originalfilename, newfilename) self.assertGitStatusShowsIsRenamed()
def test_IllegalGitCharsShouldntCreateFile_SpecialCaseAlreadyQuoted(self): with testhelper.createrepo(folderprefix="gitfunctionstestcase_"): Commiter.addandcommit( testhelper.createchangeentry(comment="Check out \"" + ">" + "\"US3333\"")) self.assertEqual(0, len(shell.getoutput("git status -z")), "No file should be created by commit message")
def test_BranchRenaming_TwoCallsAtTheSameTime_ShouldFail(self, datetimemock): with testhelper.createrepo(folderprefix="gitfunctionstestcase_"): branchname = "hello" Commiter.branch(branchname) faketime = datetime.datetime(2015, 11, 11, 11, 11, 11) datetimemock.now.return_value = faketime self.assertEqual(0, Commiter.promotebranchtomaster(branchname)) self.assertEqual(1, Commiter.promotebranchtomaster(branchname))
def test_ExistingDirStartsWithUpperCaseA_RenameChildFile_ExpectGitRename(self): with testhelper.createrepo(folderprefix="gitfunctionstestcase_"): originalfilename = "AFileWithLowerStart" newfilename = "aFileWithLowerStart" subfolder = "Afolder" # this is key to reproduce #39 create_and_change_directory(subfolder) self.simulateCreationAndRenameInGitRepo(originalfilename, newfilename) self.assertGitStatusShowsIsRenamed()
def testExistRepo_Exists_ShouldReturnTrue(self): with testhelper.createrepo(folderprefix="test_migration"): self.assertTrue(migration.existsrepo())
def test_IllegalGitCharsShouldntCreateFile_SpecialCaseAlreadyQuoted(self): with testhelper.createrepo(folderprefix="gitfunctionstestcase_"): Commiter.addandcommit(testhelper.createchangeentry(comment="Check out \"" + ">" + "\"US3333\"")) self.assertEqual(0, len(shell.getoutput("git status -z")), "No file should be created by commit message")
def test_IllegalGitCharsShouldntCreateFile_NoCommentCase(self): with testhelper.createrepo(folderprefix="gitfunctionstestcase_"): Commiter.addandcommit(testhelper.createchangeentry(comment="<No Comment>")) self.assertEqual(0, len(shell.getoutput("git status -z")), "No file should be created by commit message")
def test_checkbranchname_unquoted_expect_invalid(self): with testhelper.createrepo(folderprefix="gitfunctionstestcase_"): self.assertEqual(False, Commiter.checkbranchname("master pflaster"), "master pflaster should not be a valid branch name")
def test_checkbranchname_expect_valid(self): with testhelper.createrepo(folderprefix="gitfunctionstestcase_"): self.assertEqual(True, Commiter.checkbranchname("master"), "master should be a valid branch name")
def test_CopyBranch_TargetAlreadyExist_ShouldFail(self): with testhelper.createrepo(folderprefix="gitfunctionstestcase_"): branchname = "hello" Commiter.branch(branchname) self.assertFalse(Commiter.copybranch("master", branchname) is 0)
def test_CopyBranch_TargetDoesntExist_ShouldBeSucessful(self): with testhelper.createrepo(folderprefix="gitfunctionstestcase_"): branchname = "hello" self.assertEqual(0, Commiter.copybranch("master", branchname))
def test_BranchRenaming_TargetBranchDoesntExist(self): with testhelper.createrepo(folderprefix="gitfunctionstestcase_"): branchname = "hello" Commiter.branch(branchname) self.assertEqual(0, Commiter.promotebranchtomaster(branchname))