class BuildDepCheckerTests(unittest.TestCase):
    def setUp(self):
        self.udd = Udd()
        self.checker = BuildDepsChecker(
            self.udd.BindRelease(arch="i386", release="sid"))

    def tearDown(self):
        self.udd = None
        self.checker = None

    def testCheck(self):
        """Test checking the build-dependencies of a package"""
        # simple package, check by source package name
        b = self.checker.Check(package="pyxplot")
        self.assertTrue(b)
        self.assertTrue(len(b.bd.good) > 0)
        self.assertTrue(len(b.bd.bad) == 0)
        # big complicated package with lots of arch-dependent entries, check by binary name
        b = self.checker.Check(package="libc6")
        self.assertTrue(b)
        self.assertTrue(len(b.bd.good) > 0)
        self.assertTrue(len(b.bdi.good) > 0)
        self.assertTrue(len(b.bd.bad) == 0)
        self.assertTrue(len(b.bdi.bad) == 0)
        # check by SourcePackage object
        p = self.udd.BindSourcePackage(package="latexdraw", release="squeeze")
        b = self.checker.Check(package=p)
        self.assertTrue(b)
        self.assertTrue(len(b.bd.good) > 0)
        self.assertTrue(len(b.bd.bad) == 0)
        # non-existent package
        self.assertRaises(PackageNotFoundError,
                          self.checker.Check,
                          package="no-such-package")
        # bd and bdi lists
        p = self.udd.BindSourcePackage(package="libc6")
        bd = p.RelationshipOptionsList("build_depends")
        b = self.checker.Check(bdList=bd)
        self.assertTrue(b)
        self.assertTrue(len(b.bd.good) > 0)
        b = self.checker.Check(
            bdList=p.RelationshipOptionsList("build_depends"),
            bdiList=p.RelationshipOptionsList("build_depends"))
        self.assertTrue(b)
        self.assertTrue(len(b.bd.good) > 0)
        self.assertTrue(len(b.bdi.good) > 0)
        self.assertRaises(ValueError, self.checker.Check)
        self.assertRaises(ValueError, self.checker.Check, bdList=[])
class database(unittest.TestCase):
    def setUp(self):
        self.udd = Udd()

    def tearDown(self):
        self.udd = None

    def testDBTypes(self):
        """Test creating a Debian and derivative UDD instance"""
        self.assertTrue(Udd(distro='debian'))
        self.assertRaises(NotImplementedError, Udd,
                          distro='ubuntu')  # TODO: update when implemented
        self.assertRaises(ValueError, Udd, distro='nosuchdistro')

    def testPassConfig(self):
        """Test loading a config file manually"""
        config = Config()
        self.assertTrue(Udd(config=config))

    def testRelease(self):
        """Test binding to a release and doing a lookup"""
        r = self.udd.BindRelease('sid', 'i386')
        self.assertTrue(r)
        r = self.udd.BindRelease(['stable', 'stable-backports'], 'i386')
        self.assertTrue(r)

    def testPackage(self):
        """Test binding to a binary package and doing a lookup"""
        r = self.udd.BindPackage('libc6', 'sid', 'i386')
        self.assertTrue(r)
        self.assertTrue(r.Found())

    def testSource(self):
        """Test binding to a source package and doing a lookup"""
        r = self.udd.BindSourcePackage('glibc', 'sid')
        self.assertTrue(r)
        self.assertTrue(r.Found())
        r = self.udd.BindSourcePackage('libc6', 'sid')
        self.assertTrue(r)
        self.assertTrue(r.Found())
        self.assertTrue(r.data['version'])

    def testBts(self):
        """Test binding to a source package and doing a lookup"""
        tracker = self.udd.Bts(False)
        self.assertFalse(tracker.include_archived)
Beispiel #3
0
class commands(unittest.TestCase):
    def setUp(self):
        self.udd = Udd()
        self.dispatcher = Commands(self.udd)

    def tearDown(self):
        self.udd = None
        self.dispatcher = None

    def testVersions(self):
        """Test version lookups"""
        self.assertTrue(self.dispatcher.versions('libc6', 'sid', 'i386'))
        self.assertRaises(PackageNotFoundError, self.dispatcher.versions, 'nosuchpackage', 'sid', 'i386')
        self.assertRaises(PackageNotFoundError, self.dispatcher.versions, 'libc0.1', 'sid', 'armhf')
        self.assertTrue(self.dispatcher.versions('libc6', None, 'amd64'))
        self.assertTrue(self.dispatcher.versions('src:glibc', 'sid', 'i386'))
        self.assertRaises(PackageNotFoundError, self.dispatcher.versions, 'src:nosuchpackage', 'sid', 'i386')

    def testInfo(self):
        """Test package information lookups"""
        self.assertTrue(self.dispatcher.info('libc6', 'sid', 'i386'))
        self.assertRaises(PackageNotFoundError, self.dispatcher.info, 'nosuchpackage', 'sid', 'i386')
        self.assertRaises(PackageNotFoundError, self.dispatcher.info, 'libc6', 'sid', 'ia64')

    @unittest.skipIf(exclude_slow_tests, 'slow test')
    def testNames(self):
        """Test package name lookups"""
        self.assertTrue(self.dispatcher.names('libc6', 'sid', 'i386'))
        self.assertTrue(self.dispatcher.names('lib?6', 'sid', 'i386'))
        self.assertTrue(self.dispatcher.names('libc6*', 'sid', 'i386'))
        self.assertTrue(self.dispatcher.names('*bc6', 'sid', 'i386'))
        self.assertTrue(self.dispatcher.names('l*6', 'sid', 'i386'))
        self.assertFalse(self.dispatcher.names('libc0.1', 'sid', 'armhf'))
        self.assertTrue(self.dispatcher.names('libc6*', 'sid', 'armhf'))
        self.assertTrue(self.dispatcher.names('src:glibc', 'sid', 'armhf'))
        self.assertFalse(self.dispatcher.names('src:nosuchpackage', 'sid', 'i386'))

    def testArchs(self):
        """Test architecture availability lookups"""
        self.assertTrue(self.dispatcher.archs('libc6', 'sid'))
        self.assertRaises(PackageNotFoundError, self.dispatcher.archs, 'nosuchpackage', 'sid')

    def testPopcon(self):
        """Test popcon data lookups"""
        self.assertTrue(self.dispatcher.popcon('libc6'))
        self.assertRaises(PackageNotFoundError, self.dispatcher.popcon, 'nosuchpackage')

    def testUploads(self):
        """Test upload/maintainer data lookups"""
        self.assertTrue(self.dispatcher.uploads('glibc', max=10))
        self.assertTrue(self.dispatcher.uploads('glibc'))
        self.assertTrue(self.dispatcher.uploads('eglibc', '2.9-11'))
        self.assertRaises(PackageNotFoundError, self.dispatcher.uploads, 'nosuchpackage')
        self.assertRaises(PackageNotFoundError, self.dispatcher.uploads, 'glibc', 'nosuchversion')
        self.assertRaises(PackageNotFoundError, self.dispatcher.uploads, 'libc6')  # only does source packages
        p = self.udd.BindSourcePackage('glibc', 'sid')
        self.assertTrue(self.dispatcher.uploads(p), 'Check uploads with bind to source package failed')
        p = self.udd.BindSourcePackage('libc6', 'sid')
        self.assertTrue(self.dispatcher.uploads(p), 'Check uploads with bind to source package via bin2src failed')

    @unittest.skipIf(exclude_slow_tests, 'slow test')
    def testCheckDeps(self):
        """Test dependency testing for packages"""
        # TODO: it would be nice to actually test the accuracy of the tests
        self.assertTrue(self.dispatcher.checkdeps('libc6', 'sid', 'i386', ['depends']))
        self.assertTrue(self.dispatcher.checkdeps('libc6', 'sid', 'i386', ['depends', 'recommends', 'suggests']))
        self.assertTrue(self.dispatcher.checkdeps('cbedic', 'sid', 'i386', ['suggests']), 'broken relations not handled correctly')
        self.assertRaises(PackageNotFoundError, self.dispatcher.checkdeps, 'nosuchpackage', 'squeeze', 'i386', ['depends'])

    @unittest.skipIf(exclude_slow_tests, 'slow test')
    def testCheckInstall(self):
        """Test installability for packages"""
        # TODO: it would be nice to actually test the accuracy of the tests
        self.assertTrue(self.dispatcher.checkInstall('libc6', 'sid', 'i386', False))
        self.assertTrue(self.dispatcher.checkInstall('perl', 'sid', 'i386', True))
        #self.assertTrue(self.dispatcher.checkInstall('openjdk-6-jre-headless', 'lenny', 'i386', False))
        #self.assertTrue(self.dispatcher.checkInstall('openjdk-6-jre-headless', 'lenny', 'i386', True))
        self.assertRaises(PackageNotFoundError, self.dispatcher.checkInstall, 'nosuchpackage', 'sid', 'i386', True)

    @unittest.skipIf(exclude_slow_tests, 'slow test')
    def testWhy(self):
        """Test existence of package dependency chains"""
        # TODO: it would be nice to actually test the accuracy of the tests
        self.assertTrue(self.dispatcher.why('dpkg', 'libc6', 'squeeze', 'i386', False))
        self.assertEqual(self.dispatcher.why('dpkg', 'dolphin', 'squeeze','i386', False), [])
        self.assertEqual(self.dispatcher.why('dpkg', 'libc6-i686', 'squeeze', 'i386', False), [])
        self.assertTrue(self.dispatcher.why('dpkg', 'libc6-i686', 'squeeze', 'i386', True))
        self.assertEqual(self.dispatcher.why('dpkg', 'nosuchpackage', 'squeeze', 'i386', False), [])
        self.assertRaises(PackageNotFoundError, self.dispatcher.why, 'nosuchpackage', 'dpkg', 'squeeze', 'i386', False)

    @unittest.skipIf(exclude_slow_tests, 'slow test')
    def testCheckBackport(self):
        """Test 'simple sid backport' procedure on packages"""
        # TODO: it would be nice to actually test the accuracy of the tests
        fr = self.udd.BindRelease(arch='i386', release='sid')

        tr = self.udd.BindRelease(arch='i386', release='squeeze')
        self.assertTrue(self.dispatcher.checkBackport('iceweasel', fr, tr), 'Check [im]possible backport that requires bpo')

        trbp = self.udd.BindRelease(arch='i386',
                        release=self.udd.data.list_dependent_releases('squeeze', suffixes=['backports']))
        self.assertTrue(self.dispatcher.checkBackport('libxfont1', fr, trbp), 'Check possible backport that requires bpo')

        tro = self.udd.BindRelease(arch='i386', release="squeeze")
        self.assertTrue(self.dispatcher.checkBackport('gcc', fr, tro), 'Check impossible backport')

        self.assertTrue(self.dispatcher.checkBackport('openjdk-6', fr, tr), 'Check resolution of arch-dependent build-deps')

        self.assertTrue(self.dispatcher.checkBackport('pyxplot', fr, tr), 'Check resolution of virtual build-deps')

        self.assertTrue(self.dispatcher.checkBackport('libv4l-0', fr, tr), 'Check resolution of virtual build-deps')

        self.assertRaises(PackageNotFoundError, self.dispatcher.checkBackport, 'nosuchpackage', fr, tr)