[Reportbug-commits] [SCM] Reportbug - reports bugs in the Debian distribution branch, master, updated. 4.9-140-g5ccf988
Sandro Tosi
morph at debian.org
Thu Dec 2 00:07:06 UTC 2010
The following commit has been merged in the master branch:
commit f764fbcbfbc66e7c3819c57f4fa7179311f444e1
Author: Sandro Tosi <morph at debian.org>
Date: Mon Nov 1 12:13:49 2010 +0100
improve unit tests coverage
diff --git a/tests/test_hiermatch.py b/tests/test_hiermatch.py
index c4b135c..aceb377 100644
--- a/tests/test_hiermatch.py
+++ b/tests/test_hiermatch.py
@@ -1,6 +1,6 @@
import unittest2
-from reportbug import hiermatch
+from reportbug import hiermatch, exceptions
test_strings_list = ['Beautiful is better than ugly.',
'Explicit is better than implicit.',
@@ -12,6 +12,11 @@ test_strings_list = ['Beautiful is better than ugly.',
class TestHiermatch(unittest2.TestCase):
def test_egrep_list(self):
- matches = hiermatch.egrep_list(test_strings_list, 'better')
+ res = hiermatch.egrep_list(None, '')
+ self.assertIsNone(res)
+
+ with self.assertRaises(exceptions.InvalidRegex):
+ matches = hiermatch.egrep_list(test_strings_list, 42)
+ matches = hiermatch.egrep_list(test_strings_list, 'better')
self.assertEqual(len(matches), 6)
diff --git a/tests/test_ui.py b/tests/test_ui.py
index 7a80105..6af84fb 100644
--- a/tests/test_ui.py
+++ b/tests/test_ui.py
@@ -4,9 +4,15 @@ import unittest2
from reportbug import utils
from reportbug import ui
+from reportbug.ui import __LOADED_UIS as LOADED_UIS
class TestUI(unittest2.TestCase):
def test_ui(self):
self.assertItemsEqual(ui.AVAILABLE_UIS, ['text', 'urwid', 'gtk2'])
-
+
+ def test_getUI(self):
+ for loaded_ui in LOADED_UIS.keys():
+ self.assertEqual(ui.getUI(loaded_ui), LOADED_UIS[loaded_ui])
+
+ self.assertEqual(ui.getUI('non-existing'), LOADED_UIS['text'])
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 4d7f6ae..3904fd7 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -18,6 +18,11 @@ class TestEmail(unittest2.TestCase):
self.assertTrue(utils.check_email_addr(real_addr))
self.assertFalse(utils.check_email_addr('dummy'))
self.assertFalse(utils.check_email_addr('nouser at nodomain'))
+ self.assertFalse(utils.check_email_addr('.nouser at nodomain'))
+ self.assertFalse(utils.check_email_addr('nouser. at nodomain'))
+ self.assertFalse(utils.check_email_addr('nouser at .nodomain'))
+ self.assertFalse(utils.check_email_addr('nouser at nodomain.'))
+ self.assertFalse(utils.check_email_addr('too at many@at at signs'))
def test_get_email_addr(self):
@@ -73,14 +78,63 @@ class TestPackages(unittest2.TestCase):
self.assertIsNotNone(fulldesc)
self.assertEqual(state, 'installed')
- at unittest2.skip("Too slow")
+ def test_find_package_for(self):
+ result = utils.find_package_for('dpkg')
+ self.assertNotEqual(result[1], {})
+
+ result = utils.find_package_for('/usr/bin/reportbug')
+ self.assertNotEqual(result[1], {})
+
+ result = utils.find_package_for('/var/lib/dpkg/info/reportbug.md5sums')
+ self.assertNotEqual(result[1], {})
+
+ result = utils.find_package_for('/usr/bin/')
+ self.assertNotEqual(result[1], {})
+
+ def test_get_package_info(self):
+
+ result = utils.get_package_info([])
+ self.assertEqual(result, [])
+
+ pkg = 'reportbug'
+ result = utils.get_package_info([((pkg,), pkg)])
+
+ self.assertEqual(len(result), 1)
+ self.assertEqual(result[0][0], pkg)
+
+ # open package surely not available on my client systems
+ #to cover line 568
+ pkg = 'slapd'
+ result = utils.get_package_info([((pkg,), pkg)])
+
+ self.assertEqual(result[0][0], pkg)
+ self.assertEqual(result[0][2], '<none>')
+
+ result = utils.get_package_info([((pkg,), pkg)], skip_notfound=True)
+
+ self.assertEqual(result, [])
+
+ # package with a Provides
+ #pkg = 'emacs'
+ #result = utils.get_package_info([((pkg,), pkg)])
+
+ #self.assertEqual(result[0][0], pkg)
+
+ def test_packages_providing(self):
+ pkg = 'editor'
+ result = utils.packages_providing(pkg)
+
+ self.assertGreater(len(result), 0)
+
class TestSourcePackages(unittest2.TestCase):
+ @unittest2.skip("Too slow")
def test_get_source_name(self):
binpkg = 'python-reportbug'
src = utils.get_source_name(binpkg)
self.assertEqual(src, 'reportbug')
+ @unittest2.skip("Too slow")
def test_get_source_package(self):
src = 'reportbug'
binpkgs = utils.get_source_package(src)
@@ -96,3 +150,36 @@ class TestSystemInformation(unittest2.TestCase):
cores = utils.get_cpu_cores()
self.assertGreaterEqual(cores, 1)
+
+class TestMua(unittest2.TestCase):
+
+ def test_mua_is_supported(self):
+
+ for mua in ('mh', 'nmh', 'gnus', 'mutt'):
+ self.assertTrue(utils.mua_is_supported(mua))
+
+ self.assertFalse(utils.mua_is_supported('mua-of-my-dreams'))
+
+ def test_mua_exists(self):
+
+ for mua in ('mh', 'nmh', 'gnus', 'mutt'):
+ self.assertTrue(utils.mua_exists(mua))
+
+ def test_mua_name(self):
+
+ for mua in ('mh', 'nmh', 'gnus', 'mutt'):
+ self.assertIsInstance(utils.mua_name(mua), utils.Mua)
+
+ self.assertEqual(utils.mua_name('mua-of-my-dreams'), 'mua-of-my-dreams')
+
+class TestBugreportBody(unittest2.TestCase):
+
+ def test_get_dependency_info(self):
+
+ pkg = 'reportbug'
+ result = utils.get_dependency_info('reportbug', '')
+
+ self.assertIn('no packages', result)
+
+ result = utils.get_dependency_info('reportbug', [['dpkg']])
+ self.assertIn('dpkg', result)
--
Reportbug - reports bugs in the Debian distribution
More information about the Reportbug-commits
mailing list