Merge lp:~abentley/launchpad/no-builds-recipe into lp:launchpad

Proposed by Aaron Bentley
Status: Merged
Approved by: Tim Penhey
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~abentley/launchpad/no-builds-recipe
Merge into: lp:launchpad
Diff against target: 99 lines (+26/-13)
2 files modified
lib/lp/code/browser/tests/test_sourcepackagerecipe.py (+23/-13)
lib/lp/code/templates/sourcepackagerecipe-index.pt (+3/-0)
To merge this branch: bzr merge lp:~abentley/launchpad/no-builds-recipe
Reviewer Review Type Date Requested Status
Michael Hudson-Doyle Approve
Review via email: mp+23744@code.launchpad.net

Commit message

Show a message when a recipe has no builds

Description of the change

= Summary =
Provide a message under the builds table for a sourcepackage recipe when
there are no builds.

== Proposed fix ==
See above

== Pre-implementation notes ==
Discussed with rockstar

== Implementation details ==
Extracted the assertions in several browser tests into assertContainsRe.

Fixed some lint as a drive-by.

== Tests ==
bin/test -vvt test_index_no_builds test_sourcepackagerecipe

== Demo and Q/A ==
None

= Launchpad lint =

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  lib/lp/code/templates/sourcepackagerecipe-index.pt
  lib/lp/code/browser/tests/test_sourcepackagerecipe.py

To post a comment you must log in.
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Looks fine. Did you consider adding assertContainsRe to TestCaseWithFactory?

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/code/browser/tests/test_sourcepackagerecipe.py'
2--- lib/lp/code/browser/tests/test_sourcepackagerecipe.py 2010-04-13 14:27:38 +0000
3+++ lib/lp/code/browser/tests/test_sourcepackagerecipe.py 2010-04-20 06:04:18 +0000
4@@ -1,6 +1,6 @@
5 # Copyright 2010 Canonical Ltd. This software is licensed under the
6 # GNU Affero General Public License version 3 (see the file LICENSE).
7-# pylint: disable-msg=F0401
8+# pylint: disable-msg=F0401,E1002
9
10 """Tests for the product view classes and templates."""
11
12@@ -63,7 +63,7 @@
13 recipe=recipe, distroseries=self.squirrel, archive=self.ppa))
14 build.buildstate = BuildStatus.FULLYBUILT
15 build.datebuilt = datetime(2010, 03, 16, tzinfo=utc)
16- pattern = re.compile(dedent("""\
17+ self.assertContainsRe(dedent("""\
18 Master Chef
19 Branches
20 Description
21@@ -89,15 +89,29 @@
22 Request build\(s\)
23 Recipe contents
24 # bzr-builder format 0.2 deb-version 1.0
25- lp://dev/~chef/chocolate/cake"""), re.S)
26- main_text = self.getMainText(recipe)
27- self.assertTrue(pattern.search(main_text), repr(main_text))
28+ lp://dev/~chef/chocolate/cake"""), self.getMainText(recipe))
29+
30+ def assertContainsRe(self, regex, text):
31+ """Assert that the text contains the specified regex."""
32+ pattern = re.compile(regex, re.S)
33+ self.assertTrue(pattern.search(text), text)
34+
35+ def test_index_no_builds(self):
36+ """A message should be shown when there are no builds."""
37+ recipe = self.makeRecipe()
38+ self.assertContainsRe(dedent("""\
39+ Build records
40+ Status
41+ Time
42+ Distribution series
43+ Archive
44+ This recipe has not been built yet."""), self.getMainText(recipe))
45
46 def test_index_no_suitable_builders(self):
47 recipe = self.makeRecipe()
48 removeSecurityProxy(self.factory.makeSourcePackageRecipeBuild(
49 recipe=recipe, distroseries=self.squirrel, archive=self.ppa))
50- pattern = re.compile(dedent("""\
51+ self.assertContainsRe(dedent("""\
52 Build records
53 Status
54 Time
55@@ -106,9 +120,7 @@
56 No suitable builders
57 Secret Squirrel
58 Secret PPA
59- Request build\(s\)"""), re.S)
60- main_text = self.getMainText(recipe)
61- self.assertTrue(pattern.search(main_text), main_text)
62+ Request build\(s\)"""), self.getMainText(recipe))
63
64 def makeBuildJob(self, recipe):
65 """Return a build associated with a buildjob."""
66@@ -122,7 +134,7 @@
67 recipe = self.makeRecipe()
68 self.makeBuildJob(recipe)
69 self.factory.makeBuilder()
70- pattern = re.compile(dedent("""\
71+ self.assertContainsRe(dedent("""\
72 Build records
73 Status
74 Time
75@@ -134,9 +146,7 @@
76 Secret Squirrel
77 Secret PPA
78 Request build\(s\)
79- Recipe contents"""), re.S)
80- main_text = self.getMainText(recipe)
81- self.assertTrue(pattern.search(main_text), main_text)
82+ Recipe contents"""), self.getMainText(recipe))
83
84 def test_builds(self):
85 """Ensure SourcePackageRecipeView.builds is as described."""
86
87=== modified file 'lib/lp/code/templates/sourcepackagerecipe-index.pt'
88--- lib/lp/code/templates/sourcepackagerecipe-index.pt 2010-04-09 15:38:22 +0000
89+++ lib/lp/code/templates/sourcepackagerecipe-index.pt 2010-04-20 06:04:18 +0000
90@@ -90,6 +90,9 @@
91 </tr>
92 </tbody>
93 </table>
94+ <p tal:condition="not: view/builds">
95+ This recipe has not been built yet.
96+ </p>
97 <tal:request replace="structure context/menu:context/request_builds/fmt:link" />
98 </div>
99 <div class='portlet'>