def test_unpackHg(self): if not hg.isHgInstalled(): self.fail( "Hg is not installed on your system. All Hg tests will fail.") try: tempDir = mdTestUtilities.makeTempDir() repoPath = mdTestUtilities.createHgRepository(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 Hg repository.") pci = steps.unpack(pci) self.assertEqual(pci.success, True, "Hg repository failed to unpack.") self.assertEqual( os.path.isdir(pci.currentPath), True, "Hg 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_isHgRepoCase2(self): #Case 2: URL that is a Hg repository if not hg.isHgInstalled(): self.fail("Hg is not installed on your system. All Hg tests will fail.") path = "http://selenic.com/repo/hello" self.assertTrue(hg.isHgRepo(path), "hg.isHgRepo(" + path + ") should have returned true.") #Test if wrong path returns false falsePath = "http://foo/wrong/path" returnValue = hg.isHgRepo(falsePath) self.assertEqual(returnValue, False, "hg.isHgRepo(" + falsePath + ") should have returned false.")
def test_hgCheckout(self): if not hg.isHgInstalled(): self.fail("Hg is not installed on your system. All Hg tests will fail.") tempDir = mdTestUtilities.makeTempDir() tempRepo = mdTestUtilities.createHgRepository(tempDir) checkedOutRepo = os.path.join(tempDir, "checkedOut") try: hg.hgCheckout(tempRepo, checkedOutRepo) returnValue = os.path.exists(os.path.join(checkedOutRepo, "testFile")) self.assertEqual(returnValue, True, "'testFile' did not exist after hg.hgCheckout(" + tempRepo + ") was called.") finally: utilityFunctions.removeDir(tempDir)
def test_fetchHg(self): if not hg.isHgInstalled(): self.fail("Hg is not installed on your system. All Hg tests will fail.") try: tempDir = mdTestUtilities.makeTempDir() repoPath = mdTestUtilities.createHgRepository(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 Hg repository.") finally: utilityFunctions.removeDir(tempDir)
def test_isHgRepoCase1(self): #Case 1: Local directory that is a Hg repository if not hg.isHgInstalled(): self.fail("Hg is not installed on your system. All Hg tests will fail.") #Create repository and test if is Hg repo tempDir = mdTestUtilities.makeTempDir() path = mdTestUtilities.createHgRepository(tempDir) try: self.assertTrue(hg.isHgRepo(path), "hg.isHgRepo(" + path + ") should have returned true.") finally: utilityFunctions.removeDir(tempDir) #Test if wrong path returns false falsePath = "/foo/wrong/path" self.assertFalse(hg.isHgRepo(falsePath), "hg.isHgRepo(" + falsePath + ") should have returned false.")
def test_isHgRepo(self): if not hg.isHgInstalled(): self.fail("Hg is not installed on your system. All Hg tests will fail.") #Create repository and test if is hg repo tempDir = mdTestUtilities.makeTempDir() tempRepo = mdTestUtilities.createHgRepository(tempDir) try: returnValue = hg.isHgRepo(tempRepo) self.assertEqual(returnValue, True, "hg.isHgRepo(" + tempRepo + ") should have returned true.") finally: utilityFunctions.removeDir(tempDir) #Test if wrong path returns false falsePath = "http://foo/wrong/path" returnValue = hg.isHgRepo(falsePath) self.assertEqual(returnValue, False, "hg.isHgRepo(" + falsePath + ") should have returned false.")
def test_isHgRepoCase4(self): #Case 4: Check for false positive with .gz files if not hg.isHgInstalled(): self.fail("Hg is not installed on your system. All Hg tests will fail.") #Local file try: tempDir = mdTestUtilities.makeTempDir() tarDir, path = mdTestUtilities.createGzipFile(tempDir) self.assertFalse(hg.isHgRepo(path), "hg.isHgRepo(" + path + ") should have returned false.") finally: utilityFunctions.removeDir(tempDir) #Remote file path = "http://www.eng.lsu.edu/mirrors/apache//apr/apr-util-1.3.10.tar.gz" self.assertFalse(hg.isHgRepo(path), "hg.isHgRepo(" + path + ") should have returned false.")
def test_isHgInstalled(self): returnValue = hg.isHgInstalled() self.assertEqual(returnValue, True, "Hg is not installed on your system. All Hg tests will fail.")