Browse Source

if NEW has several versions of the given package, choose the bigger; thanks to Thorsten Glaser for the report; Closes: #704040

deb822.Deb822.iter_paragraph() expects an iterable object to parse correctly the
input, so we give it one, the paragraph split per line, so that it is able to
setup a correct dictionary with the mocked values
suites/jessie-proposed-backports
Sandro Tosi 8 years ago
parent
commit
c61eefb75e
  1. 5
      debian/changelog
  2. 3
      reportbug/checkversions.py
  3. 38
      test/test_checkversions.py

5
debian/changelog

@ -14,8 +14,11 @@ reportbug (6.4.5) UNRELEASED; urgency=low
- improve the template provided to less-expert reporters to be clear the
questions should be answered by the reporter themselves; thanks to Tony
Houghton for the report; Closes: #690782
* reportbug/checkversions.py
- if NEW has several versions of the given package, choose the bigger;
thanks to Thorsten Glaser for the report; Closes: #704040
-- Sandro Tosi <morph@debian.org> Sun, 19 Jan 2014 17:31:59 +0100
-- Sandro Tosi <morph@debian.org> Sun, 19 Jan 2014 20:03:17 +0100
reportbug (6.4.4) unstable; urgency=low

3
reportbug/checkversions.py

@ -155,7 +155,8 @@ def get_newqueue_available(package, timeout, dists=None, http_proxy=None, arch='
for para in Deb822.iter_paragraphs(page):
if para['Source'] == package:
k = para['Distribution'] + ' (' + para['Queue'] + ')'
versions[k] = para['Version']
# in case of multiple versions, choose the bigger
versions[k] = max(para['Version'].split())
return versions

38
test/test_checkversions.py

@ -3,6 +3,8 @@ import unittest2
from reportbug import checkversions
from nose.plugins.attrib import attr
import mock
class TestCheckversions(unittest2.TestCase):
def test_compare_versions(self):
@ -31,6 +33,42 @@ class TestCheckversions(unittest2.TestCase):
self.assertEqual(checkversions.later_version('1.2.4', '1.2.3'), '1.2.4')
class TestNewQueue(unittest2.TestCase):
def test_bts704040(self):
# return an iterable object, so that Deb822 (what parses the result)
# will work
pkg_in_new = """Source: procps
Binary: libprocps1-dev, procps, libprocps1
Version: 1:3.3.6-2 1:3.3.6-1 1:3.3.7-1 1:3.3.5-1
Architectures: source, amd64
Age: 4 months
Last-Modified: 1353190660
Queue: new
Maintainer: Craig Small <csmall@debian.org>
Changed-By: Craig Small <csmall@debian.org>
Distribution: experimental
Fingerprint: 5D2FB320B825D93904D205193938F96BDF50FEA5
Closes: #682082, #682083, #682086, #698482, #699716
Changes-File: procps_3.3.6-1_amd64.changes
Source: aaa
""".split('\n')
# save the original checkversions.open_url() method
save_open_url = checkversions.open_url
checkversions.open_url = mock.MagicMock(return_value = pkg_in_new)
res = checkversions.get_newqueue_available('procps', 60)
self.assertEqual(res.keys()[0], u'experimental (new)')
self.assertEqual(res[u'experimental (new)'], u'1:3.3.7-1')
# restore the original checkversions.open_url() method
checkversions.open_url = save_open_url
class TestVersionAvailable(unittest2.TestCase):
@attr('network') #marking the test as using network

Loading…
Cancel
Save