re_gpg_uid, re_re_mark, re_whitespace_comment, re_issource, \
re_is_orig_source
+from formats import parse_format, validate_changes_format
from srcformats import get_format_from_string
from collections import defaultdict
if not changes.has_key(field):
raise NoFilesFieldError
- # Get SourceFormat object for this Format and validate it
- format = get_format_from_string(changes['format'])
- format.validate_format(is_a_dsc=is_a_dsc, field=field)
+ # Validate .changes Format: field
+ validate_changes_format(parse_format(changes['format']), field)
includes_section = (not is_a_dsc) and field == "files"
class ValidateFormatTestCase(unittest.TestCase):
def assertValid(self, format, **kwargs):
- kwargs['is_a_dsc'] = kwargs.get('is_a_dsc', True)
self.fmt.validate_format(format, **kwargs)
def assertInvalid(self, *args, **kwargs):
lambda: self.assertValid(*args, **kwargs),
)
-class ValidateFormatOneTestCase(ValidateFormatTestCase):
- fmt = srcformats.FormatOne
-
- def testValid(self):
- self.assertValid((1, 0))
-
- def testInvalid(self):
- self.assertInvalid((0, 1))
- self.assertInvalid((3, 0, 'quilt'))
-
- ##
-
- def testBinary(self):
- self.assertValid((1, 5), is_a_dsc=False)
- self.assertInvalid((1, 0), is_a_dsc=False)
-
- def testRange(self):
- self.assertInvalid((1, 3), is_a_dsc=False)
- self.assertValid((1, 5), is_a_dsc=False)
- self.assertValid((1, 8), is_a_dsc=False)
- self.assertInvalid((1, 9), is_a_dsc=False)
-
- def testFilesField(self):
- self.assertInvalid((1, 7), is_a_dsc=False, field='notfiles')
- self.assertValid((1, 8), is_a_dsc=False, field='notfiles')
-
class ValidateFormatThreeTestCase(ValidateFormatTestCase):
fmt = srcformats.FormatThree