class FetcherTestCase(testcase.TestCase): def setUp(self): testcase.TestCase.setUp(self, database=False) self.spec = SpecFile() self.spec.read("tests/helloworld/pspec.xml") self.url = uri.URI(self.spec.source.archive.uri) self.destpath = ctx.config.archives_dir() self.fetch = fetcher.Fetcher(self.url, self.destpath) def testFetch(self): self.fetch.fetch() fetchedFile = os.path.join(self.destpath, self.url.filename()) if os.access(fetchedFile, os.R_OK): self.assertEqual(util.sha1_file(fetchedFile), self.spec.source.archive.sha1sum) os.remove(fetchedFile) def testResume(self): resume_test_file = "tests/helloworld/helloworld-2.0.tar.bz2.part" shutil.copy(resume_test_file, ctx.config.archives_dir()) self.fetch.fetch() fetchedFile = os.path.join(self.destpath, self.url.filename()) if os.access(fetchedFile, os.R_OK): self.assertEqual(util.sha1_file(fetchedFile), self.spec.source.archive.sha1sum) os.remove(fetchedFile)
def setUp(self): testcase.TestCase.setUp(self, database=False) self.spec = SpecFile() self.spec.read("tests/helloworld/pspec.xml") self.url = uri.URI(self.spec.source.archive.uri) self.destpath = ctx.config.archives_dir() self.fetch = fetcher.Fetcher(self.url, self.destpath)
def setUp(self): testcase.TestCase.setUp(self) self.sourcedb = sourcedb.init() self.spec = SpecFile() self.spec.read("tests/popt/pspec.xml") if not ctx.repodb.has_repo('test'): ctx.repodb.add_repo('test', pisi.repodb.Repo(pisi.uri.URI('fakerepo.xml')))
class SourceDBTestCase(testcase.TestCase): def setUp(self): testcase.TestCase.setUp(self) self.sourcedb = sourcedb.init() self.spec = SpecFile() self.spec.read("tests/popt/pspec.xml") if not ctx.repodb.has_repo('test'): ctx.repodb.add_repo('test', pisi.repodb.Repo(pisi.uri.URI('fakerepo.xml'))) def testAddRemove(self): self.sourcedb.add_spec(self.spec, 'test') self.assert_(self.sourcedb.has_spec("popt")) self.sourcedb.remove_spec("popt", 'test') self.assert_(not self.sourcedb.has_spec("popt"))
class PackageDBTestCase(testcase.TestCase): def setUp(self): testcase.TestCase.setUp(self) self.spec = SpecFile() self.spec.read('tests/popt/pspec.xml') self.spec.check() def testAdd(self): if not ctx.repodb.has_repo('test'): ctx.repodb.add_repo('test', Repo(pisi.uri.URI('fakerepo.xml'))) ctx.packagedb.add_package(self.spec.packages[1], 'test') self.assert_(ctx.packagedb.has_package('popt-libs')) # close the database and remove lock #self.pdb.close() def testRemove(self): ctx.packagedb.remove_package('popt-libs', 'test') self.assert_(not ctx.packagedb.has_package('popt-libs', 'test'))
def testMakeZip(self): # first unpack our dear sandbox.zip spec = SpecFile("tests/pccts/pspec.xml") targetDir = '/tmp/pisitest' achv = sourcearchive.SourceArchive(spec, targetDir) achv.fetch(interactive=False) achv.unpack(clean_dir=True) del achv newZip = targetDir + "/new.zip" zip = archive.ArchiveZip(newZip, 'zip', 'w') sourceDir = targetDir + "/pccts" zip.add_to_archive(sourceDir) zip.close() self.assertEqual(os.path.exists(newZip), True) self.assertEqual(len(zip.list_archive()),326)
def testUnpackZipCond(self): spec = SpecFile("tests/pccts/pspec.xml") targetDir = '/tmp' achv = sourcearchive.SourceArchive(spec, targetDir) url = uri.URI(spec.source.archive.uri) filePath = join(ctx.config.archives_dir(), url.filename()) # check cached if util.sha1_file(filePath) != spec.source.archive.sha1sum: fetch = fetcher.Fetcher(spec.source.archive.uri, targetDir) fetch.fetch() assert spec.source.archive.type == "zip" achv = archive.Archive(filePath, spec.source.archive.type) achv.unpack_files(["pccts/history.txt"], targetDir) assert pathexists(targetDir + "/pccts") testfile = targetDir + "/pccts/history.txt" assert pathexists(testfile)
def testUnpackZip(self): spec = SpecFile("tests/pccts/pspec.xml") targetDir = '/tmp/pisitest' assert spec.source.archive.type == "zip" achv = sourcearchive.SourceArchive(spec, targetDir) achv.fetch(interactive=False) achv.unpack(clean_dir=True) assert pathexists(targetDir + "/pccts") testfile = targetDir + "/pccts/history.txt" assert pathexists(testfile) # check file integrity self.assertEqual(util.sha1_file(testfile), "f2be0f9783e84e98fe4e2b8201a8f506fcc07a4d")
def testUnpackTar(self): spec = SpecFile("tests/popt/pspec.xml") targetDir = '/tmp/pisitest' achv = sourcearchive.SourceArchive(spec, targetDir) assert spec.source.archive.type == "targz" # skip fetching and directly unpack the previously fetched (by # fetchertests) archive if not achv.is_cached(interactive=False): achv.fetch(interactive=False) achv.unpack() # but testing is hard # "var/tmp/pisi/popt-1.7-3/work" (targetDir) assert pathexists(targetDir + "/popt-1.7") testfile = targetDir + "/popt-1.7/Makefile.am" assert pathexists(testfile) # check file integrity self.assertEqual(util.sha1_file(testfile), "5af9dd7d754f788cf511c57ce0af3d555fed009d")
def setUp(self): testcase.TestCase.setUp(self) self.spec = SpecFile() self.spec.read('tests/popt/pspec.xml') self.spec.check()