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
=== modified file 'lib/lp/code/browser/tests/test_sourcepackagerecipe.py'
--- lib/lp/code/browser/tests/test_sourcepackagerecipe.py 2010-04-13 14:27:38 +0000
+++ lib/lp/code/browser/tests/test_sourcepackagerecipe.py 2010-04-20 06:04:18 +0000
@@ -1,6 +1,6 @@
1# Copyright 2010 Canonical Ltd. This software is licensed under the1# Copyright 2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
3# pylint: disable-msg=F04013# pylint: disable-msg=F0401,E1002
44
5"""Tests for the product view classes and templates."""5"""Tests for the product view classes and templates."""
66
@@ -63,7 +63,7 @@
63 recipe=recipe, distroseries=self.squirrel, archive=self.ppa))63 recipe=recipe, distroseries=self.squirrel, archive=self.ppa))
64 build.buildstate = BuildStatus.FULLYBUILT64 build.buildstate = BuildStatus.FULLYBUILT
65 build.datebuilt = datetime(2010, 03, 16, tzinfo=utc)65 build.datebuilt = datetime(2010, 03, 16, tzinfo=utc)
66 pattern = re.compile(dedent("""\66 self.assertContainsRe(dedent("""\
67 Master Chef67 Master Chef
68 Branches68 Branches
69 Description69 Description
@@ -89,15 +89,29 @@
89 Request build\(s\)89 Request build\(s\)
90 Recipe contents90 Recipe contents
91 # bzr-builder format 0.2 deb-version 1.091 # bzr-builder format 0.2 deb-version 1.0
92 lp://dev/~chef/chocolate/cake"""), re.S)92 lp://dev/~chef/chocolate/cake"""), self.getMainText(recipe))
93 main_text = self.getMainText(recipe)93
94 self.assertTrue(pattern.search(main_text), repr(main_text))94 def assertContainsRe(self, regex, text):
95 """Assert that the text contains the specified regex."""
96 pattern = re.compile(regex, re.S)
97 self.assertTrue(pattern.search(text), text)
98
99 def test_index_no_builds(self):
100 """A message should be shown when there are no builds."""
101 recipe = self.makeRecipe()
102 self.assertContainsRe(dedent("""\
103 Build records
104 Status
105 Time
106 Distribution series
107 Archive
108 This recipe has not been built yet."""), self.getMainText(recipe))
95109
96 def test_index_no_suitable_builders(self):110 def test_index_no_suitable_builders(self):
97 recipe = self.makeRecipe()111 recipe = self.makeRecipe()
98 removeSecurityProxy(self.factory.makeSourcePackageRecipeBuild(112 removeSecurityProxy(self.factory.makeSourcePackageRecipeBuild(
99 recipe=recipe, distroseries=self.squirrel, archive=self.ppa))113 recipe=recipe, distroseries=self.squirrel, archive=self.ppa))
100 pattern = re.compile(dedent("""\114 self.assertContainsRe(dedent("""\
101 Build records115 Build records
102 Status116 Status
103 Time117 Time
@@ -106,9 +120,7 @@
106 No suitable builders120 No suitable builders
107 Secret Squirrel121 Secret Squirrel
108 Secret PPA122 Secret PPA
109 Request build\(s\)"""), re.S)123 Request build\(s\)"""), self.getMainText(recipe))
110 main_text = self.getMainText(recipe)
111 self.assertTrue(pattern.search(main_text), main_text)
112124
113 def makeBuildJob(self, recipe):125 def makeBuildJob(self, recipe):
114 """Return a build associated with a buildjob."""126 """Return a build associated with a buildjob."""
@@ -122,7 +134,7 @@
122 recipe = self.makeRecipe()134 recipe = self.makeRecipe()
123 self.makeBuildJob(recipe)135 self.makeBuildJob(recipe)
124 self.factory.makeBuilder()136 self.factory.makeBuilder()
125 pattern = re.compile(dedent("""\137 self.assertContainsRe(dedent("""\
126 Build records138 Build records
127 Status139 Status
128 Time140 Time
@@ -134,9 +146,7 @@
134 Secret Squirrel146 Secret Squirrel
135 Secret PPA147 Secret PPA
136 Request build\(s\)148 Request build\(s\)
137 Recipe contents"""), re.S)149 Recipe contents"""), self.getMainText(recipe))
138 main_text = self.getMainText(recipe)
139 self.assertTrue(pattern.search(main_text), main_text)
140150
141 def test_builds(self):151 def test_builds(self):
142 """Ensure SourcePackageRecipeView.builds is as described."""152 """Ensure SourcePackageRecipeView.builds is as described."""
143153
=== modified file 'lib/lp/code/templates/sourcepackagerecipe-index.pt'
--- lib/lp/code/templates/sourcepackagerecipe-index.pt 2010-04-09 15:38:22 +0000
+++ lib/lp/code/templates/sourcepackagerecipe-index.pt 2010-04-20 06:04:18 +0000
@@ -90,6 +90,9 @@
90 </tr>90 </tr>
91 </tbody>91 </tbody>
92 </table>92 </table>
93 <p tal:condition="not: view/builds">
94 This recipe has not been built yet.
95 </p>
93 <tal:request replace="structure context/menu:context/request_builds/fmt:link" />96 <tal:request replace="structure context/menu:context/request_builds/fmt:link" />
94 </div>97 </div>
95 <div class='portlet'>98 <div class='portlet'>