From c61eefb75e563ab1f26caa797cfd8106210c8d9f Mon Sep 17 00:00:00 2001 From: Sandro Tosi Date: Sun, 19 Jan 2014 20:07:56 +0100 Subject: [PATCH] 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 --- debian/changelog | 5 ++++- reportbug/checkversions.py | 3 ++- test/test_checkversions.py | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index a1596bd..ce84a3e 100644 --- a/debian/changelog +++ b/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 Sun, 19 Jan 2014 17:31:59 +0100 + -- Sandro Tosi Sun, 19 Jan 2014 20:03:17 +0100 reportbug (6.4.4) unstable; urgency=low diff --git a/reportbug/checkversions.py b/reportbug/checkversions.py index 5ce2802..750da1a 100644 --- a/reportbug/checkversions.py +++ b/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 diff --git a/test/test_checkversions.py b/test/test_checkversions.py index 17a27d3..1577ee0 100644 --- a/test/test_checkversions.py +++ b/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 +Changed-By: Craig Small +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