X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=tests%2Ftest_formats.py;fp=tests%2Ftest_formats.py;h=1ae6860aa60659ba890e9f00c31b1c02a9945ac9;hb=e102ad02c396868d6f6c514f42a641e78f7fca9b;hp=8a2b1ad56f27d98064fac0b368139f714e1426f8;hpb=ef55b8c79ae2d3e593aacb7a1f4a3c893bf62094;p=dak.git diff --git a/tests/test_formats.py b/tests/test_formats.py index 8a2b1ad5..1ae6860a 100755 --- a/tests/test_formats.py +++ b/tests/test_formats.py @@ -5,7 +5,7 @@ import unittest import os, sys sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -from daklib.formats import parse_format +from daklib.formats import parse_format, validate_changes_format from daklib.dak_exceptions import UnknownFormatError class ParseFormatTestCase(unittest.TestCase): @@ -29,3 +29,30 @@ class ParseFormatTestCase(unittest.TestCase): def textText(self): self.assertParse('1.2 (three)', (1, 2, 'three')) self.assertParseFail('0.0 ()') + +class ValidateChangesFormat(unittest.TestCase): + def assertValid(self, changes, field='files'): + validate_changes_format(changes, field) + + def assertInvalid(self, *args, **kwargs): + self.assertRaises( + UnknownFormatError, + lambda: self.assertValid(*args, **kwargs) + ) + + ## + + def testBinary(self): + self.assertValid((1, 5)) + self.assertValid((1, 8)) + self.assertInvalid((1, 0)) + + def testRange(self): + self.assertInvalid((1, 3)) + self.assertValid((1, 5)) + self.assertValid((1, 8)) + self.assertInvalid((1, 9)) + + def testFilesField(self): + self.assertInvalid((1, 7), field='notfiles') + self.assertValid((1, 8), field='notfiles')