def setUp(self): self.summ = pkgsummary.new_summary() pkgsummary.add_summary(self.summ, 'dist', 'pkg', 'X', 0, 'http://foo') self.tmpdir = tempfile.mkdtemp() self.tmpfilename = os.path.join(self.tmpdir, "foo.json") pkgsummary.write_summary(self.summ, self.tmpfilename)
def testSummMerge(self): pkgsummary.add_summary(self.summ, 'dist', 'pkg', 'X', 0, 'http://foo') mergesumm = pkgsummary.new_summary() pkgsummary.merge_summary(mergesumm, self.summ) self.assertEqual(mergesumm['packages']['pkg']['dist'], self.summ['packages']['pkg']['dist']) self.assertEqual(mergesumm['packages']['pkg']['dist'], mergesumm['packages']['pkg']['overall'])
def testSummAddArgValidation(self): with self.assertRaises(pkgsummary.SummaryException): pkgsummary.add_summary(self.summ, 'foodist', 'foopkg', 'Z', 0, 'http://foo') with self.assertRaises(pkgsummary.SummaryException): pkgsummary.add_summary(self.summ, 'foodist', 'foopkg', 'X', 'bogus', 'http://foo') with self.assertRaises(pkgsummary.SummaryException): pkgsummary.add_summary(self.summ, 'foodist', 'foopkg', 'X', 1, 'ittp://foo') pkgsummary.add_summary(self.summ, 'foodist', 'foopkg', 'X', 1, 'http://foo')
def testSummAddBlockCount(self): pkgsummary.add_summary(self.summ, 'dist', 'pkg', 'X', 0, 'http://foo') pkgsummary.add_summary(self.summ, 'dist', 'pkg', 'P', 1, 'http://foo') self.assertEqual(1, self.summ['packages']['pkg']['dist'][1]) pkgsummary.add_summary(self.summ, 'dist', 'pkg', 'F', 2, 'http://foo') self.assertEqual(2, self.summ['packages']['pkg']['dist'][1])
def testSummAddArgValidation(self): with self.assertRaises(pkgsummary.SummaryException): pkgsummary.add_summary( self.summ, 'foodist', 'foopkg', 'Z', 0, 'http://foo') with self.assertRaises(pkgsummary.SummaryException): pkgsummary.add_summary( self.summ, 'foodist', 'foopkg', 'X', 'bogus', 'http://foo') with self.assertRaises(pkgsummary.SummaryException): pkgsummary.add_summary( self.summ, 'foodist', 'foopkg', 'X', 1, 'ittp://foo') pkgsummary.add_summary( self.summ, 'foodist', 'foopkg', 'X', 1, 'http://foo')
def testSummAddOverwriteFlag(self): pkgsummary.add_summary(self.summ, 'dist', 'pkg', 'X', 0, 'http://foo') pkgsummary.add_summary(self.summ, 'dist', 'pkg', 'P', 0, 'http://foo2') self.assertEqual('X', self.summ['packages']['pkg']['dist'][0]) self.assertEqual('http://foo', self.summ['packages']['pkg']['dist'][2]) pkgsummary.add_summary(self.summ, 'dist', 'pkg', 'F', 0, 'http://foo3') self.assertEqual('F', self.summ['packages']['pkg']['dist'][0]) self.assertEqual('http://foo3', self.summ['packages']['pkg']['dist'][2])
def testSummAddArgStorageFormat(self): # store non-overlapping entries pkgsummary.add_summary(self.summ, 'dist', 'pkg', 'X', 0, 'http://foo') pkgsummary.add_summary(self.summ, 'dist', 'pkg2', 'W', 1, 'http://foo2') pkgsummary.add_summary(self.summ, 'dist2', 'pkg3', 'P', 2, 'http://foo3') self.assertEqual(['X', 0, 'http://foo'], self.summ['packages']['pkg']['dist']) self.assertEqual(['W', 1, 'http://foo2'], self.summ['packages']['pkg2']['dist']) self.assertEqual(['P', 2, 'http://foo3'], self.summ['packages']['pkg3']['dist2'])
def testSummAddArgStorageFormat(self): # store non-overlapping entries pkgsummary.add_summary(self.summ, 'dist', 'pkg', 'X', 0, 'http://foo') pkgsummary.add_summary( self.summ, 'dist', 'pkg2', 'W', 1, 'http://foo2') pkgsummary.add_summary( self.summ, 'dist2', 'pkg3', 'P', 2, 'http://foo3') self.assertEqual( ['X', 0, 'http://foo'], self.summ['packages']['pkg']['dist']) self.assertEqual( ['W', 1, 'http://foo2'], self.summ['packages']['pkg2']['dist']) self.assertEqual( ['P', 2, 'http://foo3'], self.summ['packages']['pkg3']['dist2'])