Merge lp:~jelmer/launchpad/621778-homepage-field into lp:launchpad/db-devel
- 621778-homepage-field
- Merge into db-devel
Status: | Merged |
---|---|
Approved by: | Jelmer Vernooij |
Approved revision: | no longer in the source branch. |
Merged at revision: | 9719 |
Proposed branch: | lp:~jelmer/launchpad/621778-homepage-field |
Merge into: | lp:launchpad/db-devel |
Diff against target: |
269 lines (+80/-10) 13 files modified
database/schema/comments.sql (+2/-0) database/schema/patch-2208-05-0.sql (+11/-0) lib/lp/registry/interfaces/distroseries.py (+4/-1) lib/lp/registry/model/distroseries.py (+3/-2) lib/lp/soyuz/interfaces/binarypackagebuild.py (+1/-1) lib/lp/soyuz/interfaces/binarypackagerelease.py (+7/-0) lib/lp/soyuz/interfaces/sourcepackagerelease.py (+8/-0) lib/lp/soyuz/model/binarypackagebuild.py (+2/-2) lib/lp/soyuz/model/binarypackagerelease.py (+1/-0) lib/lp/soyuz/model/sourcepackagerelease.py (+1/-0) lib/lp/soyuz/tests/test_binarypackagerelease.py (+16/-0) lib/lp/soyuz/tests/test_sourcepackagerelease.py (+16/-0) lib/lp/testing/factory.py (+8/-4) |
To merge this branch: | bzr merge lp:~jelmer/launchpad/621778-homepage-field |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Tim Penhey (community) | Approve | ||
Steve Kowalik (community) | code* | Approve | |
Stuart Bishop (community) | db | Approve | |
Robert Collins (community) | db | Approve | |
Review via email: mp+33331@code.launchpad.net |
Commit message
Add SourcePackageRe
Description of the change
This adds a "Homepage" field to SourcePackageRe
This field was added to the Debian policy a fairly recently, see http://
I'm adding this field so that it can be used as the default value for the upstream homepage URL when creating an upstream project from an Ubuntu source package.
See: https:/
Stuart Bishop (stub) wrote : | # |
Is homepage one word or two? Both forms are in common use and I don't know if LP Style prefers homepage or home_page.
DB patch is fine. It would be lovely if we could enforce the format of the string using a CHECK constraint, but I don't think we can - we have to accept whatever rubbish the user put in the package that they uploaded. You might want to mention this in the comment before anyone attempts to naively mark it up (possible attack vector there if someone sticks Javascript in the homepage field and we don't validate the URL before marking it up).
patch-2208-05-0.sql
Robert Collins (lifeless) wrote : | # |
On Mon, Aug 23, 2010 at 6:25 PM, Stuart Bishop
<email address hidden> wrote:
> Review: Approve db
> Is homepage one word or two? Both forms are in common use and I don't know if LP Style prefers homepage or home_page.
>
> DB patch is fine. It would be lovely if we could enforce the format of the string using a CHECK constraint, but I don't think we can - we have to accept whatever rubbish the user put in the package that they uploaded. You might want to mention this in the comment before anyone attempts to naively mark it up (possible attack vector there if someone sticks Javascript in the homepage field and we don't validate the URL before marking it up).
Good catch: I suggest making the factory function return just such a
javascript function by default, to make it blindingly obvious :)
-Rob
Jelmer Vernooij (jelmer) wrote : | # |
> Is homepage one word or two? Both forms are in common use and I don't know if
> LP Style prefers homepage or home_page.
Both "homepage" and "home page" are allowed according to my dictionary. "homepage" appears to be used more often in the Launchpad source code.
> DB patch is fine. It would be lovely if we could enforce the format of the
> string using a CHECK constraint, but I don't think we can - we have to accept
> whatever rubbish the user put in the package that they uploaded. You might
> want to mention this in the comment before anyone attempts to naively mark it
> up (possible attack vector there if someone sticks Javascript in the homepage
> field and we don't validate the URL before marking it up).
Makes sense, updated in the database comment and the API interface.
Jelmer Vernooij (jelmer) wrote : | # |
> > Is homepage one word or two? Both forms are in common use and I don't know
> if
> > LP Style prefers homepage or home_page.
> Both "homepage" and "home page" are allowed according to my dictionary.
> "homepage" appears to be used more often in the Launchpad source code.
"Homepage" is also the name of the field in the Debian control file from which this field will be set.
Steve Kowalik (stevenk) wrote : | # |
Hi,
These changes look pretty good, I just have some concerns:
* There exists lp.services.
* Why is homepage not exported over the API?
Steve Kowalik (stevenk) wrote : | # |
One thing I forgot to mention is the you aren't using the patch filename that stub mentioned.
Jelmer Vernooij (jelmer) wrote : | # |
> These changes look pretty good, I just have some concerns:
>
> * There exists lp.services.
> that are passed to it. Does that sound like a better fit than TextField?
Since we're importing the homepage field from the user-provided Debian package control fields, we can't rely on the homepage field containing a valid URL.
> * Why is homepage not exported over the API?
Mainly because the rest of SourcePackageRe
Steve Kowalik (stevenk) wrote : | # |
Okay, this looks good to me!
Tim Penhey (thumper) : | # |
Preview Diff
1 | === modified file 'database/schema/comments.sql' | |||
2 | --- database/schema/comments.sql 2010-08-23 04:51:48 +0000 | |||
3 | +++ database/schema/comments.sql 2010-08-25 12:22:47 +0000 | |||
4 | @@ -1339,6 +1339,7 @@ | |||
5 | 1339 | COMMENT ON COLUMN SourcePackageRelease.build_conflicts_indep IS 'The list of packages that will conflict with this source while building in architecture independent environment, as mentioned in the control file "Build-Conflicts-Indep:" field.'; | 1339 | COMMENT ON COLUMN SourcePackageRelease.build_conflicts_indep IS 'The list of packages that will conflict with this source while building in architecture independent environment, as mentioned in the control file "Build-Conflicts-Indep:" field.'; |
6 | 1340 | COMMENT ON COLUMN SourcePackageRelease.changelog IS 'The LibraryFileAlias ID of changelog associated with this sourcepackage. Often in the case of debian packages and will be found after the installation in /usr/share/doc/<binarypackagename>/changelog.Debian.gz'; | 1340 | COMMENT ON COLUMN SourcePackageRelease.changelog IS 'The LibraryFileAlias ID of changelog associated with this sourcepackage. Often in the case of debian packages and will be found after the installation in /usr/share/doc/<binarypackagename>/changelog.Debian.gz'; |
7 | 1341 | COMMENT ON COLUMN SourcePackageRelease.user_defined_fields IS 'A JSON struct containing a sequence of key-value pairs with user defined fields in the control file.'; | 1341 | COMMENT ON COLUMN SourcePackageRelease.user_defined_fields IS 'A JSON struct containing a sequence of key-value pairs with user defined fields in the control file.'; |
8 | 1342 | COMMENT ON COLUMN SourcePackageRelease.homepage IS 'Upstream project homepage URL, not checked for validity.'; | ||
9 | 1342 | 1343 | ||
10 | 1343 | -- SourcePackageName | 1344 | -- SourcePackageName |
11 | 1344 | 1345 | ||
12 | @@ -1480,6 +1481,7 @@ | |||
13 | 1480 | COMMENT ON COLUMN BinaryPackageRelease.breaks IS 'The list of packages which will be broken by the installtion of this package, as it is in the control file "Breaks:" field.'; | 1481 | COMMENT ON COLUMN BinaryPackageRelease.breaks IS 'The list of packages which will be broken by the installtion of this package, as it is in the control file "Breaks:" field.'; |
14 | 1481 | COMMENT ON COLUMN BinaryPackageRelease.debug_package IS 'The corresponding binary package release containing debug symbols for this binary, if any.'; | 1482 | COMMENT ON COLUMN BinaryPackageRelease.debug_package IS 'The corresponding binary package release containing debug symbols for this binary, if any.'; |
15 | 1482 | COMMENT ON COLUMN BinaryPackageRelease.user_defined_fields IS 'A JSON struct containing a sequence of key-value pairs with user defined fields in the control file.'; | 1483 | COMMENT ON COLUMN BinaryPackageRelease.user_defined_fields IS 'A JSON struct containing a sequence of key-value pairs with user defined fields in the control file.'; |
16 | 1484 | COMMENT ON COLUMN BinaryPackageRelease.homepage IS 'Upstream project homepage URL, not checked for validity.'; | ||
17 | 1483 | 1485 | ||
18 | 1484 | 1486 | ||
19 | 1485 | -- BinaryPackageFile | 1487 | -- BinaryPackageFile |
20 | 1486 | 1488 | ||
21 | === added file 'database/schema/patch-2208-05-0.sql' | |||
22 | --- database/schema/patch-2208-05-0.sql 1970-01-01 00:00:00 +0000 | |||
23 | +++ database/schema/patch-2208-05-0.sql 2010-08-25 12:22:47 +0000 | |||
24 | @@ -0,0 +1,11 @@ | |||
25 | 1 | -- Copyright 2010 Canonical Ltd. This software is licensed under the | ||
26 | 2 | -- GNU Affero General Public License version 3 (see the file LICENSE). | ||
27 | 3 | SET client_min_messages=ERROR; | ||
28 | 4 | |||
29 | 5 | ALTER TABLE BinaryPackageRelease | ||
30 | 6 | ADD COLUMN homepage TEXT; | ||
31 | 7 | |||
32 | 8 | ALTER TABLE SourcePackageRelease | ||
33 | 9 | ADD COLUMN homepage TEXT; | ||
34 | 10 | |||
35 | 11 | INSERT INTO LaunchpadDatabaseRevision VALUES (2208, 05, 0); | ||
36 | 0 | 12 | ||
37 | === modified file 'lib/lp/registry/interfaces/distroseries.py' | |||
38 | --- lib/lp/registry/interfaces/distroseries.py 2010-08-21 13:54:20 +0000 | |||
39 | +++ lib/lp/registry/interfaces/distroseries.py 2010-08-25 12:22:47 +0000 | |||
40 | @@ -602,7 +602,8 @@ | |||
41 | 602 | dsc_maintainer_rfc822, dsc_standards_version, dsc_format, | 602 | dsc_maintainer_rfc822, dsc_standards_version, dsc_format, |
42 | 603 | dsc_binaries, archive, copyright, build_conflicts, | 603 | dsc_binaries, archive, copyright, build_conflicts, |
43 | 604 | build_conflicts_indep, dateuploaded=None, | 604 | build_conflicts_indep, dateuploaded=None, |
45 | 605 | source_package_recipe_build=None, user_defined_fields=None): | 605 | source_package_recipe_build=None, user_defined_fields=None, |
46 | 606 | homepage=None): | ||
47 | 606 | """Create an uploads `SourcePackageRelease`. | 607 | """Create an uploads `SourcePackageRelease`. |
48 | 607 | 608 | ||
49 | 608 | Set this distroseries set to be the uploadeddistroseries. | 609 | Set this distroseries set to be the uploadeddistroseries. |
50 | @@ -640,6 +641,8 @@ | |||
51 | 640 | :param source_package_recipe_build: optional SourcePackageRecipeBuild | 641 | :param source_package_recipe_build: optional SourcePackageRecipeBuild |
52 | 641 | :param user_defined_fields: optional sequence of key-value pairs with | 642 | :param user_defined_fields: optional sequence of key-value pairs with |
53 | 642 | user defined fields. | 643 | user defined fields. |
54 | 644 | :param homepage: optional string with (unchecked) upstream homepage | ||
55 | 645 | URL | ||
56 | 643 | :return: the just creates `SourcePackageRelease` | 646 | :return: the just creates `SourcePackageRelease` |
57 | 644 | """ | 647 | """ |
58 | 645 | 648 | ||
59 | 646 | 649 | ||
60 | === modified file 'lib/lp/registry/model/distroseries.py' | |||
61 | --- lib/lp/registry/model/distroseries.py 2010-08-24 20:30:48 +0000 | |||
62 | +++ lib/lp/registry/model/distroseries.py 2010-08-25 12:22:47 +0000 | |||
63 | @@ -1186,7 +1186,8 @@ | |||
64 | 1186 | dsc_maintainer_rfc822, dsc_standards_version, dsc_format, | 1186 | dsc_maintainer_rfc822, dsc_standards_version, dsc_format, |
65 | 1187 | dsc_binaries, archive, copyright, build_conflicts, | 1187 | dsc_binaries, archive, copyright, build_conflicts, |
66 | 1188 | build_conflicts_indep, dateuploaded=DEFAULT, | 1188 | build_conflicts_indep, dateuploaded=DEFAULT, |
68 | 1189 | source_package_recipe_build=None, user_defined_fields=None): | 1189 | source_package_recipe_build=None, user_defined_fields=None, |
69 | 1190 | homepage=None): | ||
70 | 1190 | """See `IDistroSeries`.""" | 1191 | """See `IDistroSeries`.""" |
71 | 1191 | return SourcePackageRelease( | 1192 | return SourcePackageRelease( |
72 | 1192 | upload_distroseries=self, sourcepackagename=sourcepackagename, | 1193 | upload_distroseries=self, sourcepackagename=sourcepackagename, |
73 | @@ -1203,7 +1204,7 @@ | |||
74 | 1203 | build_conflicts=build_conflicts, | 1204 | build_conflicts=build_conflicts, |
75 | 1204 | build_conflicts_indep=build_conflicts_indep, | 1205 | build_conflicts_indep=build_conflicts_indep, |
76 | 1205 | source_package_recipe_build=source_package_recipe_build, | 1206 | source_package_recipe_build=source_package_recipe_build, |
78 | 1206 | user_defined_fields=user_defined_fields) | 1207 | user_defined_fields=user_defined_fields, homepage=homepage) |
79 | 1207 | 1208 | ||
80 | 1208 | def getComponentByName(self, name): | 1209 | def getComponentByName(self, name): |
81 | 1209 | """See `IDistroSeries`.""" | 1210 | """See `IDistroSeries`.""" |
82 | 1210 | 1211 | ||
83 | === modified file 'lib/lp/soyuz/interfaces/binarypackagebuild.py' | |||
84 | --- lib/lp/soyuz/interfaces/binarypackagebuild.py 2010-08-21 13:54:20 +0000 | |||
85 | +++ lib/lp/soyuz/interfaces/binarypackagebuild.py 2010-08-25 12:22:47 +0000 | |||
86 | @@ -140,7 +140,7 @@ | |||
87 | 140 | shlibdeps=None, depends=None, recommends=None, suggests=None, | 140 | shlibdeps=None, depends=None, recommends=None, suggests=None, |
88 | 141 | conflicts=None, replaces=None, provides=None, pre_depends=None, | 141 | conflicts=None, replaces=None, provides=None, pre_depends=None, |
89 | 142 | enhances=None, breaks=None, essential=False, debug_package=None, | 142 | enhances=None, breaks=None, essential=False, debug_package=None, |
91 | 143 | user_defined_fields=None): | 143 | user_defined_fields=None, homepage=None): |
92 | 144 | """Create and return a `BinaryPackageRelease`. | 144 | """Create and return a `BinaryPackageRelease`. |
93 | 145 | 145 | ||
94 | 146 | The binarypackagerelease will be attached to this specific build. | 146 | The binarypackagerelease will be attached to this specific build. |
95 | 147 | 147 | ||
96 | === modified file 'lib/lp/soyuz/interfaces/binarypackagerelease.py' | |||
97 | --- lib/lp/soyuz/interfaces/binarypackagerelease.py 2010-08-21 13:56:34 +0000 | |||
98 | +++ lib/lp/soyuz/interfaces/binarypackagerelease.py 2010-08-25 12:22:47 +0000 | |||
99 | @@ -80,6 +80,13 @@ | |||
100 | 80 | user_defined_fields = List( | 80 | user_defined_fields = List( |
101 | 81 | title=_("Sequence of user-defined fields as key-value pairs.")) | 81 | title=_("Sequence of user-defined fields as key-value pairs.")) |
102 | 82 | 82 | ||
103 | 83 | homepage = TextLine( | ||
104 | 84 | title=_("Homepage"), | ||
105 | 85 | description=_( | ||
106 | 86 | "Upstream project homepage as set in the package. This URL is not " | ||
107 | 87 | "sanitized."), | ||
108 | 88 | required=False) | ||
109 | 89 | |||
110 | 83 | files = Attribute("Related list of IBinaryPackageFile entries") | 90 | files = Attribute("Related list of IBinaryPackageFile entries") |
111 | 84 | 91 | ||
112 | 85 | title = TextLine(required=True, readonly=True) | 92 | title = TextLine(required=True, readonly=True) |
113 | 86 | 93 | ||
114 | === modified file 'lib/lp/soyuz/interfaces/sourcepackagerelease.py' | |||
115 | --- lib/lp/soyuz/interfaces/sourcepackagerelease.py 2010-08-21 13:56:34 +0000 | |||
116 | +++ lib/lp/soyuz/interfaces/sourcepackagerelease.py 2010-08-25 12:22:47 +0000 | |||
117 | @@ -104,6 +104,14 @@ | |||
118 | 104 | 104 | ||
119 | 105 | user_defined_fields = List( | 105 | user_defined_fields = List( |
120 | 106 | title=_("Sequence of user-defined fields as key-value pairs.")) | 106 | title=_("Sequence of user-defined fields as key-value pairs.")) |
121 | 107 | |||
122 | 108 | homepage = TextLine( | ||
123 | 109 | title=_("Homepage"), | ||
124 | 110 | description=_( | ||
125 | 111 | "Upstream project homepage as set in the package. This URL is not " | ||
126 | 112 | "sanitized."), | ||
127 | 113 | required=False) | ||
128 | 114 | |||
129 | 107 | # read-only properties | 115 | # read-only properties |
130 | 108 | name = Attribute('The sourcepackagename for this release, as text') | 116 | name = Attribute('The sourcepackagename for this release, as text') |
131 | 109 | title = Attribute('The title of this sourcepackagerelease') | 117 | title = Attribute('The title of this sourcepackagerelease') |
132 | 110 | 118 | ||
133 | === modified file 'lib/lp/soyuz/model/binarypackagebuild.py' | |||
134 | --- lib/lp/soyuz/model/binarypackagebuild.py 2010-08-25 00:30:21 +0000 | |||
135 | +++ lib/lp/soyuz/model/binarypackagebuild.py 2010-08-25 12:22:47 +0000 | |||
136 | @@ -485,7 +485,7 @@ | |||
137 | 485 | architecturespecific, shlibdeps=None, depends=None, recommends=None, | 485 | architecturespecific, shlibdeps=None, depends=None, recommends=None, |
138 | 486 | suggests=None, conflicts=None, replaces=None, provides=None, | 486 | suggests=None, conflicts=None, replaces=None, provides=None, |
139 | 487 | pre_depends=None, enhances=None, breaks=None, essential=False, | 487 | pre_depends=None, enhances=None, breaks=None, essential=False, |
141 | 488 | debug_package=None, user_defined_fields=None): | 488 | debug_package=None, user_defined_fields=None, homepage=None): |
142 | 489 | """See IBuild.""" | 489 | """See IBuild.""" |
143 | 490 | return BinaryPackageRelease( | 490 | return BinaryPackageRelease( |
144 | 491 | build=self, binarypackagename=binarypackagename, version=version, | 491 | build=self, binarypackagename=binarypackagename, version=version, |
145 | @@ -498,7 +498,7 @@ | |||
146 | 498 | breaks=breaks, essential=essential, installedsize=installedsize, | 498 | breaks=breaks, essential=essential, installedsize=installedsize, |
147 | 499 | architecturespecific=architecturespecific, | 499 | architecturespecific=architecturespecific, |
148 | 500 | debug_package=debug_package, | 500 | debug_package=debug_package, |
150 | 501 | user_defined_fields=user_defined_fields) | 501 | user_defined_fields=user_defined_fields, homepage=homepage) |
151 | 502 | 502 | ||
152 | 503 | def estimateDuration(self): | 503 | def estimateDuration(self): |
153 | 504 | """See `IPackageBuild`.""" | 504 | """See `IPackageBuild`.""" |
154 | 505 | 505 | ||
155 | === modified file 'lib/lp/soyuz/model/binarypackagerelease.py' | |||
156 | --- lib/lp/soyuz/model/binarypackagerelease.py 2010-08-21 13:56:34 +0000 | |||
157 | +++ lib/lp/soyuz/model/binarypackagerelease.py 2010-08-25 12:22:47 +0000 | |||
158 | @@ -81,6 +81,7 @@ | |||
159 | 81 | installedsize = IntCol(dbName='installedsize') | 81 | installedsize = IntCol(dbName='installedsize') |
160 | 82 | architecturespecific = BoolCol(dbName='architecturespecific', | 82 | architecturespecific = BoolCol(dbName='architecturespecific', |
161 | 83 | notNull=True) | 83 | notNull=True) |
162 | 84 | homepage = StringCol(dbName='homepage') | ||
163 | 84 | datecreated = UtcDateTimeCol(notNull=True, default=UTC_NOW) | 85 | datecreated = UtcDateTimeCol(notNull=True, default=UTC_NOW) |
164 | 85 | debug_package = ForeignKey(dbName='debug_package', | 86 | debug_package = ForeignKey(dbName='debug_package', |
165 | 86 | foreignKey='BinaryPackageRelease') | 87 | foreignKey='BinaryPackageRelease') |
166 | 87 | 88 | ||
167 | === modified file 'lib/lp/soyuz/model/sourcepackagerelease.py' | |||
168 | --- lib/lp/soyuz/model/sourcepackagerelease.py 2010-08-21 13:56:34 +0000 | |||
169 | +++ lib/lp/soyuz/model/sourcepackagerelease.py 2010-08-25 12:22:47 +0000 | |||
170 | @@ -146,6 +146,7 @@ | |||
171 | 146 | build_conflicts = StringCol(dbName='build_conflicts') | 146 | build_conflicts = StringCol(dbName='build_conflicts') |
172 | 147 | build_conflicts_indep = StringCol(dbName='build_conflicts_indep') | 147 | build_conflicts_indep = StringCol(dbName='build_conflicts_indep') |
173 | 148 | architecturehintlist = StringCol(dbName='architecturehintlist') | 148 | architecturehintlist = StringCol(dbName='architecturehintlist') |
174 | 149 | homepage = StringCol(dbName='homepage') | ||
175 | 149 | format = EnumCol(dbName='format', schema=SourcePackageType, | 150 | format = EnumCol(dbName='format', schema=SourcePackageType, |
176 | 150 | default=SourcePackageType.DPKG, notNull=True) | 151 | default=SourcePackageType.DPKG, notNull=True) |
177 | 151 | upload_distroseries = ForeignKey(foreignKey='DistroSeries', | 152 | upload_distroseries = ForeignKey(foreignKey='DistroSeries', |
178 | 152 | 153 | ||
179 | === modified file 'lib/lp/soyuz/tests/test_binarypackagerelease.py' | |||
180 | --- lib/lp/soyuz/tests/test_binarypackagerelease.py 2010-08-21 13:56:34 +0000 | |||
181 | +++ lib/lp/soyuz/tests/test_binarypackagerelease.py 2010-08-25 12:22:47 +0000 | |||
182 | @@ -49,3 +49,19 @@ | |||
183 | 49 | self.assertEquals([ | 49 | self.assertEquals([ |
184 | 50 | ["Python-Version", ">= 2.4"], | 50 | ["Python-Version", ">= 2.4"], |
185 | 51 | ["Other", "Bla"]], release.user_defined_fields) | 51 | ["Other", "Bla"]], release.user_defined_fields) |
186 | 52 | |||
187 | 53 | def test_homepage_default(self): | ||
188 | 54 | # By default, no homepage is set. | ||
189 | 55 | bpr = self.factory.makeBinaryPackageRelease() | ||
190 | 56 | self.assertEquals(None, bpr.homepage) | ||
191 | 57 | |||
192 | 58 | def test_homepage_empty(self): | ||
193 | 59 | # The homepage field can be empty. | ||
194 | 60 | bpr = self.factory.makeBinaryPackageRelease(homepage="") | ||
195 | 61 | self.assertEquals("", bpr.homepage) | ||
196 | 62 | |||
197 | 63 | def test_homepage_set_invalid(self): | ||
198 | 64 | # As the homepage field is inherited from the .deb, the URL | ||
199 | 65 | # does not have to be valid. | ||
200 | 66 | bpr = self.factory.makeBinaryPackageRelease(homepage="<invalid<url") | ||
201 | 67 | self.assertEquals("<invalid<url", bpr.homepage) | ||
202 | 52 | 68 | ||
203 | === modified file 'lib/lp/soyuz/tests/test_sourcepackagerelease.py' | |||
204 | --- lib/lp/soyuz/tests/test_sourcepackagerelease.py 2010-08-21 13:54:20 +0000 | |||
205 | +++ lib/lp/soyuz/tests/test_sourcepackagerelease.py 2010-08-25 12:22:47 +0000 | |||
206 | @@ -38,3 +38,19 @@ | |||
207 | 38 | self.assertEquals([ | 38 | self.assertEquals([ |
208 | 39 | ["Python-Version", ">= 2.4"], | 39 | ["Python-Version", ">= 2.4"], |
209 | 40 | ["Other", "Bla"]], release.user_defined_fields) | 40 | ["Other", "Bla"]], release.user_defined_fields) |
210 | 41 | |||
211 | 42 | def test_homepage_default(self): | ||
212 | 43 | # By default, no homepage is set. | ||
213 | 44 | spr = self.factory.makeSourcePackageRelease() | ||
214 | 45 | self.assertEquals(None, spr.homepage) | ||
215 | 46 | |||
216 | 47 | def test_homepage_empty(self): | ||
217 | 48 | # The homepage field can be empty. | ||
218 | 49 | spr = self.factory.makeSourcePackageRelease(homepage="") | ||
219 | 50 | self.assertEquals("", spr.homepage) | ||
220 | 51 | |||
221 | 52 | def test_homepage_set_invalid(self): | ||
222 | 53 | # As the homepage field is inherited from the DSCFile, the URL | ||
223 | 54 | # does not have to be valid. | ||
224 | 55 | spr = self.factory.makeSourcePackageRelease(homepage="<invalid<url") | ||
225 | 56 | self.assertEquals("<invalid<url", spr.homepage) | ||
226 | 41 | 57 | ||
227 | === modified file 'lib/lp/testing/factory.py' | |||
228 | --- lib/lp/testing/factory.py 2010-08-23 08:12:39 +0000 | |||
229 | +++ lib/lp/testing/factory.py 2010-08-25 12:22:47 +0000 | |||
230 | @@ -2408,7 +2408,8 @@ | |||
231 | 2408 | date_uploaded=UTC_NOW, | 2408 | date_uploaded=UTC_NOW, |
232 | 2409 | source_package_recipe_build=None, | 2409 | source_package_recipe_build=None, |
233 | 2410 | dscsigningkey=None, | 2410 | dscsigningkey=None, |
235 | 2411 | user_defined_fields=None): | 2411 | user_defined_fields=None, |
236 | 2412 | homepage=None): | ||
237 | 2412 | """Make a `SourcePackageRelease`.""" | 2413 | """Make a `SourcePackageRelease`.""" |
238 | 2413 | if distroseries is None: | 2414 | if distroseries is None: |
239 | 2414 | if source_package_recipe_build is not None: | 2415 | if source_package_recipe_build is not None: |
240 | @@ -2476,7 +2477,8 @@ | |||
241 | 2476 | archive=archive, | 2477 | archive=archive, |
242 | 2477 | dateuploaded=date_uploaded, | 2478 | dateuploaded=date_uploaded, |
243 | 2478 | source_package_recipe_build=source_package_recipe_build, | 2479 | source_package_recipe_build=source_package_recipe_build, |
245 | 2479 | user_defined_fields=user_defined_fields) | 2480 | user_defined_fields=user_defined_fields, |
246 | 2481 | homepage=homepage) | ||
247 | 2480 | 2482 | ||
248 | 2481 | def makeSourcePackageReleaseFile(self, sourcepackagerelease=None, | 2483 | def makeSourcePackageReleaseFile(self, sourcepackagerelease=None, |
249 | 2482 | library_file=None, filetype=None): | 2484 | library_file=None, filetype=None): |
250 | @@ -2704,7 +2706,8 @@ | |||
251 | 2704 | provides=None, pre_depends=None, | 2706 | provides=None, pre_depends=None, |
252 | 2705 | enhances=None, breaks=None, | 2707 | enhances=None, breaks=None, |
253 | 2706 | essential=False, installed_size=None, | 2708 | essential=False, installed_size=None, |
255 | 2707 | date_created=None, debug_package=None): | 2709 | date_created=None, debug_package=None, |
256 | 2710 | homepage=None): | ||
257 | 2708 | """Make a `BinaryPackageRelease`.""" | 2711 | """Make a `BinaryPackageRelease`.""" |
258 | 2709 | if build is None: | 2712 | if build is None: |
259 | 2710 | build = self.makeBinaryPackageBuild() | 2713 | build = self.makeBinaryPackageBuild() |
260 | @@ -2735,7 +2738,8 @@ | |||
261 | 2735 | suggests=suggests, conflicts=conflicts, replaces=replaces, | 2738 | suggests=suggests, conflicts=conflicts, replaces=replaces, |
262 | 2736 | provides=provides, pre_depends=pre_depends, | 2739 | provides=provides, pre_depends=pre_depends, |
263 | 2737 | enhances=enhances, breaks=breaks, essential=essential, | 2740 | enhances=enhances, breaks=breaks, essential=essential, |
265 | 2738 | installedsize=installed_size, debug_package=debug_package) | 2741 | installedsize=installed_size, debug_package=debug_package, |
266 | 2742 | homepage=homepage) | ||
267 | 2739 | if date_created is not None: | 2743 | if date_created is not None: |
268 | 2740 | removeSecurityProxy(bpr).datecreated = date_created | 2744 | removeSecurityProxy(bpr).datecreated = date_created |
269 | 2741 | return bpr | 2745 | return bpr |
If you're adding in python support for this, I think a couple of tests would be sensible: e.g. that you want it nullable.
DB side looks fine.