3 from base_test import DakTestCase
7 from daklib.formats import parse_format, validate_changes_format
8 from daklib.dak_exceptions import UnknownFormatError
10 class ParseFormatTestCase(DakTestCase):
11 def assertParse(self, format, expected):
12 self.assertEqual(parse_format(format), expected)
14 def assertParseFail(self, format):
17 lambda: parse_format(format)
21 self.assertParse('1.0', (1, 0))
24 self.assertParseFail('')
25 self.assertParseFail(' ')
26 self.assertParseFail(' ')
29 self.assertParse('1.2 (three)', (1, 2, 'three'))
30 self.assertParseFail('0.0 ()')
32 class ValidateChangesFormat(DakTestCase):
33 def assertValid(self, changes, field='files'):
34 validate_changes_format(changes, field)
36 def assertInvalid(self, *args, **kwargs):
39 lambda: self.assertValid(*args, **kwargs)
45 self.assertValid((1, 5))
46 self.assertValid((1, 8))
47 self.assertInvalid((1, 0))
50 self.assertInvalid((1, 3))
51 self.assertValid((1, 5))
52 self.assertValid((1, 8))
53 self.assertInvalid((1, 9))
55 def testFilesField(self):
56 self.assertInvalid((1, 7), field='notfiles')
57 self.assertValid((1, 8), field='notfiles')
59 if __name__ == '__main__':