Browse Source

convert reportbug.debbugs to py3k

- remove BTSParser, now that we are using SOAP
master
Sandro Tosi 6 years ago
parent
commit
7b676cd9cf
  1. 297
      reportbug/debbugs.py
  2. 126
      test/test_debbugs.py

297
reportbug/debbugs.py

@ -21,37 +21,36 @@
# ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
# SOFTWARE.
import utils
from . import utils
import sys
import mailbox
import email
import email.parser
import email.Errors
import cStringIO
import sgmllib
import email.errors
import io
import glob
import os
import re
import time
import urllib
import urllib.request, urllib.parse, urllib.error
import textwrap
import pprint
# SOAP interface to Debian BTS
import debianbts
from collections import defaultdict
import checkversions
from exceptions import (
from . import checkversions
from .exceptions import (
NoNetwork,
QuertBTSError,
)
from urlutils import open_url
from .urlutils import open_url
def msgfactory(fp):
try:
return email.message_from_file(fp)
except email.Errors.MessageParseError:
except email.errors.MessageParseError:
# Don't return None since that will
# stop the mailbox iterator
return ''
@ -455,7 +454,7 @@ def handle_debian_release(package, bts, ui, fromaddr, timeout, online=True, http
# FIXME: pu/rm should lookup the version elsewhere
version = info and info[0]
if online and tag.endswith('-pu'):
version = checkversions.get_versions_available(package, timeout, (tag[:-3],)).values()[0]
version = list(checkversions.get_versions_available(package, timeout, (tag[:-3],)).values())[0]
if version:
cont = ui.select_options(
"Latest version seems to be %s, is this the proper one ?" % (version),
@ -552,7 +551,7 @@ def handle_debian_release(package, bts, ui, fromaddr, timeout, online=True, http
good = ".depends ~ " + j(listgood)
bad = ".depends ~ " + j(listbad)
body += textwrap.dedent(u"""\
body += textwrap.dedent("""\
Ben file:
@ -568,7 +567,7 @@ def handle_debian_release(package, bts, ui, fromaddr, timeout, online=True, http
body = ''
elif tag == 'unblock':
subject = 'unblock: %s/%s' % (package, version)
body = textwrap.dedent(u"""\
body = textwrap.dedent("""\
Please unblock package %s
(explain the reason for the unblock here)
@ -587,7 +586,7 @@ def handle_debian_release(package, bts, ui, fromaddr, timeout, online=True, http
return (subject, severity, headers, pseudos, body, query)
itp_template = textwrap.dedent(u"""\
itp_template = textwrap.dedent("""\
* Package name : %(package)s
Version : x.y.z
Upstream Author : Name <somebody@example.org>
@ -671,7 +670,7 @@ def handle_wnpp(package, bts, ui, fromaddr, timeout, online=True, http_proxy=Non
if tag == 'ITP':
headers.append('X-Debbugs-CC: debian-devel@lists.debian.org')
pseudos.append(u'Owner: %s' % fromaddr.decode('utf-8', 'replace'))
pseudos.append('Owner: %s' % fromaddr.decode('utf-8', 'replace'))
ui.log_message('Your report will be carbon-copied to debian-devel, '
'per Debian policy.\n')
@ -731,13 +730,13 @@ def dpkg_infofunc():
multiarch = utils.get_multiarch()
if debarch:
if utsmachine == debarch:
debinfo = u'Architecture: %s\n' % debarch
debinfo = 'Architecture: %s\n' % debarch
else:
debinfo = u'Architecture: %s (%s)\n' % (debarch, utsmachine)
debinfo = 'Architecture: %s (%s)\n' % (debarch, utsmachine)
else:
debinfo = u'Architecture: ? (%s)\n' % utsmachine
debinfo = 'Architecture: ? (%s)\n' % utsmachine
if multiarch:
debinfo += u'Foreign Architectures: %s\n' % multiarch
debinfo += 'Foreign Architectures: %s\n' % multiarch
debinfo += '\n'
return debinfo
@ -752,7 +751,7 @@ def ubuntu_infofunc():
def generic_infofunc():
utsmachine = os.uname()[4]
return utils.lsb_release_info() + u'Architecture: %s\n\n' % utsmachine
return utils.lsb_release_info() + 'Architecture: %s\n\n' % utsmachine
# Supported servers
@ -868,7 +867,7 @@ def cgi_package_url(system, package, archived=False, source=False,
if version:
query['version'] = str(version)
qstr = urllib.urlencode(query)
qstr = urllib.parse.urlencode(query)
# print qstr
return '%spkgreport.cgi?%s' % (root, qstr)
@ -877,7 +876,7 @@ def cgi_package_url(system, package, archived=False, source=False,
def package_url(system, package, mirrors=None, source=False,
repeatmerged=True):
btsroot = get_btsroot(system, mirrors)
package = urllib.quote_plus(package.lower())
package = urllib.parse.quote_plus(package.lower())
return btsroot + ('db/pa/l%s.html' % package)
@ -918,7 +917,7 @@ def parse_bts_url(url):
# Dynamically add any additional systems found
for origin in glob.glob('/etc/dpkg/origins/*'):
try:
fp = file(origin)
fp = open(origin)
system = os.path.basename(origin)
SYSTEMS[system] = SYSTEMS.get(system, {'otherpkgs': {},
'query-dpkg': True,
@ -950,198 +949,6 @@ for origin in glob.glob('/etc/dpkg/origins/*'):
pass
# For summary pages, we want to keep:
#
# - Contents of <title>...</title>
# - Contents of <h2>...</h2>
# - Contents of each <li>
#
# For individual bugs, we want to keep:
# - Contents of <title>...</title>
# - Contents of every <pre>...</pre> after a <h2>....</h2> tag.
class BTSParser(sgmllib.SGMLParser):
def __init__(self, mode='summary', cgi=False, followups=False):
import warnings
warnings.warn('BTSParse is Deprecated, report a bug if you see this',
DeprecationWarning)
sgmllib.SGMLParser.__init__(self)
self.hierarchy = []
self.lidata = None
self.lidatalist = None
self.savedata = None
self.title = None
self.bugcount = 0
self.mode = mode
self.cgi = cgi
self.followups = followups
self.inbuglist = self.intrailerinfo = False
self.bugtitle = None
if followups:
self.preblock = []
else:
self.preblock = ''
self.endh2 = False
# --- Formatter interface, taking care of 'savedata' mode;
# shouldn't need to be overridden
def handle_data(self, data):
if self.savedata is not None:
self.savedata += data
# --- Hooks to save data; shouldn't need to be overridden
def save_bgn(self):
self.savedata = ''
def save_end(self, mode=False):
data = self.savedata
if not mode and data:
data = ' '.join(data.split())
self.savedata = None
return data
def start_h1(self, attrs):
self.save_bgn()
self.oldmode = self.mode
self.mode = 'title'
def end_h1(self):
self.title = self.save_end()
self.mode = self.oldmode
def start_h2(self, attrs):
if self.lidata:
self.check_li()
self.save_bgn()
def end_h2(self):
if self.mode == 'summary':
hiertitle = self.save_end()
if 'bug' in hiertitle:
self.hierarchy.append((hiertitle, []))
self.endh2 = True # We are at the end of a title, flag <pre>
def start_ul(self, attrs):
if self.mode == 'summary':
for k, v in attrs:
if k == 'class' and v == 'bugs':
self.inbuglist = True
def end_ul(self):
if self.inbuglist:
self.check_li()
self.inbuglist = False
def do_br(self, attrs):
if self.mode == 'title':
self.savedata = ""
elif self.mode == 'summary' and self.inbuglist and not self.intrailerinfo:
self.bugtitle = self.save_end()
self.intrailerinfo = True
self.save_bgn()
def check_li(self):
if self.mode == 'summary':
if not self.intrailerinfo:
self.bugtitle = self.save_end()
trailinfo = ''
else:
trailinfo = self.save_end()
match = re.search(r'fixed:\s+([\w.+~-]+(\s+[\w.+~:-]+)?)', trailinfo)
if match:
title = self.bugtitle
bits = re.split(r':\s+', title, 1)
if len(bits) > 1:
buginfo = '%s [FIXED %s]: %s' % (
bits[0], match.group(1), bits[1])
else:
if title.endswith(':'):
title = title[:-1]
buginfo = '%s [FIXED %s]' % (title, match.group(1))
else:
buginfo = self.bugtitle
self.lidatalist.append(buginfo)
self.bugcount += 1
self.lidata = self.intrailerinfo = False
def do_li(self, attrs):
if self.mode == 'summary' and self.inbuglist:
if self.lidata:
self.check_li()
self.lidata = True
if self.hierarchy:
self.lidatalist = self.hierarchy[-1][1]
else:
self.lidatalist = []
self.save_bgn()
def start_pre(self, attrs):
"Save <pre> when we follow a </h2>"
if self.followups:
if not self.endh2:
return
else:
if self.cgi and self.preblock:
return
self.save_bgn()
def end_pre(self):
if self.followups:
if not self.endh2:
return
self.endh2 = False # Done with a report, reset </h2>.
stuff = self.save_end(1)
if not self.cgi:
self.preblock.insert(0, stuff)
else:
self.preblock.append(stuff)
elif not (self.preblock and self.cgi):
self.preblock = self.save_end(1)
def reorganize(self):
if not self.hierarchy:
return
newhierarchy = []
fixed = []
fixedfinder = re.compile(r'\[FIXED ([^\]]+)\]')
resolvedfinder = re.compile(r'Resolved')
for (title, buglist) in self.hierarchy:
if 'Resolved' in title:
newhierarchy.append((title, buglist))
continue
bugs = []
for bug in buglist:
if fixedfinder.search(bug):
fixed.append(bug)
else:
bugs.append(bug)
if bugs:
title = ' '.join(title.split()[:-2])
if len(bugs) != 1:
title += ' (%d bugs)' % len(bugs)
else:
title += ' (1 bug)'
newhierarchy.append((title, bugs))
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)
@ -1193,7 +1000,7 @@ def parse_mbox_report(number, url, http_proxy, timeout, followups=False):
return None
# Make this seekable
wholefile = cStringIO.StringIO(page.read())
wholefile = io.StringIO(page.read())
try:
page.fp._sock.recv = None
@ -1244,60 +1051,6 @@ def parse_mbox_report(number, url, http_proxy, timeout, followups=False):
return (title, output)
def get_cgi_reports(package, timeout, system='debian', http_proxy='',
archived=False, source=False, version=None):
try:
page = open_url(cgi_package_url(system, package, archived, source,
version=version), http_proxy, timeout)
except:
raise NoNetwork
if not page:
return (0, None, None)
# content = page.read()
# if 'Maintainer' not in content:
# return (0, None, None)
parser = BTSParser(cgi=True)
for line in page:
try:
line = line.decode('utf-8') # BTS pages are encoded in utf-8
except UnicodeDecodeError:
# page has a bad char
line = line.decode('utf-8', 'replace')
parser.feed(line)
parser.close()
try:
page.fp._sock.recv = None
except:
pass
page.close()
# Reorganize hierarchy to put recently-fixed bugs at top
parser.reorganize()
# Morph @ 2008-08-15; due to BTS output format changes
try:
parser.hierarchy.remove(('Select bugs', []))
except:
pass
data = (parser.bugcount, parser.title, parser.hierarchy)
del parser
return data
def get_cgi_report(number, timeout, system='debian', http_proxy='', archived=False,
followups=False):
number = int(number)
url = cgi_report_url(system, number, archived='no', mbox=True)
return parse_mbox_report(number, url, http_proxy, timeout, followups)
# return parse_html_report(number, url, http_proxy, followups, cgi=True)
def get_btsroot(system, mirrors=None):
if mirrors:
alternates = SYSTEMS[system].get('mirrors')
@ -1310,14 +1063,14 @@ def get_btsroot(system, mirrors=None):
def get_reports(package, timeout, system='debian', mirrors=None, version=None,
http_proxy='', archived=False, source=False):
if system == 'debian':
if isinstance(package, basestring):
if isinstance(package, str):
if source:
pkg_filter = 'src'
else:
pkg_filter = 'package'
bugs = debianbts.get_bugs(pkg_filter, package)
else:
bugs = map(int, package)
bugs = list(map(int, package))
try:
# retrieve bugs and generate the hierarchy
@ -1344,7 +1097,7 @@ def get_reports(package, timeout, system='debian', mirrors=None, version=None,
return (len(bugs), 'Bug reports for %s' % package, hier)
# XXX: is the code below used at all now? can we remove it?
if isinstance(package, basestring):
if isinstance(package, str):
if SYSTEMS[system].get('cgiroot'):
try:
result = get_cgi_reports(package, timeout, system, http_proxy, archived,

126
test/test_debbugs.py

@ -1,95 +1,95 @@
import unittest2
import unittest
from nose.plugins.attrib import attr
import mock
from reportbug import utils
from reportbug import debbugs
import urllib
import urllib.request, urllib.parse, urllib.error
import re
class TestDebianbts(unittest2.TestCase):
class TestDebianbts(unittest.TestCase):
def test_get_tags(self):
# for each severity, for each mode
self.assertItemsEqual(debbugs.get_tags('critical', utils.MODE_NOVICE).keys(),
self.assertCountEqual(list(debbugs.get_tags('critical', utils.MODE_NOVICE).keys()),
['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'security', 'patch', 'newcomer'])
self.assertItemsEqual(debbugs.get_tags('grave', utils.MODE_NOVICE).keys(),
self.assertCountEqual(list(debbugs.get_tags('grave', utils.MODE_NOVICE).keys()),
['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'security', 'patch', 'newcomer'])
self.assertItemsEqual(debbugs.get_tags('serious', utils.MODE_NOVICE).keys(),
self.assertCountEqual(list(debbugs.get_tags('serious', utils.MODE_NOVICE).keys()),
['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'security', 'patch', 'newcomer'])
self.assertItemsEqual(debbugs.get_tags('important', utils.MODE_NOVICE).keys(),
self.assertCountEqual(list(debbugs.get_tags('important', utils.MODE_NOVICE).keys()),
['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'patch', 'newcomer'])
self.assertItemsEqual(debbugs.get_tags('does-not-build', utils.MODE_NOVICE).keys(),
self.assertCountEqual(list(debbugs.get_tags('does-not-build', utils.MODE_NOVICE).keys()),
['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'patch', 'newcomer'])
self.assertItemsEqual(debbugs.get_tags('normal', utils.MODE_NOVICE).keys(),
self.assertCountEqual(list(debbugs.get_tags('normal', utils.MODE_NOVICE).keys()),
['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'patch', 'newcomer'])
self.assertItemsEqual(debbugs.get_tags('non-critical', utils.MODE_NOVICE).keys(),
self.assertCountEqual(list(debbugs.get_tags('non-critical', utils.MODE_NOVICE).keys()),
['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'patch', 'newcomer'])
self.assertItemsEqual(debbugs.get_tags('minor', utils.MODE_NOVICE).keys(),
self.assertCountEqual(list(debbugs.get_tags('minor', utils.MODE_NOVICE).keys()),
['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'patch', 'newcomer'])
self.assertItemsEqual(debbugs.get_tags('wishlist', utils.MODE_NOVICE).keys(),
self.assertCountEqual(list(debbugs.get_tags('wishlist', utils.MODE_NOVICE).keys()),
['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'patch', 'newcomer'])
self.assertItemsEqual(debbugs.get_tags('critical', utils.MODE_STANDARD).keys(),
self.assertCountEqual(list(debbugs.get_tags('critical', utils.MODE_STANDARD).keys()),
['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'security', 'patch', 'newcomer'])
self.assertItemsEqual(debbugs.get_tags('grave', utils.MODE_STANDARD).keys(),
self.assertCountEqual(list(debbugs.get_tags('grave', utils.MODE_STANDARD).keys()),
['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'security', 'patch', 'newcomer'])
self.assertItemsEqual(debbugs.get_tags('serious', utils.MODE_STANDARD).keys(),
self.assertCountEqual(list(debbugs.get_tags('serious', utils.MODE_STANDARD).keys()),
['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'security', 'patch', 'newcomer'])
self.assertItemsEqual(debbugs.get_tags('important', utils.MODE_STANDARD).keys(),
self.assertCountEqual(list(debbugs.get_tags('important', utils.MODE_STANDARD).keys()),
['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'patch', 'newcomer'])
self.assertItemsEqual(debbugs.get_tags('does-not-build', utils.MODE_STANDARD).keys(),
self.assertCountEqual(list(debbugs.get_tags('does-not-build', utils.MODE_STANDARD).keys()),
['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'patch', 'newcomer'])
self.assertItemsEqual(debbugs.get_tags('normal', utils.MODE_STANDARD).keys(),
self.assertCountEqual(list(debbugs.get_tags('normal', utils.MODE_STANDARD).keys()),
['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'patch', 'newcomer'])
self.assertItemsEqual(debbugs.get_tags('non-critical', utils.MODE_STANDARD).keys(),
self.assertCountEqual(list(debbugs.get_tags('non-critical', utils.MODE_STANDARD).keys()),
['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'patch', 'newcomer'])
self.assertItemsEqual(debbugs.get_tags('minor', utils.MODE_STANDARD).keys(),
self.assertCountEqual(list(debbugs.get_tags('minor', utils.MODE_STANDARD).keys()),
['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'patch', 'newcomer'])
self.assertItemsEqual(debbugs.get_tags('wishlist', utils.MODE_STANDARD).keys(),
self.assertCountEqual(list(debbugs.get_tags('wishlist', utils.MODE_STANDARD).keys()),
['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'patch', 'newcomer'])
self.assertItemsEqual(debbugs.get_tags('critical', utils.MODE_ADVANCED).keys(),
self.assertCountEqual(list(debbugs.get_tags('critical', utils.MODE_ADVANCED).keys()),
['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
self.assertItemsEqual(debbugs.get_tags('grave', utils.MODE_ADVANCED).keys(),
self.assertCountEqual(list(debbugs.get_tags('grave', utils.MODE_ADVANCED).keys()),
['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
self.assertItemsEqual(debbugs.get_tags('serious', utils.MODE_ADVANCED).keys(),
self.assertCountEqual(list(debbugs.get_tags('serious', utils.MODE_ADVANCED).keys()),
['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
self.assertItemsEqual(debbugs.get_tags('important', utils.MODE_ADVANCED).keys(),
self.assertCountEqual(list(debbugs.get_tags('important', utils.MODE_ADVANCED).keys()),
['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
self.assertItemsEqual(debbugs.get_tags('does-not-build', utils.MODE_ADVANCED).keys(),
self.assertCountEqual(list(debbugs.get_tags('does-not-build', utils.MODE_ADVANCED).keys()),
['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
self.assertItemsEqual(debbugs.get_tags('normal', utils.MODE_ADVANCED).keys(),
self.assertCountEqual(list(debbugs.get_tags('normal', utils.MODE_ADVANCED).keys()),
['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
self.assertItemsEqual(debbugs.get_tags('non-critical', utils.MODE_ADVANCED).keys(),
self.assertCountEqual(list(debbugs.get_tags('non-critical', utils.MODE_ADVANCED).keys()),
['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
self.assertItemsEqual(debbugs.get_tags('minor', utils.MODE_ADVANCED).keys(),
self.assertCountEqual(list(debbugs.get_tags('minor', utils.MODE_ADVANCED).keys()),
['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
self.assertItemsEqual(debbugs.get_tags('wishlist', utils.MODE_ADVANCED).keys(),
self.assertCountEqual(list(debbugs.get_tags('wishlist', utils.MODE_ADVANCED).keys()),
['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
self.assertItemsEqual(debbugs.get_tags('critical', utils.MODE_EXPERT).keys(),
self.assertCountEqual(list(debbugs.get_tags('critical', utils.MODE_EXPERT).keys()),
['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
self.assertItemsEqual(debbugs.get_tags('grave', utils.MODE_EXPERT).keys(),
self.assertCountEqual(list(debbugs.get_tags('grave', utils.MODE_EXPERT).keys()),
['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
self.assertItemsEqual(debbugs.get_tags('serious', utils.MODE_EXPERT).keys(),
self.assertCountEqual(list(debbugs.get_tags('serious', utils.MODE_EXPERT).keys()),
['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
self.assertItemsEqual(debbugs.get_tags('important', utils.MODE_EXPERT).keys(),
self.assertCountEqual(list(debbugs.get_tags('important', utils.MODE_EXPERT).keys()),
['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
self.assertItemsEqual(debbugs.get_tags('does-not-build', utils.MODE_EXPERT).keys(),
self.assertCountEqual(list(debbugs.get_tags('does-not-build', utils.MODE_EXPERT).keys()),
['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
self.assertItemsEqual(debbugs.get_tags('normal', utils.MODE_EXPERT).keys(),
self.assertCountEqual(list(debbugs.get_tags('normal', utils.MODE_EXPERT).keys()),
['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
self.assertItemsEqual(debbugs.get_tags('non-critical', utils.MODE_EXPERT).keys(),
self.assertCountEqual(list(debbugs.get_tags('non-critical', utils.MODE_EXPERT).keys()),
['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
self.assertItemsEqual(debbugs.get_tags('minor', utils.MODE_EXPERT).keys(),
self.assertCountEqual(list(debbugs.get_tags('minor', utils.MODE_EXPERT).keys()),
['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
self.assertItemsEqual(debbugs.get_tags('wishlist', utils.MODE_EXPERT).keys(),
self.assertCountEqual(list(debbugs.get_tags('wishlist', utils.MODE_EXPERT).keys()),
['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
class TestInfofunc(unittest2.TestCase):
class TestInfofunc(unittest.TestCase):
def test_dpkg_infofunc(self):
info = debbugs.dpkg_infofunc()
arch = utils.get_arch()
@ -138,7 +138,7 @@ class TestInfofunc(unittest2.TestCase):
self.assertIn('Architecture:', info)
class TestMiscFunctions(unittest2.TestCase):
class TestMiscFunctions(unittest.TestCase):
def test_yn_bool(self):
self.assertEqual(debbugs.yn_bool(None), 'no')
self.assertEqual(debbugs.yn_bool('no'), 'no')
@ -158,13 +158,13 @@ class TestMiscFunctions(unittest2.TestCase):
self.assertEqual(debbugs.convert_severity(severity, type), value)
@attr('network') # marking the test as using network
@unittest2.skip("Need to talk with dondelelcaro about make them sync")
@unittest.skip("Need to talk with dondelelcaro about make them sync")
def test_pseudopackages_in_sync(self):
dictparse = re.compile(r'([^\s]+)\s+(.+)', re.IGNORECASE)
bdo_list = {}
pseudo = urllib.urlopen('https://bugs.debian.org/pseudopackages/pseudo-packages.description')
pseudo = urllib.request.urlopen('https://bugs.debian.org/pseudopackages/pseudo-packages.description')
for l in pseudo:
m = dictparse.search(l)
bdo_list[m.group(1)] = m.group(2)
@ -173,11 +173,7 @@ class TestMiscFunctions(unittest2.TestCase):
self.assertEqual(debbugs.debother, bdo_list)
class TestGetReports(unittest2.TestCase):
@attr('network') # marking the test as using network
def test_get_cgi_reports(self):
data = debbugs.get_cgi_reports('reportbug', timeout=60)
self.assertGreater(data[0], 0)
class TestGetReports(unittest.TestCase):
@attr('network') # marking the test as using network
def test_get_reports(self):
@ -203,32 +199,24 @@ class TestGetReports(unittest2.TestCase):
self.assertGreater(data[0], 0)
class TestUrlFunctions(unittest2.TestCase):
class TestUrlFunctions(unittest.TestCase):
def test_cgi_report_url(self):
self.assertEqual(debbugs.cgi_report_url('debian', 123),
'https://bugs.debian.org/cgi-bin/bugreport.cgi?' +
'bug=123&archived=False&mbox=no')
self.assertCountEqual(debbugs.cgi_report_url('debian', 123).split('?')[1].split('&'),
'bug=123&archived=False&mbox=no'.split('&'))
self.assertIsNone(debbugs.cgi_report_url('default', 123))
def test_cgi_package_url(self):
self.assertEqual(debbugs.cgi_package_url('debian', 'reportbug'),
'https://bugs.debian.org/cgi-bin/pkgreport.cgi?' +
'archived=no&pkg=reportbug&repeatmerged=yes')
self.assertEqual(debbugs.cgi_package_url
('debian', 'reportbug', source=True),
'https://bugs.debian.org/cgi-bin/pkgreport.cgi?src=' +
'reportbug&archived=no&repeatmerged=yes')
self.assertEqual(debbugs.cgi_package_url
('debian', 'reportbug', version='5.0'),
'https://bugs.debian.org/cgi-bin/pkgreport.cgi?archi' +
'ved=no&version=5.0&pkg=reportbug&repeatmerged=yes')
self.assertCountEqual(debbugs.cgi_package_url('debian', 'reportbug').split('?')[1].split('&'),
'repeatmerged=yes&archived=no&pkg=reportbug'.split('&'))
self.assertCountEqual(debbugs.cgi_package_url('debian', 'reportbug', source=True).split('?')[1].split('&'),
'src=reportbug&archived=no&repeatmerged=yes'.split('&'))
self.assertCountEqual(debbugs.cgi_package_url('debian', 'reportbug', version='5.0').split('?')[1].split('&'),
'pkg=reportbug&version=5.0&repeatmerged=yes&archived=no'.split('&'))
def test_get_package_url(self):
self.assertEqual(debbugs.get_package_url('debian', 'reportbug'),
'https://bugs.debian.org/cgi-bin/pkgreport.cgi?archi' +
'ved=no&pkg=reportbug&repeatmerged=yes')
self.assertCountEqual(debbugs.get_package_url('debian', 'reportbug').split('?')[1].split('&'),
'archived=no&pkg=reportbug&repeatmerged=yes'.split('&'))
def test_get_report_url(self):
self.assertEqual(debbugs.get_report_url('debian', 123),
'https://bugs.debian.org/cgi-bin/bugreport.cgi?' +
'bug=123&archived=False&mbox=no')
self.assertCountEqual(debbugs.get_report_url('debian', 123).split('?')[1].split('&'),
'bug=123&archived=False&mbox=no'.split('&'))

Loading…
Cancel
Save