3 from base_test import DakTestCase, fixture
7 from daklib.utils import parse_changes
8 from daklib.dak_exceptions import InvalidDscError, ParseChangesError
10 class ParseChangesTestCase(DakTestCase):
11 def assertParse(self, filename, *args):
12 return parse_changes(fixture(filename), *args)
14 def assertFails(self, filename, line=None, *args):
16 self.assertParse(filename, *args)
17 self.fail('%s was not recognised as invalid' % filename)
18 except ParseChangesError:
20 except InvalidDscError, actual_line:
22 assertEqual(actual_line, line)
24 class ParseDscTestCase(ParseChangesTestCase):
26 self.assertParse('dsc/1.dsc', 0, 1)
28 def test_1_ignoreErrors(self):
29 # Valid .dsc ; ignoring errors
30 self.assertParse('dsc/1.dsc', 0, 1)
33 # Missing blank line before signature body
34 self.assertParse('dsc/2.dsc', 0, 1)
36 def test_2_ignoreErrors(self):
37 # Invalid .dsc ; ignoring errors
38 self.assertParse('dsc/2.dsc', 0, 1)
41 # Missing blank line after signature header
42 self.assertParse('dsc/3.dsc', 0, 1)
45 # No blank lines at all
46 self.assertParse('dsc/4.dsc', 0, 1)
49 # Extra blank line before signature body
50 self.assertParse('dsc/5.dsc', 0, 1)
53 # Extra blank line after signature header
54 self.assertParse('dsc/6.dsc', 0, 1)
56 class ParseChangesTestCase(ParseChangesTestCase):
59 self.assertFails('changes/1.changes', line=5)
62 changes = self.assertParse('changes/2.changes', 0)
64 binaries = changes['binary']
66 self.assert_('krb5-ftpd' in binaries.split())
69 for filename in ('valid', 'bogus-pre', 'bogus-post'):
70 for strict_whitespace in (0, 1):
71 changes = self.assertParse(
72 'changes/%s.changes' % filename,
75 self.failIf(changes.get('you'))
77 if __name__ == '__main__':