Merge lp:~evfool/update-manager/fix665173 into lp:update-manager

Proposed by Robert Roth
Status: Merged
Merged at revision: 2085
Proposed branch: lp:~evfool/update-manager/fix665173
Merge into: lp:update-manager
Diff against target: 48 lines (+10/-3)
2 files modified
UpdateManager/Core/MyCache.py (+4/-2)
tests/test_changelog.py (+6/-1)
To merge this branch: bzr merge lp:~evfool/update-manager/fix665173
Reviewer Review Type Date Requested Status
Michael Vogt (community) Approve
Robert Roth (community) Approve
Barry Warsaw (community) Approve
Review via email: mp+55663@code.launchpad.net

Description of the change

Show only one error message for sources not supporting changelogs, do not show one for the source and one for the binary source (this is how the message got duplicated).

To post a comment you must log in.
Revision history for this message
Barry Warsaw (barry) wrote :

Thanks for your contribution. The patch looks okay to me (although I cannot upload it). Have you tried to add a test for this situation?

review: Approve
Revision history for this message
Barry Warsaw (barry) wrote :

Hmm, I guess the only problem could be that if one changelog source gave an HTTPError and then another source gave an BadStatusLine error (for example), you'd only see one of the two error messages, but maybe that's not terrible. If you were to get both errors, you've definitely got problems. ;)

Revision history for this message
Robert Roth (evfool) wrote :

I have tested it manually on a source not supporting changelogs, and the message is only shown once, as expected. Do you mean a unit-test? I think I could do that with a hard-coded launchpad changelog URL, that reports that changelogs are not supported. I'll check, I haven't written any Python unit-tests so fat, but I assume that the right place for this would be another method in the tests/test_changelog.py

Revision history for this message
Barry Warsaw (barry) wrote :

> I have tested it manually on a source not supporting changelogs, and the
> message is only shown once, as expected. Do you mean a unit-test? I think I
> could do that with a hard-coded launchpad changelog URL, that reports that
> changelogs are not supported. I'll check, I haven't written any Python unit-
> tests so fat, but I assume that the right place for this would be another
> method in the tests/test_changelog.py

I think that would be a good place for it. There should be lots of examples in the package to cargo cult from :). Give it a shot! Thanks.

lp:~evfool/update-manager/fix665173 updated
2073. By Robert Roth

Unittest to test if the changelog not supported text gets in the changelog text only once

Revision history for this message
Robert Roth (evfool) wrote :

Really simple unittest added to check if the error message gets only once in the changelog. The package name is hardcoded for a package I have found that does not support changelogs, but not everyone will have that package though, so it could be replaced with a better package.

review: Needs Resubmitting
Revision history for this message
Barry Warsaw (barry) wrote :

Maybe mvo has some thoughts about that. The indentation looks a little weird in the merge proposal, but if the test passes for you then I think it's good. Let's see what Michael has to say. Thanks for doing this!

review: Approve
Revision history for this message
Robert Roth (evfool) wrote :

The requested changes have been commited.

review: Approve
Revision history for this message
Michael Vogt (mvo) wrote :

Hello! Thanks a lot for this branch (and the other branches!). Its getting a bit late here, but I will definitely merge this tonight or tomorrow.

Revision history for this message
Michael Vogt (mvo) wrote :

Thanks a bunch, merged (I modified the unittest a bit to make it not depend on a sources.list entry that has liboverlay-scrollbar-0.1-0

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'UpdateManager/Core/MyCache.py'
2--- UpdateManager/Core/MyCache.py 2010-08-11 06:52:22 +0000
3+++ UpdateManager/Core/MyCache.py 2011-04-01 18:26:37 +0000
4@@ -287,6 +287,7 @@
5 # Try non official changelog location
6 changelogs_uri_binary = self._guess_third_party_changelogs_uri_by_binary(name)
7 changelogs_uri_source = self._guess_third_party_changelogs_uri_by_source(name)
8+ error_message = ""
9 for changelogs_uri in [changelogs_uri_binary,changelogs_uri_source]:
10 if changelogs_uri:
11 try:
12@@ -294,15 +295,16 @@
13 self.all_changes[name] += changelog
14 except urllib2.HTTPError, e:
15 # no changelogs_uri or 404
16- self.all_changes[name] += _(
17+ error_message = _(
18 "This change is not coming from a "
19 "source that supports changelogs.")
20 except (IOError, httplib.BadStatusLine, socket.error), e:
21 # network errors and others
22 logging.exception("error on changelog fetching")
23- self.all_changes[name] += _(
24+ error_message = _(
25 "Failed to download the list of changes. \n"
26 "Please check your Internet connection.")
27+ self.all_changes[name] += error_message
28 return
29 # fixup epoch handling version
30 srcpkg = self[name].sourcePackageName
31
32=== modified file 'tests/test_changelog.py'
33--- tests/test_changelog.py 2010-08-10 12:22:09 +0000
34+++ tests/test_changelog.py 2011-04-01 18:26:37 +0000
35@@ -37,7 +37,12 @@
36 pkg = self.cache[pkgname]
37 self.assertTrue(pkg.candidate.version in uri)
38 self.assertTrue("gtk+2.0" in uri)
39-
40+ def test_changelog_not_supported(self):
41+ pkgname = "liboverlay-scrollbar-0.1-0"
42+ # test binary changelogs
43+ self.cache.get_changelog(pkgname)
44+ error = "This change is not coming from a source that supports changelogs."
45+ self.assertEqual(self.cache.all_changes[pkgname].count(error),1)
46
47 if __name__ == '__main__':
48 if len(sys.argv) > 1 and sys.argv[1] == "-v":

Subscribers

People subscribed via source and target branches

to status/vote changes: