Merge lp:~michael.nelson/launchpad/591010-locationerror-related-packages into lp:launchpad

Proposed by Michael Nelson on 2010-06-10
Status: Merged
Approved by: Jelmer Vernooij on 2010-06-10
Approved revision: no longer in the source branch.
Merged at revision: 10987
Proposed branch: lp:~michael.nelson/launchpad/591010-locationerror-related-packages
Merge into: lp:launchpad
Diff against target: 93 lines (+49/-3)
3 files modified
lib/lp/registry/browser/tests/test_person_view.py (+47/-1)
lib/lp/registry/templates/person-related-software.pt (+1/-1)
lib/lp/soyuz/templates/person-ppa-packages.pt (+1/-1)
To merge this branch: bzr merge lp:~michael.nelson/launchpad/591010-locationerror-related-packages
Reviewer Review Type Date Requested Status
Jelmer Vernooij (community) code 2010-06-10 Approve on 2010-06-10
Review via email: mp+27235@code.launchpad.net

Description of the Change

Please review my branch:

   bzr+ssh://bazaar.launchpad.net/~michael.nelson/launchpad/591010-locationerror-related-packages

revision 10980.

Demo URL: Demonstrating just shows that the page doesn't oops, but if you're
really keen, you can view the page with the correct data by
putting a breakpoint at the end of the test and then running `make
LPCONFIG=testrunner run`. In the debugger, get the user name with
`self.user.name` and plug that in to:

https://launchpad.dev/~<user-name>/+related-software

Test command: bin/test -vv -m test_person_view -t
TestPersonRelatedSoftwareFailedBuild

The two template fixes are one-liners, creating the tests was a bit confusing.
To reproduce the problem required publishing a package in the users PPA, but
with a build built in the context of a distro archive (ie. as if it had been
copied out). I created an XXX with an associated bug:
https://bugs.edge.launchpad.net/soyuz/+bug/592050

but for the moment just ensured the oops is fixed (so this can be CP'd if
necessary).

To post a comment you must log in.
Jelmer Vernooij (jelmer) :
review: Approve (code)
Jelmer Vernooij (jelmer) wrote :

The buildmaster import seems somewhat out of place, I would expect it to sort before all of the registry imports.

Michael Nelson (michael.nelson) wrote :

Woops... when cleaning up the stray registry import, I'd then placed it out of order again. Updated. Thanks!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/browser/tests/test_person_view.py'
2--- lib/lp/registry/browser/tests/test_person_view.py 2010-06-07 21:37:52 +0000
3+++ lib/lp/registry/browser/tests/test_person_view.py 2010-06-10 10:29:35 +0000
4@@ -10,10 +10,11 @@
5
6 from canonical.launchpad.ftests import ANONYMOUS, login
7 from canonical.launchpad.webapp.interfaces import NotFoundError
8-from lp.registry.interfaces.karma import IKarmaCacheManager
9 from canonical.launchpad.webapp.servers import LaunchpadTestRequest
10 from canonical.testing import (
11 DatabaseFunctionalLayer, LaunchpadFunctionalLayer, LaunchpadZopelessLayer)
12+from lp.buildmaster.interfaces.buildbase import BuildStatus
13+from lp.registry.interfaces.karma import IKarmaCacheManager
14 from lp.registry.browser.person import PersonEditView, PersonView
15 from lp.registry.interfaces.person import PersonVisibility
16 from lp.registry.interfaces.teammembership import TeamMembershipStatus
17@@ -337,5 +338,50 @@
18 self.assertEqual(True, self.view.has_participations)
19
20
21+class TestPersonRelatedSoftwareFailedBuild(TestCaseWithFactory):
22+ """The related software views display links to failed builds."""
23+
24+ layer = LaunchpadFunctionalLayer
25+
26+ def setUp(self):
27+ super(TestPersonRelatedSoftwareFailedBuild, self).setUp()
28+ self.user = self.factory.makePerson()
29+
30+ # First we need to publish some PPA packages with failed builds
31+ # for this person.
32+ # XXX michaeln 2010-06-10 bug=592050.
33+ # Strangely, the builds need to be built in the context of a
34+ # main archive to reproduce bug 591010 for which this test was
35+ # written to demonstrate.
36+ login('foo.bar@canonical.com')
37+ publisher = SoyuzTestPublisher()
38+ publisher.prepareBreezyAutotest()
39+ ppa = self.factory.makeArchive(owner=self.user)
40+ src_pub = publisher.getPubSource(
41+ creator=self.user, maintainer=self.user, archive=ppa)
42+ binaries = publisher.getPubBinaries(
43+ pub_source=src_pub)
44+ self.build = binaries[0].binarypackagerelease.build
45+ self.build.status = BuildStatus.FAILEDTOBUILD
46+ self.build.archive = publisher.distroseries.main_archive
47+ login(ANONYMOUS)
48+
49+ def test_related_software_with_failed_build(self):
50+ # The link to the failed build is displayed.
51+ self.view = create_view(self.user, name='+related-software')
52+ html = self.view()
53+ self.assertTrue(
54+ '<a href="/ubuntutest/+source/foo/666/+build/%d">i386</a>' % (
55+ self.build.id) in html)
56+
57+ def test_related_ppa_packages_with_failed_build(self):
58+ # The link to the failed build is displayed.
59+ self.view = create_view(self.user, name='+ppa-packages')
60+ html = self.view()
61+ self.assertTrue(
62+ '<a href="/ubuntutest/+source/foo/666/+build/%d">i386</a>' % (
63+ self.build.id) in html)
64+
65+
66 def test_suite():
67 return unittest.TestLoader().loadTestsFromName(__name__)
68
69=== modified file 'lib/lp/registry/templates/person-related-software.pt'
70--- lib/lp/registry/templates/person-related-software.pt 2009-09-08 14:37:17 +0000
71+++ lib/lp/registry/templates/person-related-software.pt 2010-06-10 10:29:35 +0000
72@@ -187,7 +187,7 @@
73 <tal:block condition="not: spr/needs_building">
74 <tal:block repeat="build spr/failed_builds">
75 <a tal:attributes="href build/fmt:url"
76- tal:content="build/distroarchseries/architecturetag" />
77+ tal:content="build/distro_arch_series/architecturetag" />
78 </tal:block>
79 <tal:block condition="not: spr/failed_builds">
80 None
81
82=== modified file 'lib/lp/soyuz/templates/person-ppa-packages.pt'
83--- lib/lp/soyuz/templates/person-ppa-packages.pt 2009-09-08 14:37:17 +0000
84+++ lib/lp/soyuz/templates/person-ppa-packages.pt 2010-06-10 10:29:35 +0000
85@@ -88,7 +88,7 @@
86 <tal:block condition="not: spr/needs_building">
87 <tal:block repeat="build spr/failed_builds">
88 <a tal:attributes="href build/fmt:url"
89- tal:content="build/distroarchseries/architecturetag" />
90+ tal:content="build/distro_arch_series/architecturetag" />
91 </tal:block>
92 <tal:block condition="not: spr/failed_builds">
93 None