]> git.decadent.org.uk Git - dak.git/blob - tests/test_process_gpgv_output.py
ea1fb337174c48f03e27f009a4c59950b4c9a698
[dak.git] / tests / test_process_gpgv_output.py
1 #!/usr/bin/env python
2
3 from base_test import DakTestCase
4
5 import unittest
6
7 from daklib.utils import process_gpgv_output
8
9 class ProcessGPGVOutputTestCase(DakTestCase):
10     def assertParse(self, input, output):
11         self.assertEqual(process_gpgv_output(input)[0], output)
12
13     def assertNotParse(self, input):
14         ret = process_gpgv_output(input)
15         self.assertNotEqual(len(ret[1]), 0)
16
17     ##
18
19     def testEmpty(self):
20         self.assertParse('', {})
21
22     def testBroken(self):
23         self.assertNotParse('foo')
24         self.assertNotParse('  foo  ')
25         self.assertNotParse('[PREFIXPG:] KEY VAL1 VAL2 VAL3')
26
27     def testSimple(self):
28         self.assertParse(
29             '[GNUPG:] KEY VAL1 VAL2 VAL3',
30             {'KEY': ['VAL1', 'VAL2', 'VAL3']},
31         )
32
33     def testNoKeys(self):
34         self.assertParse('[GNUPG:] KEY', {'KEY': []})
35
36     def testDuplicate(self):
37         self.assertNotParse('[GNUPG:] TEST_KEY\n[GNUPG:] TEST_KEY')
38         self.assertNotParse('[GNUPG:] KEY VAL1\n[GNUPG:] KEY VAL2')
39
40     def testDuplicateSpecial(self):
41         # NODATA and friends are special
42         for special in ('NODATA', 'SIGEXPIRED', 'KEYEXPIRED'):
43             self.assertParse(
44                 '[GNUPG:] %s\n[GNUPG:] %s' % (special, special),
45                 {special: []},
46             )
47
48 if __name__ == '__main__':
49     unittest.main()