From 3b77b40a6433c23696f40ce33a24fdf2880277f1 Mon Sep 17 00:00:00 2001 From: Chris Lamb Date: Sat, 31 Oct 2009 23:28:41 +0000 Subject: [PATCH] Add tests for process_gpgv_output Signed-off-by: Chris Lamb --- tests/test_process_gpgv_output.py | 49 +++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100755 tests/test_process_gpgv_output.py diff --git a/tests/test_process_gpgv_output.py b/tests/test_process_gpgv_output.py new file mode 100755 index 00000000..ea1fb337 --- /dev/null +++ b/tests/test_process_gpgv_output.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python + +from base_test import DakTestCase + +import unittest + +from daklib.utils import process_gpgv_output + +class ProcessGPGVOutputTestCase(DakTestCase): + def assertParse(self, input, output): + self.assertEqual(process_gpgv_output(input)[0], output) + + def assertNotParse(self, input): + ret = process_gpgv_output(input) + self.assertNotEqual(len(ret[1]), 0) + + ## + + def testEmpty(self): + self.assertParse('', {}) + + def testBroken(self): + self.assertNotParse('foo') + self.assertNotParse(' foo ') + self.assertNotParse('[PREFIXPG:] KEY VAL1 VAL2 VAL3') + + def testSimple(self): + self.assertParse( + '[GNUPG:] KEY VAL1 VAL2 VAL3', + {'KEY': ['VAL1', 'VAL2', 'VAL3']}, + ) + + def testNoKeys(self): + self.assertParse('[GNUPG:] KEY', {'KEY': []}) + + def testDuplicate(self): + self.assertNotParse('[GNUPG:] TEST_KEY\n[GNUPG:] TEST_KEY') + self.assertNotParse('[GNUPG:] KEY VAL1\n[GNUPG:] KEY VAL2') + + def testDuplicateSpecial(self): + # NODATA and friends are special + for special in ('NODATA', 'SIGEXPIRED', 'KEYEXPIRED'): + self.assertParse( + '[GNUPG:] %s\n[GNUPG:] %s' % (special, special), + {special: []}, + ) + +if __name__ == '__main__': + unittest.main() -- 2.39.2