]> git.decadent.org.uk Git - dak.git/blobdiff - tests/test_srcformats.py
Merge remote-tracking branch 'jcristau/formatone-no-tar-sig'
[dak.git] / tests / test_srcformats.py
index 1e78981b6a9ec45dc3c5cbb4a7bf5b37a0881d02..42ff63898059b0c5c76b771281f0ecf7aa2fb13f 100755 (executable)
@@ -1,17 +1,13 @@
 #!/usr/bin/env python
 
-import unittest
-
-import os, sys
-sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-
-from collections import defaultdict
+from base_test import DakTestCase
 
 from daklib import srcformats
+from collections import defaultdict
 from daklib.formats import parse_format
 from daklib.dak_exceptions import UnknownFormatError
 
-class SourceFormatTestCase(unittest.TestCase):
+class SourceFormatTestCase(DakTestCase):
     def get_rejects(self, has_vars):
         has = defaultdict(lambda: 0)
         has.update(has_vars)
@@ -60,6 +56,12 @@ class FormatOneTestCase(SourceFormatTestCase):
             'native_tar_gz': 1,
             'debian_diff': 1,
         })
+        self.assertRejected({
+            'orig_tar': 1,
+            'orig_tar_gz': 1,
+            'debian_diff': 1,
+            'orig_tar_sig': 1,
+        })
 
 class FormatTreeTestCase(SourceFormatTestCase):
     fmt = srcformats.FormatThree
@@ -104,90 +106,7 @@ class FormatTreeQuiltTestCase(SourceFormatTestCase):
             'native_tar': 1,
         })
 
-##
-
-class ParseFormatTestCase(unittest.TestCase):
-    def assertParse(self, format, expected):
-        self.assertEqual(parse_format(format), expected)
-
-    def assertParseFail(self, format):
-        self.assertRaises(
-            UnknownFormatError,
-            lambda: parse_format(format)
-        )
-
-    def testParse(self):
-        self.assertParse('1.0', (1, 0))
-
-    def testEmpty(self):
-        self.assertParseFail('')
-        self.assertParseFail(' ')
-        self.assertParseFail('  ')
-
-    def textText(self):
-        self.assertParse('1.2 (three)', (1, 2, 'three'))
-        self.assertParseFail('0.0 ()')
-
-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):
-        self.assertRaises(
-            UnknownFormatError,
-            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
-
-    def testValid(self):
-        self.assertValid((3, 0, 'native'))
-
-    def testInvalid(self):
-        self.assertInvalid((1, 0))
-        self.assertInvalid((0, 0))
-        self.assertInvalid((3, 0, 'quilt'))
-
-class ValidateFormatThreeQuiltTestCase(ValidateFormatTestCase):
-    fmt = srcformats.FormatThreeQuilt
-
-    def testValid(self):
-        self.assertValid((3, 0, 'quilt'))
-
-    def testInvalid(self):
-        self.assertInvalid((1, 0))
-        self.assertInvalid((0, 0))
-        self.assertInvalid((3, 0, 'native'))
-
-class FormatFromStringTestCase(unittest.TestCase):
+class FormatFromStringTestCase(DakTestCase):
     def assertFormat(self, txt, klass):
         self.assertEqual(srcformats.get_format_from_string(txt), klass)
 
@@ -210,4 +129,5 @@ class FormatFromStringTestCase(unittest.TestCase):
         self.assertInvalid('8.4 (hardy)')
 
 if __name__ == '__main__':
+    import unittest
     unittest.main()