Browse Source

improve unittests coverage of reportbug.debianbts

suites/jessie-proposed-backports
Sandro Tosi 11 years ago
parent
commit
5aa64bbcd1
  1. 3
      reportbug/debianbts.py
  2. 77
      test/test_debianbts.py

3
reportbug/debianbts.py

@ -771,12 +771,14 @@ def cgi_package_url(system, package, archived=False, source=False,
#print qstr
return '%spkgreport.cgi?%s' % (root, qstr)
# TODO: to be removed
def package_url(system, package, mirrors=None, source=False,
repeatmerged=True):
btsroot=get_btsroot(system, mirrors)
package = urllib.quote_plus(package.lower())
return btsroot+('db/pa/l%s.html' % package)
# TODO: to be removed
def report_url(system, number, mirrors=None):
number = str(number)
if len(number) < 2: return None
@ -1018,6 +1020,7 @@ class BTSParser(sgmllib.SGMLParser):
if fixed:
self.hierarchy = [('Bugs fixed in subsequent releases (%d bugs)' % len(fixed), fixed)] + newhierarchy
# TODO: to be removed
def parse_html_report(number, url, http_proxy, timeout, followups=False, cgi=True):
page = open_url(url, http_proxy, timeout)
if not page:

77
test/test_debianbts.py

@ -1,5 +1,7 @@
import unittest2
from nose.plugins.attrib import attr
from reportbug import utils
from reportbug import debianbts
@ -75,10 +77,73 @@ class TestMiscFunctions(unittest2.TestCase):
self.assertEqual(debianbts.yn_bool('yes'), 'yes')
self.assertEqual(debianbts.yn_bool('dummy string'), 'yes')
def test_convert_severity(self):
# lists of bts systems, severity and the expected value in return
sevs = [('debbugs', 'critical', 'critical'),
('debbugs', 'non-critical', 'normal'),
(None, 'dummy', 'dummy'),
('gnats', 'important', 'serious'),
('gnats', 'dummy', 'dummy')]
for type, severity, value in sevs:
self.assertEqual(debianbts.convert_severity(severity, type), value)
class TestGetReports(unittest2.TestCase):
@attr('network') #marking the test as using network
def test_get_cgi_reports(self):
data = debianbts.get_cgi_reports('reportbug', timeout=60)
self.assertGreater(data[0], 0)
@attr('network') #marking the test as using network
def test_get_reports(self):
data = debianbts.get_reports('reportbug', timeout=60)
self.assertGreater(data[0], 0)
@attr('network') #marking the test as using network
def test_get_report(self):
data = debianbts.get_report(415801, 120)
self.assertEqual(data[0],
'#415801: reportbug: add support for SOAP interface to BTS')
class TestUrlFunctions(unittest2.TestCase):
def test_cgi_report_url(self):
self.assertEqual(debianbts.cgi_report_url('debian', 123),
'http://bugs.debian.org/cgi-bin/bugreport.cgi?' +
'bug=123&archived=False&mbox=no')
self.assertIsNone(debianbts.cgi_report_url('default', 123))
def test_cgi_package_url(self):
self.assertEqual(debianbts.cgi_package_url('debian', 'reportbug'),
'http://bugs.debian.org/cgi-bin/pkgreport.cgi?' +
'archived=no&pkg=reportbug&repeatmerged=yes')
self.assertEqual(debianbts.cgi_package_url
('debian', 'reportbug', source=True),
'http://bugs.debian.org/cgi-bin/pkgreport.cgi?src=' +
'reportbug&archived=no&repeatmerged=yes')
self.assertEqual(debianbts.cgi_package_url
('debian', 'reportbug', version='5.0'),
'http://bugs.debian.org/cgi-bin/pkgreport.cgi?archi' +
'ved=no&version=5.0&pkg=reportbug&repeatmerged=yes')
def test_get_package_url(self):
self.assertEqual(debianbts.get_package_url('debian', 'reportbug'),
'http://bugs.debian.org/cgi-bin/pkgreport.cgi?archi' +
'ved=no&pkg=reportbug&repeatmerged=yes')
def test_get_report_url(self):
#class TestNetwork(unittest2.TestCase):
#
# def test_get_cgi_reports(self):
#
# data = debianbts.get_cgi_reports('reportbug', timeout=60)
# self.assertGreater(len(data), 0)
self.assertEqual(debianbts.get_report_url('debian', 123),
'http://bugs.debian.org/cgi-bin/bugreport.cgi?' +
'bug=123&archived=False&mbox=no')

Loading…
Cancel
Save