def test_unpackGit(self): if not git.isGitInstalled(): self.fail( "Git is not installed on your system. All Git tests will fail." ) try: tempDir = mdTestUtilities.makeTempDir() repoPath = mdTestUtilities.createGitRepository(tempDir) pci = createPythonCallInfo(repoPath, os.path.join(tempDir, "output"), os.path.join(tempDir, "download")) pci = steps.fetch(pci) testFilePath = os.path.join(pci.outputPath, mdTestUtilities.testFileName) self.assertEqual(pci.success, True, "Git repository failed to fetch.") self.assertEqual( os.path.exists(testFilePath), True, "'" + mdTestUtilities.testFileName + "' did not exist after fetching a Git repository.") pci = steps.unpack(pci) self.assertEqual(pci.success, True, "Git repository failed to unpack.") self.assertEqual( os.path.isdir(pci.currentPath), True, "Git repository was not a directory after unpacking.") self.assertEqual( os.path.exists( os.path.join(pci.currentPath, mdTestUtilities.testFileName)), True, "testFile did not exist after unpacking.") finally: utilityFunctions.removeDir(tempDir)
def test_gitCheckout(self): if not git.isGitInstalled(): self.fail("Git is not installed on your system. All Git tests will fail.") tempDir = mdTestUtilities.makeTempDir() tempRepo = mdTestUtilities.createGitRepository(tempDir) checkedOutRepo = os.path.join(tempDir, "checkedOut") try: git.gitCheckout(tempRepo, checkedOutRepo) returnValue = os.path.exists(os.path.join(checkedOutRepo, mdTestUtilities.testFileName)) self.assertEqual(returnValue, True, "'" + mdTestUtilities.testFileName + "' did not exist after git.gitCheckout(" + tempRepo + ") was called.") finally: utilityFunctions.removeDir(tempDir)
def test_fetchGit(self): if not git.isGitInstalled(): self.fail("Git is not installed on your system. All Git tests will fail.") try: tempDir = mdTestUtilities.makeTempDir() repoPath = mdTestUtilities.createGitRepository(tempDir) pci = createPythonCallInfo(repoPath, os.path.join(tempDir, "output"), os.path.join(tempDir, "download")) pci = steps.fetch(pci) testFilePath = os.path.join(pci.outputPath, mdTestUtilities.testFileName) self.assertEqual(pci.success, True, "Hg repository failed to fetch.") self.assertEqual(os.path.exists(testFilePath), True, "'" + mdTestUtilities.testFileName + "' did not exist after fetching a Git repository.") finally: utilityFunctions.removeDir(tempDir)
def test_isGitRepoCase1(self): #Case 1: Local directory that is a git repository if not git.isGitInstalled(): self.fail("Git is not installed on your system. All Git tests will fail.") #Create repository and test if is git repo tempDir = mdTestUtilities.makeTempDir() tempRepo = mdTestUtilities.createGitRepository(tempDir) try: self.assertTrue(git.isGitRepo(tempRepo), "git.isGitRepo(" + tempRepo + ") should have returned true.") finally: utilityFunctions.removeDir(tempDir) #Test if wrong path returns false falsePath = "/foo/wrong/path" self.assertFalse(git.isGitRepo(falsePath), "git.isGitRepo(" + falsePath + ") should have returned false.")
def test_gitCheckout(self): if not git.isGitInstalled(): self.fail( "Git is not installed on your system. All Git tests will fail." ) tempDir = mdTestUtilities.makeTempDir() tempRepo = mdTestUtilities.createGitRepository(tempDir) checkedOutRepo = os.path.join(tempDir, "checkedOut") try: git.gitCheckout(tempRepo, checkedOutRepo) returnValue = os.path.exists( os.path.join(checkedOutRepo, mdTestUtilities.testFileName)) self.assertEqual( returnValue, True, "'" + mdTestUtilities.testFileName + "' did not exist after git.gitCheckout(" + tempRepo + ") was called.") finally: utilityFunctions.removeDir(tempDir)
def test_isGitRepoCase1(self): #Case 1: Local directory that is a git repository if not git.isGitInstalled(): self.fail( "Git is not installed on your system. All Git tests will fail." ) #Create repository and test if is git repo tempDir = mdTestUtilities.makeTempDir() tempRepo = mdTestUtilities.createGitRepository(tempDir) try: self.assertTrue( git.isGitRepo(tempRepo), "git.isGitRepo(" + tempRepo + ") should have returned true.") finally: utilityFunctions.removeDir(tempDir) #Test if wrong path returns false falsePath = "/foo/wrong/path" self.assertFalse( git.isGitRepo(falsePath), "git.isGitRepo(" + falsePath + ") should have returned false.")