Commit 482df1a5 authored by Raphaël Hertzog's avatar Raphaël Hertzog

debian: fix URL for binary package bug stats

This URL was broken very early on and we never noticed because
get_resource_content() was hiding the errors. Once fixed, the appearence
of real data revealed non-working code that I had to fix too.
parent 95d83317
Pipeline #50029 passed with stage
in 31 minutes and 38 seconds
......@@ -508,13 +508,13 @@ class BinariesInformationPanel(BasePanel, BugDisplayManagerMixin):
return
# Try to get the URL to the bug tracker for the given categories
for category in bug_stats:
url, implemented = self.bug_manager.get_bug_tracker_url(
url = self.bug_manager.get_bug_tracker_url(
binary_name, 'binary', category['category_name'])
if not implemented:
if not url:
continue
category['url'] = url
# Include the total bug count and corresponding tracker URL
all_bugs_url, implemented = self.bug_manager.get_bug_tracker_url(
all_bugs_url = self.bug_manager.get_bug_tracker_url(
binary_name, 'binary', 'all')
return {
'total_count': sum(
......
# -*- coding: utf-8 -*-
# Copyright 2013-2018 The Distro Tracker Developers
# Copyright 2013-2019 The Distro Tracker Developers
# See the COPYRIGHT file at the top-level directory of this distribution and
# at https://deb.li/DTAuthors
#
......@@ -19,6 +19,8 @@ from django.conf import settings
from django.urls import reverse
from distro_tracker.core.models import (
BinaryPackageBugStats,
PackageData,
PackageName,
PseudoPackageName,
Repository,
......@@ -27,8 +29,8 @@ from distro_tracker.core.models import (
SourcePackageRepositoryEntry
)
from distro_tracker.core.panels import (
BinariesInformationPanel,
DeadPackageWarningPanel,
PackageData,
VersionedLinks
)
from distro_tracker.core.utils.packages import package_url
......@@ -298,3 +300,39 @@ class NewsPanelTests(TestCase, TemplateTestsMixin):
created_by="Author {}".format(self.NEWS_LIMIT))
response = self.get_package_page_response()
self.assertLinkIsInResponse(response, self.news_link + "?page=2")
class BinariesInformationPanelTests(TestCase, TemplateTestsMixin):
def setUp(self):
self.srcpkg = self.create_source_package(
binary_packages=['pkg-binary'])
self.pkgname = self.srcpkg.source_package_name
self.binpkg = self.srcpkg.binary_packages.first()
self.stats = [
{
'category_name': 'rc',
'bug_count': 0,
},
]
self.bug_stats = BinaryPackageBugStats.objects.create(
package=self.binpkg, stats=self.stats)
binaries = [
{
'name': self.binpkg.name,
},
]
PackageData.objects.create(package=self.pkgname,
key='binaries', value=binaries)
def test_panel_context(self):
panel = BinariesInformationPanel(self.srcpkg.source_package_name, None)
ctx = panel.context
self.assertIsInstance(ctx, list)
item = ctx[0]
self.assertIsInstance(item, dict)
self.assertEqual(item['name'], 'pkg-binary')
stats = item['bug_stats']
self.assertIsInstance(stats, dict)
self.assertIsInstance(stats['total_count'], int)
self.assertIsInstance(stats['categories'], list)
self.assertEqual(stats['categories'], self.stats)
......@@ -34,7 +34,6 @@ from django.utils.http import urlencode
import yaml
from distro_tracker import vendor
from distro_tracker.accounts.models import UserEmail
from distro_tracker.core.models import (
ActionItem,
......@@ -360,8 +359,8 @@ class UpdatePackageBugStats(BaseTask, BugDisplayManagerMixin):
bug_count = bug_stats['help']['bug_count']
# Include the URL in the short description
url, _ = vendor.call('get_bug_tracker_url', package.name, 'source',
'help')
url = self.bug_manager.get_bug_tracker_url(
package.name, 'source', 'help')
if not url:
url = ''
# Include the bug count in the short description
......@@ -492,7 +491,7 @@ class UpdatePackageBugStats(BaseTask, BugDisplayManagerMixin):
"""
Performs the update of bug statistics for binary packages.
"""
url = 'https://udd.debian.org/cgi-bin/bugs-binpkgs-distro_tracker.cgi'
url = 'https://udd.debian.org/cgi-bin/bugs-binpkgs-pts.cgi'
response_content = get_resource_text(url)
if not response_content:
return
......
Markdown is supported
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