Commit aec6c204 authored by Clément Schreiner's avatar Clément Schreiner
Browse files

Closedbugs plugin now working with the new API.

parent 1484b9fc
......@@ -95,14 +95,19 @@ class ClosedBug(PluginResult):
@property
def package(self):
return self['package']
@property
def is_wnpp(self):
return self.package == 'wnpp'
def __str__(self):
if self.exists:
string = '{name} ({severity}: {subject}'.format(
name=self['name'],
severity=self.severity,
string = '{package} ({severity}: {subject}'.format(
package=self['package'],
severity=self['severity'],
subject=self['subject'])
else:
string = 'Non-existent bug #{}'.format(self.number)
string = 'Bug #{} does not exist for'.format(self.number)
return string
......@@ -126,6 +131,14 @@ class ClosedBugsPlugin(QAPlugin):
bugs = [int(x) for x in self.changes['Closes'].split()]
test_result = self.new_test_result(nb_closed=0,
nb_errors=0,
wnpp='false')
if not bugs:
log.debug('Package does not close any bugs')
return
if bugs:
log.debug('Creating SOAP proxy to bugs.debian.org')
try:
......@@ -158,51 +171,44 @@ class ClosedBugsPlugin(QAPlugin):
severity = constants.PLUGIN_SEVERITY_INFO
nb_closed = 0
nb_errors = 0
wnpp = False
for bug in bugs:
bug_result = self.new_result(ClosedBug, number=bug)
if not bug in raw_bugs:
log.debug('{} does not exist'.format(bug))
bug_result.exists = False
bug_result.belongs = False
bug_result.is_error = False
bug_result.is_error = True
test_result.nb_errors += 1
severity = max(severity, constants.PLUGIN_SEVERITY_ERROR)
nb_errors += 1
continue
bug_result.exists = True
log.debug('Found bug {}'.format(bug))
package = raw_bugs[bug]['package']
bug_result['name'] = package
bug_result['package'] = package
bug_result['subject'] = raw_bugs[bug]['subject']
bug_result['severity'] = raw_bugs[bug]['severity']
source = raw_bugs['source'].split(', ')
bug_result.belongs = True
source = raw_bugs[bug]['source'].split(', ')
if name == 'wnpp':
bug_result.wnpp = True
wnpp = True
nb_closed += 1
if package == 'wnpp':
log.debug('Package closes a wnpp bug')
test_result.nb_closed += 1
test_result.closes_wnpp = True
bug_result.belongs = True
elif self.changes['Source'] in source:
nb_closed += 1
test_result.nb_closed += 1
bug_result.belongs = True
else:
bug_result.belongs = False
nb_errors += 1
severity = max(severity, constants.PLUGIN_SEVERITY_ERROR)
test_result.nb_errors += 1
test_result['severity'] = max(severity,
constants.PLUGIN_SEVERITY_ERROR)
test_result = self.new_test_result(nb_errors=nb_errors,
nb_closed=nb_closed,
wnpp=wnpp,
severity=severity)
else:
log.debug('Package does not close any bugs')
plugin = ClosedBugsPlugin
models = [
......
......@@ -2,22 +2,28 @@
${test_result}
</div>
<div class="qa-content">
%if test_result.nb_errors:
% if test_result.nb_errors:
Errors:
<ul class="bugs-errors">
% for bug in filter(lambda b: b.is_error, results['closed_bug']):
<li>${bug}</li>
% for bug in filter(lambda bug: bug.is_error, results['closed_bug']):
<li>${bug}</li>'
% endfor
</ul>
%endif
% endif
<ul class="bugs-closed">
% for bug in filter(lambda b: b.is_closed, results["closed_bug"]):
<%
bugs = test_result.get_bugs()
%>
% for package in bugs:
<li>
<a href="http://bugs.debian.org/${bug.package}">${bug.package}</a>:
<a href="http://bugs.debian.org/${package}">${package}</a>:
<ul>
% for bugnum, title, severity in o.rich_data["bugs"][package]:
% for bug in bugs[package]:
<li>
<a href="http://bugs.debian.org/${bugnum}">#${bugnum}</a> (${severity}): ${title}
<a href="http://bugs.debian.org/${bug.number}">
#${bug.number}
</a>
(${bug['severity']}): ${bug['subject']}
</li>
% endfor
</ul>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment