]> git.decadent.org.uk Git - dak.git/blobdiff - tests/test_lintian.py
Move lintian parsing to daklib.lintian and add tests.
[dak.git] / tests / test_lintian.py
diff --git a/tests/test_lintian.py b/tests/test_lintian.py
new file mode 100755 (executable)
index 0000000..99d5e93
--- /dev/null
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+
+from base_test import DakTestCase
+
+import unittest
+
+from daklib.lintian import parse_lintian_output
+
+class ParseLintianTestCase(DakTestCase):
+    def assertParse(self, output, expected):
+        self.assertEqual(
+            list(parse_lintian_output(output)),
+            expected,
+        )
+
+    def testSimple(self):
+        self.assertParse(
+            'W: pkgname: some-tag path/to/file',
+            [('W', 'pkgname', 'some-tag', 'path/to/file')],
+        )
+
+        self.assertParse('', [])
+        self.assertParse('\n\n', [])
+        self.assertParse('dummy error test', [])
+
+    def testBinaryNoDescription(self):
+        self.assertParse(
+            'W: pkgname: some-tag',
+            [('W', 'pkgname', 'some-tag', '')],
+        )
+
+    def testSource(self):
+        self.assertParse(
+            'W: pkgname source: some-tag',
+            [('W', 'pkgname source', 'some-tag', '')]
+        )
+
+    def testSourceNoDescription(self):
+        self.assertParse(
+            'W: pkgname source: some-tag path/to/file',
+            [('W', 'pkgname source', 'some-tag', 'path/to/file')]
+        )
+
+if __name__ == '__main__':
+    unittest.main()