Example #1
0
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)
Example #2
0
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"))
Example #3
0
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'))