Merge lp:~jelmer/launchpad/613468-xb-ppa-db into lp:launchpad/db-devel

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merged at revision: 9651
Proposed branch: lp:~jelmer/launchpad/613468-xb-ppa-db
Merge into: lp:launchpad/db-devel
Diff against target: 404 lines (+147/-40)
14 files modified
database/schema/comments.sql (+2/-0)
database/schema/patch-2207-82-0.sql (+11/-0)
lib/lp/registry/interfaces/distroseries.py (+3/-1)
lib/lp/registry/model/distroseries.py (+3/-2)
lib/lp/soyuz/doc/binarypackagebuild.txt (+11/-22)
lib/lp/soyuz/interfaces/binarypackagebuild.py (+5/-4)
lib/lp/soyuz/interfaces/binarypackagerelease.py (+3/-1)
lib/lp/soyuz/interfaces/sourcepackagerelease.py (+3/-3)
lib/lp/soyuz/model/binarypackagebuild.py (+7/-5)
lib/lp/soyuz/model/binarypackagerelease.py (+18/-0)
lib/lp/soyuz/model/sourcepackagerelease.py (+17/-0)
lib/lp/soyuz/tests/test_binarypackagerelease.py (+51/-0)
lib/lp/soyuz/tests/test_sourcepackagerelease.py (+9/-0)
lib/lp/testing/factory.py (+4/-2)
To merge this branch: bzr merge lp:~jelmer/launchpad/613468-xb-ppa-db
Reviewer Review Type Date Requested Status
Michael Nelson (community) code Approve
Stuart Bishop (community) db Approve
Robert Collins db Pending
Review via email: mp+32307@code.launchpad.net

Commit message

Add SourcePackageRelease.user_defined_fields, BinaryPackageRelease.user_defined_fields.

Description of the change

This adds a database field for user_defined_fields to SourcePackageRelease and BinaryPackageRelease. This is required for bug 613468 so that we can put these user defined fields in the Packages and Sources files generated by the publisher.

Pre-implementation call: with bigjools

Tests:
./bin/test lp.soyuz.tests.test_binarypackagerelease lp.soyuz.tests.test_sourcepackagerelease

To post a comment you must log in.
Revision history for this message
Stuart Bishop (stub) wrote :

Fine, but needs comments on the new columns in comments.sql

patch-2207-82-0.sql

review: Approve (db)
Revision history for this message
Michael Nelson (michael.nelson) wrote :
Download full text (5.1 KiB)

Hi Jelmer! Nice clean branch :)

> === modified file 'lib/lp/soyuz/interfaces/binarypackagebuild.py'
> --- lib/lp/soyuz/interfaces/binarypackagebuild.py 2010-08-10 21:54:41 +0000
> +++ lib/lp/soyuz/interfaces/binarypackagebuild.py 2010-08-12 10:37:50 +0000
> @@ -125,10 +125,11 @@
>
> def createBinaryPackageRelease(
> binarypackagename, version, summary, description, binpackageformat,
> - component, section, priority, shlibdeps, depends, recommends,
> - suggests, conflicts, replaces, provides, pre_depends, enhances,
> - breaks, essential, installedsize, architecturespecific,
> - debug_package):
> + component, section, priority, installedsize, architecturespecific,
> + shlibdeps=None, depends=None, recommends=None, suggests=None,
> + conflicts=None, replaces=None, provides=None, pre_depends=None,
> + enhances=None, breaks=None, essential=False, debug_package=None,
> + user_defined_fields=None):

I'm assuming you've checked that all call-sites use kwargs before re-ordering... and my next question was going to be are you sure that all those kwargs are really optional, but your test_provides() ensures that too :)

> """Create and return a `BinaryPackageRelease`.
>
> The binarypackagerelease will be attached to this specific build.

>
> === modified file 'lib/lp/soyuz/interfaces/binarypackagerelease.py'
> --- lib/lp/soyuz/interfaces/binarypackagerelease.py 2010-07-10 04:52:43 +0000
> +++ lib/lp/soyuz/interfaces/binarypackagerelease.py 2010-08-12 10:37:50 +0000
> @@ -56,6 +56,8 @@
> title=_("Debug package"), schema=Interface, required=False,
> description=_("The corresponding package containing debug symbols "
> "for this binary."))
> + user_defined_fields = Attribute(
> + "Sequence of user-defined fields as key-value pairs.")

you could use zope.schema.List instead of attribute:

    user_defined_fields = List(
        title=_("Sequence of user-defined fields as key-value pairs."))

if that's what it is.

>
> files = Attribute("Related list of IBinaryPackageFile entries")
>
>
> === modified file 'lib/lp/soyuz/interfaces/sourcepackagerelease.py'
> --- lib/lp/soyuz/interfaces/sourcepackagerelease.py 2010-07-29 22:55:15 +0000
> +++ lib/lp/soyuz/interfaces/sourcepackagerelease.py 2010-08-12 10:37:50 +0000
> @@ -96,8 +96,8 @@
> "was first uploaded in Launchpad")
> publishings = Attribute("MultipleJoin on SourcepackagePublishing")
>
> -
> -
> + user_defined_fields = Attribute(
> + "Sequence of user-defined fields as key-value pairs.")

Same here.

> # read-only properties
> name = Attribute('The sourcepackagename for this release, as text')
> title = Attribute('The title of this sourcepackagerelease')
>
> === modified file 'lib/lp/soyuz/model/binarypackagerelease.py'
> --- lib/lp/soyuz/model/binarypackagerelease.py 2010-07-10 04:46:49 +0000
> +++ lib/lp/soyuz/model/binarypackagerelease.py 2010-08-12 10:37:50 +0000
> @@ -13,6...

Read more...

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'database/schema/comments.sql'
--- database/schema/comments.sql 2010-08-10 05:50:08 +0000
+++ database/schema/comments.sql 2010-08-12 19:10:59 +0000
@@ -1338,6 +1338,7 @@
1338COMMENT ON COLUMN SourcePackageRelease.build_conflicts IS 'The list of packages that will conflict with this source while building, as mentioned in the control file "Build-Conflicts:" field.';1338COMMENT ON COLUMN SourcePackageRelease.build_conflicts IS 'The list of packages that will conflict with this source while building, as mentioned in the control file "Build-Conflicts:" field.';
1339COMMENT 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.';1339COMMENT 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.';
1340COMMENT 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';1340COMMENT 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';
1341COMMENT 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.';
13411342
1342-- SourcePackageName1343-- SourcePackageName
13431344
@@ -1478,6 +1479,7 @@
1478COMMENT ON COLUMN BinaryPackageRelease.enhances IS 'The list of packages pointed as "enhanced" after the installation of this package, as it is in control file "Enhances:" field.';1479COMMENT ON COLUMN BinaryPackageRelease.enhances IS 'The list of packages pointed as "enhanced" after the installation of this package, as it is in control file "Enhances:" field.';
1479COMMENT 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.';1480COMMENT 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.';
1480COMMENT ON COLUMN BinaryPackageRelease.debug_package IS 'The corresponding binary package release containing debug symbols for this binary, if any.';1481COMMENT ON COLUMN BinaryPackageRelease.debug_package IS 'The corresponding binary package release containing debug symbols for this binary, if any.';
1482COMMENT 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.';
14811483
14821484
1483-- BinaryPackageFile1485-- BinaryPackageFile
14841486
=== added file 'database/schema/patch-2207-82-0.sql'
--- database/schema/patch-2207-82-0.sql 1970-01-01 00:00:00 +0000
+++ database/schema/patch-2207-82-0.sql 2010-08-12 19:10:59 +0000
@@ -0,0 +1,11 @@
1-- Copyright 2010 Canonical Ltd. This software is licensed under the
2-- GNU Affero General Public License version 3 (see the file LICENSE).
3SET client_min_messages=ERROR;
4
5ALTER TABLE BinaryPackageRelease
6 ADD COLUMN user_defined_fields TEXT;
7
8ALTER TABLE SourcePackageRelease
9 ADD COLUMN user_defined_fields TEXT;
10
11INSERT INTO LaunchpadDatabaseRevision VALUES (2207, 82, 0);
012
=== modified file 'lib/lp/registry/interfaces/distroseries.py'
--- lib/lp/registry/interfaces/distroseries.py 2010-08-05 00:25:36 +0000
+++ lib/lp/registry/interfaces/distroseries.py 2010-08-12 19:10:59 +0000
@@ -572,7 +572,7 @@
572 dsc_maintainer_rfc822, dsc_standards_version, dsc_format,572 dsc_maintainer_rfc822, dsc_standards_version, dsc_format,
573 dsc_binaries, archive, copyright, build_conflicts,573 dsc_binaries, archive, copyright, build_conflicts,
574 build_conflicts_indep, dateuploaded=None,574 build_conflicts_indep, dateuploaded=None,
575 source_package_recipe_build=None):575 source_package_recipe_build=None, user_defined_fields=None):
576 """Create an uploads `SourcePackageRelease`.576 """Create an uploads `SourcePackageRelease`.
577577
578 Set this distroseries set to be the uploadeddistroseries.578 Set this distroseries set to be the uploadeddistroseries.
@@ -608,6 +608,8 @@
608 :param archive: IArchive to where the upload was targeted608 :param archive: IArchive to where the upload was targeted
609 :param dateuploaded: optional datetime, if omitted assumed nowUTC609 :param dateuploaded: optional datetime, if omitted assumed nowUTC
610 :param source_package_recipe_build: optional SourcePackageRecipeBuild610 :param source_package_recipe_build: optional SourcePackageRecipeBuild
611 :param user_defined_fields: optional sequence of key-value pairs with
612 user defined fields.
611 :return: the just creates `SourcePackageRelease`613 :return: the just creates `SourcePackageRelease`
612 """614 """
613615
614616
=== modified file 'lib/lp/registry/model/distroseries.py'
--- lib/lp/registry/model/distroseries.py 2010-08-10 21:54:41 +0000
+++ lib/lp/registry/model/distroseries.py 2010-08-12 19:10:59 +0000
@@ -1128,7 +1128,7 @@
1128 dsc_maintainer_rfc822, dsc_standards_version, dsc_format,1128 dsc_maintainer_rfc822, dsc_standards_version, dsc_format,
1129 dsc_binaries, archive, copyright, build_conflicts,1129 dsc_binaries, archive, copyright, build_conflicts,
1130 build_conflicts_indep, dateuploaded=DEFAULT,1130 build_conflicts_indep, dateuploaded=DEFAULT,
1131 source_package_recipe_build=None):1131 source_package_recipe_build=None, user_defined_fields=None):
1132 """See `IDistroSeries`."""1132 """See `IDistroSeries`."""
1133 return SourcePackageRelease(1133 return SourcePackageRelease(
1134 upload_distroseries=self, sourcepackagename=sourcepackagename,1134 upload_distroseries=self, sourcepackagename=sourcepackagename,
@@ -1144,7 +1144,8 @@
1144 dsc_format=dsc_format, dsc_binaries=dsc_binaries,1144 dsc_format=dsc_format, dsc_binaries=dsc_binaries,
1145 build_conflicts=build_conflicts,1145 build_conflicts=build_conflicts,
1146 build_conflicts_indep=build_conflicts_indep,1146 build_conflicts_indep=build_conflicts_indep,
1147 source_package_recipe_build=source_package_recipe_build)1147 source_package_recipe_build=source_package_recipe_build,
1148 user_defined_fields=user_defined_fields)
11481149
1149 def getComponentByName(self, name):1150 def getComponentByName(self, name):
1150 """See `IDistroSeries`."""1151 """See `IDistroSeries`."""
11511152
=== modified file 'lib/lp/soyuz/doc/binarypackagebuild.txt'
--- lib/lp/soyuz/doc/binarypackagebuild.txt 2010-08-10 21:54:41 +0000
+++ lib/lp/soyuz/doc/binarypackagebuild.txt 2010-08-12 19:10:59 +0000
@@ -310,20 +310,8 @@
310 >>> section = firefox_build.source_package_release.section.id310 >>> section = firefox_build.source_package_release.section.id
311 >>> from canonical.launchpad.interfaces import PackagePublishingPriority311 >>> from canonical.launchpad.interfaces import PackagePublishingPriority
312 >>> priority = PackagePublishingPriority.STANDARD312 >>> priority = PackagePublishingPriority.STANDARD
313 >>> shlibdeps = None
314 >>> depends = None
315 >>> recommends = None
316 >>> suggests = None
317 >>> conflicts = None
318 >>> replaces = None
319 >>> provides = None
320 >>> essential = False
321 >>> installedsize = 0313 >>> installedsize = 0
322 >>> architecturespecific = False314 >>> architecturespecific = False
323 >>> pre_depends = None
324 >>> enhances = None
325 >>> breaks = None
326 >>> debug_package = None
327315
328Invoke createBinaryPackageRelease with all required arguments.316Invoke createBinaryPackageRelease with all required arguments.
329317
@@ -331,11 +319,11 @@
331 >>> pmount_build = getUtility(IBinaryPackageBuildSet).getByBuildID(19)319 >>> pmount_build = getUtility(IBinaryPackageBuildSet).getByBuildID(19)
332320
333 >>> bin = pmount_build.createBinaryPackageRelease(321 >>> bin = pmount_build.createBinaryPackageRelease(
334 ... binarypackagename, version, summary, description,322 ... binarypackagename=binarypackagename, version=version,
335 ... binpackageformat, component, section, priority, shlibdeps,323 ... summary=summary, description=description,
336 ... depends, recommends, suggests, conflicts, replaces, provides,324 ... binpackageformat=binpackageformat, component=component,
337 ... pre_depends, enhances, breaks, essential, installedsize,325 ... section=section, priority=priority, installedsize=installedsize,
338 ... architecturespecific, debug_package)326 ... architecturespecific=architecturespecific)
339327
340 >>> from canonical.launchpad.interfaces import IBinaryPackageRelease328 >>> from canonical.launchpad.interfaces import IBinaryPackageRelease
341 >>> from canonical.launchpad.webapp.testing import verifyObject329 >>> from canonical.launchpad.webapp.testing import verifyObject
@@ -364,11 +352,12 @@
364 ... version = "%d" % i352 ... version = "%d" % i
365 ... binarypackagename = bpnameset.ensure("test-%d" % i).id353 ... binarypackagename = bpnameset.ensure("test-%d" % i).id
366 ... b = pmount_build.createBinaryPackageRelease(354 ... b = pmount_build.createBinaryPackageRelease(
367 ... binarypackagename, version, summary, description,355 ... binarypackagename=binarypackagename, version=version,
368 ... binpackageformat, component, section, priority, shlibdeps,356 ... summary=summary, description=description,
369 ... depends, recommends, suggests, conflicts, replaces, provides,357 ... binpackageformat=binpackageformat, component=component,
370 ... pre_depends, enhances, breaks, essential, installedsize,358 ... section=section, priority=priority,
371 ... architecturespecific, debug_package)359 ... installedsize=installedsize,
360 ... architecturespecific=architecturespecific)
372361
373362
374Check if the property is still working:363Check if the property is still working:
375364
=== modified file 'lib/lp/soyuz/interfaces/binarypackagebuild.py'
--- lib/lp/soyuz/interfaces/binarypackagebuild.py 2010-08-10 21:54:41 +0000
+++ lib/lp/soyuz/interfaces/binarypackagebuild.py 2010-08-12 19:10:59 +0000
@@ -125,10 +125,11 @@
125125
126 def createBinaryPackageRelease(126 def createBinaryPackageRelease(
127 binarypackagename, version, summary, description, binpackageformat,127 binarypackagename, version, summary, description, binpackageformat,
128 component, section, priority, shlibdeps, depends, recommends,128 component, section, priority, installedsize, architecturespecific,
129 suggests, conflicts, replaces, provides, pre_depends, enhances,129 shlibdeps=None, depends=None, recommends=None, suggests=None,
130 breaks, essential, installedsize, architecturespecific,130 conflicts=None, replaces=None, provides=None, pre_depends=None,
131 debug_package):131 enhances=None, breaks=None, essential=False, debug_package=None,
132 user_defined_fields=None):
132 """Create and return a `BinaryPackageRelease`.133 """Create and return a `BinaryPackageRelease`.
133134
134 The binarypackagerelease will be attached to this specific build.135 The binarypackagerelease will be attached to this specific build.
135136
=== modified file 'lib/lp/soyuz/interfaces/binarypackagerelease.py'
--- lib/lp/soyuz/interfaces/binarypackagerelease.py 2010-07-10 04:52:43 +0000
+++ lib/lp/soyuz/interfaces/binarypackagerelease.py 2010-08-12 19:10:59 +0000
@@ -18,7 +18,7 @@
18from lazr.enum import DBEnumeratedType, DBItem18from lazr.enum import DBEnumeratedType, DBItem
19from lazr.restful.declarations import exported, export_as_webservice_entry19from lazr.restful.declarations import exported, export_as_webservice_entry
20from lazr.restful.fields import Reference, ReferenceChoice20from lazr.restful.fields import Reference, ReferenceChoice
21from zope.schema import Bool, Date, Datetime, Int, Object, Text, TextLine21from zope.schema import Bool, Date, Datetime, Int, List, Object, Text, TextLine
22from zope.interface import Interface, Attribute22from zope.interface import Interface, Attribute
2323
24from canonical.launchpad import _24from canonical.launchpad import _
@@ -56,6 +56,8 @@
56 title=_("Debug package"), schema=Interface, required=False,56 title=_("Debug package"), schema=Interface, required=False,
57 description=_("The corresponding package containing debug symbols "57 description=_("The corresponding package containing debug symbols "
58 "for this binary."))58 "for this binary."))
59 user_defined_fields = List(
60 title=_("Sequence of user-defined fields as key-value pairs."))
5961
60 files = Attribute("Related list of IBinaryPackageFile entries")62 files = Attribute("Related list of IBinaryPackageFile entries")
6163
6264
=== modified file 'lib/lp/soyuz/interfaces/sourcepackagerelease.py'
--- lib/lp/soyuz/interfaces/sourcepackagerelease.py 2010-07-29 22:55:15 +0000
+++ lib/lp/soyuz/interfaces/sourcepackagerelease.py 2010-08-12 19:10:59 +0000
@@ -14,7 +14,7 @@
1414
1515
16from lazr.restful.fields import Reference16from lazr.restful.fields import Reference
17from zope.schema import TextLine17from zope.schema import List, TextLine
18from zope.interface import Interface, Attribute18from zope.interface import Interface, Attribute
1919
20from canonical.launchpad import _20from canonical.launchpad import _
@@ -96,8 +96,8 @@
96 "was first uploaded in Launchpad")96 "was first uploaded in Launchpad")
97 publishings = Attribute("MultipleJoin on SourcepackagePublishing")97 publishings = Attribute("MultipleJoin on SourcepackagePublishing")
9898
9999 user_defined_fields = List(
100100 title=_("Sequence of user-defined fields as key-value pairs."))
101 # read-only properties101 # read-only properties
102 name = Attribute('The sourcepackagename for this release, as text')102 name = Attribute('The sourcepackagename for this release, as text')
103 title = Attribute('The title of this sourcepackagerelease')103 title = Attribute('The title of this sourcepackagerelease')
104104
=== modified file 'lib/lp/soyuz/model/binarypackagebuild.py'
--- lib/lp/soyuz/model/binarypackagebuild.py 2010-08-10 21:54:41 +0000
+++ lib/lp/soyuz/model/binarypackagebuild.py 2010-08-12 19:10:59 +0000
@@ -448,10 +448,11 @@
448448
449 def createBinaryPackageRelease(449 def createBinaryPackageRelease(
450 self, binarypackagename, version, summary, description,450 self, binarypackagename, version, summary, description,
451 binpackageformat, component,section, priority, shlibdeps,451 binpackageformat, component, section, priority, installedsize,
452 depends, recommends, suggests, conflicts, replaces, provides,452 architecturespecific, shlibdeps=None, depends=None, recommends=None,
453 pre_depends, enhances, breaks, essential, installedsize,453 suggests=None, conflicts=None, replaces=None, provides=None,
454 architecturespecific, debug_package):454 pre_depends=None, enhances=None, breaks=None, essential=False,
455 debug_package=None, user_defined_fields=None):
455 """See IBuild."""456 """See IBuild."""
456 return BinaryPackageRelease(457 return BinaryPackageRelease(
457 build=self, binarypackagename=binarypackagename, version=version,458 build=self, binarypackagename=binarypackagename, version=version,
@@ -463,7 +464,8 @@
463 provides=provides, pre_depends=pre_depends, enhances=enhances,464 provides=provides, pre_depends=pre_depends, enhances=enhances,
464 breaks=breaks, essential=essential, installedsize=installedsize,465 breaks=breaks, essential=essential, installedsize=installedsize,
465 architecturespecific=architecturespecific,466 architecturespecific=architecturespecific,
466 debug_package=debug_package)467 debug_package=debug_package,
468 user_defined_fields=user_defined_fields)
467469
468 def estimateDuration(self):470 def estimateDuration(self):
469 """See `IBuildBase`."""471 """See `IBuildBase`."""
470472
=== modified file 'lib/lp/soyuz/model/binarypackagerelease.py'
--- lib/lp/soyuz/model/binarypackagerelease.py 2010-07-10 04:46:49 +0000
+++ lib/lp/soyuz/model/binarypackagerelease.py 2010-08-12 19:10:59 +0000
@@ -13,6 +13,8 @@
1313
14from zope.interface import implements14from zope.interface import implements
1515
16import simplejson
17
16from sqlobject import StringCol, ForeignKey, IntCol, SQLMultipleJoin, BoolCol18from sqlobject import StringCol, ForeignKey, IntCol, SQLMultipleJoin, BoolCol
17from storm.locals import Date, Int, Reference, Storm19from storm.locals import Date, Int, Reference, Storm
1820
@@ -68,6 +70,22 @@
68 files = SQLMultipleJoin('BinaryPackageFile',70 files = SQLMultipleJoin('BinaryPackageFile',
69 joinColumn='binarypackagerelease', orderBy="libraryfile")71 joinColumn='binarypackagerelease', orderBy="libraryfile")
7072
73 _user_defined_fields = StringCol(dbName='user_defined_fields')
74
75 def __init__(self, *args, **kwargs):
76 if 'user_defined_fields' in kwargs:
77 kwargs['_user_defined_fields'] = simplejson.dumps(
78 kwargs['user_defined_fields'])
79 del kwargs['user_defined_fields']
80 super(BinaryPackageRelease, self).__init__(*args, **kwargs)
81
82 @property
83 def user_defined_fields(self):
84 """See `IBinaryPackageRelease`."""
85 if self._user_defined_fields is None:
86 return []
87 return simplejson.loads(self._user_defined_fields)
88
71 @property89 @property
72 def title(self):90 def title(self):
73 """See `IBinaryPackageRelease`."""91 """See `IBinaryPackageRelease`."""
7492
=== modified file 'lib/lp/soyuz/model/sourcepackagerelease.py'
--- lib/lp/soyuz/model/sourcepackagerelease.py 2010-08-02 02:13:52 +0000
+++ lib/lp/soyuz/model/sourcepackagerelease.py 2010-08-12 19:10:59 +0000
@@ -15,6 +15,7 @@
15import pytz15import pytz
16from StringIO import StringIO16from StringIO import StringIO
17import re17import re
18import simplejson
1819
19from sqlobject import StringCol, ForeignKey, SQLMultipleJoin20from sqlobject import StringCol, ForeignKey, SQLMultipleJoin
20from storm.expr import Join21from storm.expr import Join
@@ -147,6 +148,22 @@
147 package_diffs = SQLMultipleJoin(148 package_diffs = SQLMultipleJoin(
148 'PackageDiff', joinColumn='to_source', orderBy="-date_requested")149 'PackageDiff', joinColumn='to_source', orderBy="-date_requested")
149150
151 _user_defined_fields = StringCol(dbName='user_defined_fields')
152
153 def __init__(self, *args, **kwargs):
154 if 'user_defined_fields' in kwargs:
155 kwargs['_user_defined_fields'] = simplejson.dumps(
156 kwargs['user_defined_fields'])
157 del kwargs['user_defined_fields']
158 super(SourcePackageRelease, self).__init__(*args, **kwargs)
159
160 @property
161 def user_defined_fields(self):
162 """See `IBinaryPackageRelease`."""
163 if self._user_defined_fields is None:
164 return []
165 return simplejson.loads(self._user_defined_fields)
166
150 @property167 @property
151 def builds(self):168 def builds(self):
152 """See `ISourcePackageRelease`."""169 """See `ISourcePackageRelease`."""
153170
=== added file 'lib/lp/soyuz/tests/test_binarypackagerelease.py'
--- lib/lp/soyuz/tests/test_binarypackagerelease.py 1970-01-01 00:00:00 +0000
+++ lib/lp/soyuz/tests/test_binarypackagerelease.py 2010-08-12 19:10:59 +0000
@@ -0,0 +1,51 @@
1# Copyright 2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).
3
4"""Test BinaryPackageRelease."""
5
6__metaclass__ = type
7
8from canonical.testing import LaunchpadFunctionalLayer
9
10from lp.soyuz.interfaces.binarypackagerelease import (
11 IBinaryPackageRelease, BinaryPackageFormat)
12from lp.soyuz.interfaces.publishing import PackagePublishingPriority
13
14from lp.testing import TestCaseWithFactory
15
16
17class TestBinaryPackageRelease(TestCaseWithFactory):
18 """Tests for BinaryPackageRelease."""
19
20 layer = LaunchpadFunctionalLayer
21
22 def test_provides(self):
23 build = self.factory.makeBinaryPackageBuild()
24 release = build.createBinaryPackageRelease(
25 binarypackagename=self.factory.makeBinaryPackageName(),
26 version="0.1", summary="My package",
27 description="My description",
28 binpackageformat=BinaryPackageFormat.DEB,
29 component=self.factory.makeComponent("main"),
30 section=self.factory.makeSection("net"),
31 priority=PackagePublishingPriority.OPTIONAL,
32 installedsize=0, architecturespecific=False)
33 self.assertProvides(release, IBinaryPackageRelease)
34
35 def test_user_defined_fields(self):
36 build = self.factory.makeBinaryPackageBuild()
37 release = build.createBinaryPackageRelease(
38 binarypackagename=self.factory.makeBinaryPackageName(),
39 version="0.1", summary="My package",
40 description="My description",
41 binpackageformat=BinaryPackageFormat.DEB,
42 component=self.factory.makeComponent("main"),
43 section=self.factory.makeSection("net"),
44 priority=PackagePublishingPriority.OPTIONAL,
45 installedsize=0, architecturespecific=False,
46 user_defined_fields=[
47 ("Python-Version", ">= 2.4"),
48 ("Other", "Bla")])
49 self.assertEquals([
50 ["Python-Version", ">= 2.4"],
51 ["Other", "Bla"]], release.user_defined_fields)
052
=== modified file 'lib/lp/soyuz/tests/test_sourcepackagerelease.py'
--- lib/lp/soyuz/tests/test_sourcepackagerelease.py 2010-07-29 23:09:34 +0000
+++ lib/lp/soyuz/tests/test_sourcepackagerelease.py 2010-08-12 19:10:59 +0000
@@ -30,3 +30,12 @@
30 spr = self.factory.makeSourcePackageRelease(30 spr = self.factory.makeSourcePackageRelease(
31 source_package_recipe_build=recipe_build)31 source_package_recipe_build=recipe_build)
32 self.assertEqual(recipe_build.requester, spr.uploader)32 self.assertEqual(recipe_build.requester, spr.uploader)
33
34 def test_user_defined_fields(self):
35 release = self.factory.makeSourcePackageRelease(
36 user_defined_fields=[
37 ("Python-Version", ">= 2.4"),
38 ("Other", "Bla")])
39 self.assertEquals([
40 ["Python-Version", ">= 2.4"],
41 ["Other", "Bla"]], release.user_defined_fields)
3342
=== modified file 'lib/lp/testing/factory.py'
--- lib/lp/testing/factory.py 2010-08-06 10:48:49 +0000
+++ lib/lp/testing/factory.py 2010-08-12 19:10:59 +0000
@@ -2289,7 +2289,8 @@
2289 dsc_format='1.0', dsc_binaries='foo-bin',2289 dsc_format='1.0', dsc_binaries='foo-bin',
2290 date_uploaded=UTC_NOW,2290 date_uploaded=UTC_NOW,
2291 source_package_recipe_build=None,2291 source_package_recipe_build=None,
2292 dscsigningkey=None):2292 dscsigningkey=None,
2293 user_defined_fields=None):
2293 """Make a `SourcePackageRelease`."""2294 """Make a `SourcePackageRelease`."""
2294 if distroseries is None:2295 if distroseries is None:
2295 if source_package_recipe_build is not None:2296 if source_package_recipe_build is not None:
@@ -2355,7 +2356,8 @@
2355 dsc_binaries=dsc_binaries,2356 dsc_binaries=dsc_binaries,
2356 archive=archive,2357 archive=archive,
2357 dateuploaded=date_uploaded,2358 dateuploaded=date_uploaded,
2358 source_package_recipe_build=source_package_recipe_build)2359 source_package_recipe_build=source_package_recipe_build,
2360 user_defined_fields=user_defined_fields)
23592361
2360 def makeSourcePackageReleaseFile(self, sourcepackagerelease=None,2362 def makeSourcePackageReleaseFile(self, sourcepackagerelease=None,
2361 library_file=None, filetype=None):2363 library_file=None, filetype=None):

Subscribers

People subscribed via source and target branches

to status/vote changes: