Merge lp:~rockstar/launchpad/recipe-description into lp:launchpad/db-devel

Proposed by Paul Hummer on 2010-03-16
Status: Merged
Approved by: Björn Tillenius on 2010-03-24
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~rockstar/launchpad/recipe-description
Merge into: lp:launchpad/db-devel
Diff against target: 186 lines (+52/-9)
7 files modified
database/schema/patch-2207-37-0.sql (+9/-0)
lib/lp/code/interfaces/sourcepackagerecipe.py (+6/-2)
lib/lp/code/model/sourcepackagerecipe.py (+3/-1)
lib/lp/code/model/tests/test_sourcepackagerecipe.py (+22/-0)
lib/lp/code/tests/test_recipebuilder.py (+1/-1)
lib/lp/code/tests/test_sourcepackagerecipe.py (+6/-3)
lib/lp/testing/factory.py (+5/-2)
To merge this branch: bzr merge lp:~rockstar/launchpad/recipe-description
Reviewer Review Type Date Requested Status
Björn Tillenius (community) db 2010-03-16 Approve on 2010-03-24
Stuart Bishop db 2010-03-16 Approve on 2010-03-17
Brad Crittenden (community) code 2010-03-16 Approve on 2010-03-16
Review via email: mp+21479@code.launchpad.net

Description of the Change

This branch adds a description to SourcePackageRecipes - abentley and I
realized that it was missing from the model, and we needed it based on my
mockups and the fact that recipes are very hard to decipher the purpose of
otherwise.

To post a comment you must log in.
Brad Crittenden (bac) :
review: Approve (code)
Stuart Bishop (stub) wrote :

Fine. patch-2207-37-0.sql.

Consider making the new description column NOT NULL if the UI really doesn't make sense without one set.

review: Approve (db)
Björn Tillenius (bjornt) wrote :

On Tue, Mar 16, 2010 at 07:41:20PM -0000, Paul Hummer wrote:
> === added file 'database/schema/patch-2207-99-0.sql'
> --- database/schema/patch-2207-99-0.sql 1970-01-01 00:00:00 +0000
> +++ database/schema/patch-2207-99-0.sql 2010-03-16 19:41:18 +0000
> @@ -0,0 +1,9 @@
> +-- Copyright 2010 Canonical Ltd. This software is licensed under the
> +-- GNU Affero General Public License version 3 (see the file LICENSE).
> +
> +SET client_min_messages=ERROR;
> +
> +ALTER TABLE SourcePackageRecipe
> +ADD COLUMN description TEXT;
> +
> +INSERT INTO LaunchpadDatabaseRevision VALUES (2207, 99, 0);
>
> === modified file 'lib/lp/code/interfaces/sourcepackagerecipe.py'
> --- lib/lp/code/interfaces/sourcepackagerecipe.py 2010-02-05 14:22:03 +0000
> +++ lib/lp/code/interfaces/sourcepackagerecipe.py 2010-03-16 19:41:18 +0000
> @@ -71,6 +71,10 @@
> constraint=name_validator,
> description=_("The name of this recipe."))
>
> + description = Text(
> + title=_('Description'), required=False,
> + description=_('A short description of the recipe.'))
> +

The interface says that the description can't be None, while the db
patch says that it can. What should it be? Judging from your comments,
it seems that it should be not-None, though.

> builder_recipe = Attribute(
> _("The bzr-builder data structure for the recipe."))
>
>
> === modified file 'lib/lp/code/model/sourcepackagerecipe.py'
> --- lib/lp/code/model/sourcepackagerecipe.py 2010-02-05 15:38:19 +0000
> +++ lib/lp/code/model/sourcepackagerecipe.py 2010-03-16 19:41:18 +0000
> @@ -58,6 +58,7 @@
> sourcepackagename_id, 'SourcePackageName.id')
>
> name = Unicode(allow_none=True)
> + description = StringCol(dbName='description')

StringCol from sqlobject on a storm object? Does this even work? A small
test might be useful :)

    review needsfixing

--
Björn Tillenius | https://launchpad.net/~bjornt

review: Needs Fixing
Björn Tillenius (bjornt) wrote :

As discussed on IRC, the interface now says that the description can be None, while the db patch says it can. Paul said he would make things consistent (description can't be None).

review: Approve (db)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'database/sampledata/current-dev.sql'
2=== modified file 'database/sampledata/current.sql'
3=== added file 'database/schema/patch-2207-37-0.sql'
4--- database/schema/patch-2207-37-0.sql 1970-01-01 00:00:00 +0000
5+++ database/schema/patch-2207-37-0.sql 2010-03-26 17:54:33 +0000
6@@ -0,0 +1,9 @@
7+-- Copyright 2010 Canonical Ltd. This software is licensed under the
8+-- GNU Affero General Public License version 3 (see the file LICENSE).
9+
10+SET client_min_messages=ERROR;
11+
12+ALTER TABLE SourcePackageRecipe
13+ADD COLUMN description TEXT NOT NULL;
14+
15+INSERT INTO LaunchpadDatabaseRevision VALUES (2207, 37, 0);
16
17=== modified file 'lib/lp/code/interfaces/sourcepackagerecipe.py'
18--- lib/lp/code/interfaces/sourcepackagerecipe.py 2010-03-25 15:21:54 +0000
19+++ lib/lp/code/interfaces/sourcepackagerecipe.py 2010-03-26 17:54:33 +0000
20@@ -14,7 +14,7 @@
21 from lazr.restful.fields import Reference
22
23 from zope.interface import Attribute, Interface
24-from zope.schema import Datetime, TextLine
25+from zope.schema import Datetime, Text, TextLine
26
27 from canonical.launchpad import _
28 from canonical.launchpad.validators.name import name_validator
29@@ -72,6 +72,10 @@
30 constraint=name_validator,
31 description=_("The name of this recipe."))
32
33+ description = Text(
34+ title=_('Description'), required=True,
35+ description=_('A short description of the recipe.'))
36+
37 builder_recipe = Attribute(
38 _("The bzr-builder data structure for the recipe."))
39
40@@ -98,5 +102,5 @@
41 """
42
43 def new(registrant, owner, distroseries, sourcepackagename, name,
44- builder_recipe):
45+ builder_recipe, description):
46 """Create an `ISourcePackageRecipe`."""
47
48=== modified file 'lib/lp/code/model/sourcepackagerecipe.py'
49--- lib/lp/code/model/sourcepackagerecipe.py 2010-03-25 15:21:54 +0000
50+++ lib/lp/code/model/sourcepackagerecipe.py 2010-03-26 17:54:33 +0000
51@@ -58,6 +58,7 @@
52 sourcepackagename_id, 'SourcePackageName.id')
53
54 name = Unicode(allow_none=True)
55+ description = Unicode(allow_none=False)
56
57 @property
58 def _recipe_data(self):
59@@ -85,7 +86,7 @@
60
61 @staticmethod
62 def new(registrant, owner, distroseries, sourcepackagename, name,
63- builder_recipe):
64+ builder_recipe, description):
65 """See `ISourcePackageRecipeSource.new`."""
66 store = IMasterStore(SourcePackageRecipe)
67 sprecipe = SourcePackageRecipe()
68@@ -95,6 +96,7 @@
69 sprecipe.distroseries = distroseries
70 sprecipe.sourcepackagename = sourcepackagename
71 sprecipe.name = name
72+ sprecipe.description = description
73 store.add(sprecipe)
74 return sprecipe
75
76
77=== added file 'lib/lp/code/model/tests/test_sourcepackagerecipe.py'
78--- lib/lp/code/model/tests/test_sourcepackagerecipe.py 1970-01-01 00:00:00 +0000
79+++ lib/lp/code/model/tests/test_sourcepackagerecipe.py 2010-03-26 17:54:33 +0000
80@@ -0,0 +1,22 @@
81+# Copyright 2010 Canonical Ltd. This software is licensed under the
82+# GNU Affero General Public License version 3 (see the file LICENSE).
83+
84+"""Tests for SourcePackageRecipes."""
85+
86+__metaclass__ = type
87+
88+from lp.testing import (
89+ run_with_login, TestCase, TestCaseWithFactory, time_counter)
90+from canonical.testing import DatabaseFunctionalLayer, LaunchpadZopelessLayer
91+
92+
93+class TestSourcePackageRecipe(TestCaseWithFactory):
94+
95+ layer = LaunchpadZopelessLayer
96+
97+ def test_sourcepackagerecipe_description(self):
98+ """Ensure that the SourcePackageRecipe has a proper description."""
99+ description = u'The whoozits and whatzits.'
100+ source_package_recipe = self.factory.makeSourcePackageRecipe(
101+ description=description)
102+ self.assertEqual(description, source_package_recipe.description)
103
104=== modified file 'lib/lp/code/tests/test_recipebuilder.py'
105--- lib/lp/code/tests/test_recipebuilder.py 2010-02-05 15:26:10 +0000
106+++ lib/lp/code/tests/test_recipebuilder.py 2010-03-26 17:54:33 +0000
107@@ -59,7 +59,7 @@
108 somebranch = self.factory.makeBranch(owner=requester, name="pkg",
109 product=self.factory.makeProduct("someapp"))
110 recipe = self.factory.makeSourcePackageRecipe(requester, requester,
111- distroseries, spn, u"recept", somebranch)
112+ distroseries, spn, u"recept", u"Recipe description", somebranch)
113 spb = self.factory.makeSourcePackageRecipeBuild(
114 sourcepackage=sourcepackage, recipe=recipe, requester=requester)
115 job = spb.makeJob()
116
117=== modified file 'lib/lp/code/tests/test_sourcepackagerecipe.py'
118--- lib/lp/code/tests/test_sourcepackagerecipe.py 2010-03-25 15:21:54 +0000
119+++ lib/lp/code/tests/test_sourcepackagerecipe.py 2010-03-26 17:54:33 +0000
120@@ -51,10 +51,11 @@
121 distroseries = self.factory.makeDistroSeries()
122 sourcepackagename = self.factory.makeSourcePackageName()
123 name = self.factory.getUniqueString(u'recipe-name')
124+ description = self.factory.getUniqueString(u'recipe-description')
125 return getUtility(ISourcePackageRecipeSource).new(
126 registrant=registrant, owner=owner, distroseries=distroseries,
127 sourcepackagename=sourcepackagename, name=name,
128- builder_recipe=builder_recipe)
129+ description=description, builder_recipe=builder_recipe)
130
131 def test_creation(self):
132 # The metadata supplied when a SourcePackageRecipe is created is
133@@ -64,11 +65,12 @@
134 distroseries = self.factory.makeDistroSeries()
135 sourcepackagename = self.factory.makeSourcePackageName()
136 name = self.factory.getUniqueString(u'recipe-name')
137+ description = self.factory.getUniqueString(u'recipe-description')
138 builder_recipe = self.factory.makeRecipe()
139 recipe = getUtility(ISourcePackageRecipeSource).new(
140 registrant=registrant, owner=owner, distroseries=distroseries,
141 sourcepackagename=sourcepackagename, name=name,
142- builder_recipe=builder_recipe)
143+ description=description, builder_recipe=builder_recipe)
144 self.assertEquals(
145 (registrant, owner, distroseries, sourcepackagename, name),
146 (recipe.registrant, recipe.owner, recipe.distroseries,
147@@ -250,10 +252,11 @@
148 distroseries = self.factory.makeDistroSeries()
149 sourcepackagename = self.factory.makeSourcePackageName()
150 name = self.factory.getUniqueString(u'recipe-name')
151+ description = self.factory.getUniqueString(u'recipe-description')
152 recipe = getUtility(ISourcePackageRecipeSource).new(
153 registrant=registrant, owner=owner, distroseries=distroseries,
154 sourcepackagename=sourcepackagename, name=name,
155- builder_recipe=builder_recipe)
156+ description=description, builder_recipe=builder_recipe)
157 return recipe.builder_recipe
158
159 def check_base_recipe_branch(self, branch, url, revspec=None,
160
161=== modified file 'lib/lp/testing/factory.py'
162--- lib/lp/testing/factory.py 2010-03-25 08:48:14 +0000
163+++ lib/lp/testing/factory.py 2010-03-26 17:54:33 +0000
164@@ -1761,7 +1761,7 @@
165
166 def makeSourcePackageRecipe(self, registrant=None, owner=None,
167 distroseries=None, sourcepackagename=None,
168- name=None, *branches):
169+ name=None, description=None, *branches):
170 """Make a `SourcePackageRecipe`."""
171 if registrant is None:
172 registrant = self.makePerson()
173@@ -1773,9 +1773,12 @@
174 sourcepackagename = self.makeSourcePackageName()
175 if name is None:
176 name = self.getUniqueString().decode('utf8')
177+ if description is None:
178+ description = self.getUniqueString().decode('utf8')
179 recipe = self.makeRecipe(*branches)
180 return getUtility(ISourcePackageRecipeSource).new(
181- registrant, owner, distroseries, sourcepackagename, name, recipe)
182+ registrant, owner, distroseries, sourcepackagename, name, recipe,
183+ description)
184
185 def makeSourcePackageRecipeBuild(self, sourcepackage=None, recipe=None,
186 requester=None, archive=None,

Subscribers

People subscribed via source and target branches

to status/vote changes: