3 from base_test import DakTestCase
7 from daklib.lintian import parse_lintian_output, generate_reject_messages
9 class ParseLintianTestCase(DakTestCase):
10 def assertParse(self, output, expected):
12 list(parse_lintian_output(output)),
18 'W: pkgname: some-tag path/to/file', [{
22 'description': 'path/to/file',
26 self.assertParse('', [])
27 self.assertParse('\n\n', [])
28 self.assertParse('dummy error test', [])
30 def testBinaryNoDescription(self):
32 'W: pkgname: some-tag', [{
42 'W: pkgname source: some-tag', [{
44 'package': 'pkgname source',
50 def testSourceNoDescription(self):
52 'W: pkgname source: some-tag path/to/file', [{
54 'package': 'pkgname source',
56 'description': 'path/to/file',
60 class GenerateRejectMessages(DakTestCase):
61 def assertNumReject(self, input, defs, num):
62 msgs = list(generate_reject_messages(input, defs))
63 self.assertEqual(len(msgs), num)
65 def testUnknownTag(self):
66 self.assertNumReject([
73 ], {'fatal': ['known-tag'], 'nonfatal': []},
77 def testFatalTags(self):
78 self.assertNumReject([
91 ], {'fatal': ['fatal-tag-1', 'fatal-tag-2'], 'nonfatal': []},
95 def testMixture(self):
96 self.assertNumReject([
105 'package': 'pkgname',
106 'tag': 'unknown-tag',
109 ], {'fatal': ['fatal-tag'], 'nonfatal': []},
113 def testOverridable(self):
114 self.assertNumReject([
117 'package': 'pkgname',
118 'tag': 'non-fatal-tag',
121 ], {'fatal': [], 'nonfatal': ['non-fatal-tag']},
122 1 + 1, # We add an extra 'reject' hint message
125 def testOverrideAllowed(self):
126 self.assertNumReject([
128 'package': 'pkgname',
129 'tag': 'non-fatal-tag',
131 ], {'fatal': [], 'nonfatal': ['non-fatal-tag']},
135 def testOverrideNotAllowed(self):
136 self.assertNumReject([
139 'package': 'pkgname',
143 ], {'fatal': ['fatal-tag'], 'nonfatal': []},
147 if __name__ == '__main__':