class BtsTests(unittest.TestCase): def setUp(self): self.udd = Udd() self.bts = self.udd.Bts(True) self.btsc = self.udd.Bts(False) def tearDown(self): self.bts = None self.btsc = None self.udd = None def testBugs(self): bugs = [500000, 500001, 500002, 666666] self.assertTrue(self.bts.bugs(bugs)) self.assertEqual(len(self.bts.bugs(bugs)), 4) self.assertEqual(len(self.btsc.bugs(bugs)), 0) def testBug(self): b = self.bts.bug(500000) self.assertTrue(b) self.assertEqual(b.title, "cdbs: Please add dh_installdefoma in debhelper.mk") self.assertEqual(b.id, 500000) self.assertEqual(b.severity, "wishlist") self.assertEqual(b.status, "done") self.assertEqual(b.archived, True) self.assertTrue(self.bts.bug("500000")) self.assertTrue(self.bts.bug("544925")) self.assertTrue(self.bts.bug("#500000")) self.assertRaises(BugNotFoundError, self.bts.bug, -1) self.assertRaises(BugNotFoundError, self.bts.bug, 99999999) self.assertRaises(BugNotFoundError, self.btsc.bug, 500000) # bug is archived def test_get_bugs(self): self.assertTrue(self.bts.get_bugs({'package': 'latexdraw'})) self.assertTrue(self.bts.get_bugs({'package': 'pyx' })) # package -> source mapping self.assertTrue(self.btsc.get_bugs({'title': 'RM: '})) self.assertTrue(self.bts.get_bugs({'source': 'latexdraw'})) self.assertFalse(self.btsc.get_bugs({'source': 'spline'})) self.assertTrue( self.bts.get_bugs({ 'source': 'latexdraw', 'sort': 'id DESC' })) self.assertEqual( len(self.bts.get_bugs({ 'source': 'latexdraw', 'limit': 1 })), 1) def test_get_bugs_tags(self): b = self.bts.bug(2297) self.bts.get_bugs_tags(b) self.assertEqual(len(b.tags), 1) bl = self.bts.bugs([500000, 500001, 500002, 620381]) self.bts.get_bugs_tags(bl)
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)