Merge lp:~al-maisan/launchpad/psds-model-changes-399186 into lp:launchpad/db-devel
- psds-model-changes-399186
- Merge into db-devel
Status: | Merged |
---|---|
Merged at revision: | not available |
Proposed branch: | lp:~al-maisan/launchpad/psds-model-changes-399186 |
Merge into: | lp:launchpad/db-devel |
Diff against target: |
668 lines 10 files modified
database/schema/comments.sql (+10/-1) database/schema/patch-2207-06-0.sql (+122/-0) database/schema/security.cfg (+5/-0) database/schema/trusted.sql (+15/-0) lib/lp/soyuz/configure.zcml (+8/-0) lib/lp/soyuz/interfaces/packageset.py (+40/-5) lib/lp/soyuz/interfaces/packagesetgroup.py (+41/-0) lib/lp/soyuz/model/packageset.py (+53/-5) lib/lp/soyuz/model/packagesetgroup.py (+30/-0) lib/lp/soyuz/tests/test_packageset.py (+121/-0) |
To merge this branch: | bzr merge lp:~al-maisan/launchpad/psds-model-changes-399186 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Brad Crittenden (community) | code | Approve | |
Review via email: mp+14038@code.launchpad.net |
Commit message
Description of the change
Muharem Hrnjadovic (al-maisan) wrote : | # |
Brad Crittenden (bac) wrote : | # |
Hi Muharem,
Thanks for the branch. It looks good except for the following small items:
* Line 46 - End of line comments are discouraged by our coding standards. Please move to the previous line.
* I think "The person who owns the package set at hand." would read better for most users as "The person who owns this package set."
* Lines 91,110 - Capitalize Ubuntu.
* Line 383 - typo 'dupliacte'
Muharem Hrnjadovic (al-maisan) wrote : | # |
Brad Crittenden wrote:
> Review: Approve code
> Hi Muharem,
>
> Thanks for the branch. It looks good except for the following small items:
>
> * Line 46 - End of line comments are discouraged by our coding standards. Please move to the previous line.
>
> * I think "The person who owns the package set at hand." would read better for most users as "The person who owns this package set."
>
> * Lines 91,110 - Capitalize Ubuntu.
>
> * Line 383 - typo 'dupliacte'
Hello Brad,
thank you very much for the review! I have revised the branch to
accommodate your suggestions.
Best regards
--
Muharem Hrnjadovic <email address hidden>
Public key id : B2BBFCFC
Key fingerprint : A5A3 CC67 2B87 D641 103F 5602 219F 6B60 B2BB FCFC
1 | === modified file 'lib/lp/soyuz/interfaces/packageset.py' | |||
2 | --- lib/lp/soyuz/interfaces/packageset.py 2009-10-27 15:42:04 +0000 | |||
3 | +++ lib/lp/soyuz/interfaces/packageset.py 2009-10-27 22:26:47 +0000 | |||
4 | @@ -35,13 +35,15 @@ | |||
5 | 35 | 35 | ||
6 | 36 | class NoSuchPackageSet(NameLookupFailed): | 36 | class NoSuchPackageSet(NameLookupFailed): |
7 | 37 | """Raised when we try to look up an PackageSet that doesn't exist.""" | 37 | """Raised when we try to look up an PackageSet that doesn't exist.""" |
9 | 38 | webservice_error(400) #Bad request. | 38 | # Bad request. |
10 | 39 | webservice_error(400) | ||
11 | 39 | _message_prefix = "No such packageset" | 40 | _message_prefix = "No such packageset" |
12 | 40 | 41 | ||
13 | 41 | 42 | ||
14 | 42 | class DuplicatePackagesetName(Exception): | 43 | class DuplicatePackagesetName(Exception): |
15 | 43 | """Raised for packagesets with the same name and distroseries.""" | 44 | """Raised for packagesets with the same name and distroseries.""" |
17 | 44 | webservice_error(400) # Bad request. | 45 | # Bad request. |
18 | 46 | webservice_error(400) | ||
19 | 45 | 47 | ||
20 | 46 | 48 | ||
21 | 47 | class IPackagesetViewOnly(IHasOwner): | 49 | class IPackagesetViewOnly(IHasOwner): |
22 | @@ -56,7 +58,7 @@ | |||
23 | 56 | 58 | ||
24 | 57 | owner = exported(Reference( | 59 | owner = exported(Reference( |
25 | 58 | IPerson, title=_("Person"), required=True, readonly=True, | 60 | IPerson, title=_("Person"), required=True, readonly=True, |
27 | 59 | description=_("The person who owns the package set at hand."))) | 61 | description=_("The person who owns this package set."))) |
28 | 60 | 62 | ||
29 | 61 | name = exported(TextLine( | 63 | name = exported(TextLine( |
30 | 62 | title=_('Valid package set name'), | 64 | title=_('Valid package set name'), |
31 | @@ -336,7 +338,7 @@ | |||
32 | 336 | title=_('Package set description'), required=True), | 338 | title=_('Package set description'), required=True), |
33 | 337 | owner=Reference( | 339 | owner=Reference( |
34 | 338 | IPerson, title=_("Person"), required=True, readonly=True, | 340 | IPerson, title=_("Person"), required=True, readonly=True, |
36 | 339 | description=_("The person who owns the package set at hand.")), | 341 | description=_("The person who owns this package set.")), |
37 | 340 | distroseries=Reference( | 342 | distroseries=Reference( |
38 | 341 | IDistroSeries, title=_("Distroseries"), required=False, | 343 | IDistroSeries, title=_("Distroseries"), required=False, |
39 | 342 | readonly=True, description=_( | 344 | readonly=True, description=_( |
40 | @@ -350,7 +352,7 @@ | |||
41 | 350 | :param description: the description for the package set to be created. | 352 | :param description: the description for the package set to be created. |
42 | 351 | :param owner: the owner of the package set to be created. | 353 | :param owner: the owner of the package set to be created. |
43 | 352 | :param distroseries: the distroseries to which the new packageset | 354 | :param distroseries: the distroseries to which the new packageset |
45 | 353 | is related. Defaults to the current ubuntu series. | 355 | is related. Defaults to the current Ubuntu series. |
46 | 354 | :param related_set: the newly created package set is to be related to | 356 | :param related_set: the newly created package set is to be related to |
47 | 355 | `related_set` (by being placed in the same package group). | 357 | `related_set` (by being placed in the same package group). |
48 | 356 | 358 | ||
49 | @@ -368,7 +370,7 @@ | |||
50 | 368 | 370 | ||
51 | 369 | :param name: the name of the package set sought. | 371 | :param name: the name of the package set sought. |
52 | 370 | :param distroseries: the distroseries to which the new packageset | 372 | :param distroseries: the distroseries to which the new packageset |
54 | 371 | is related. Defaults to the current ubuntu series. | 373 | is related. Defaults to the current Ubuntu series. |
55 | 372 | 374 | ||
56 | 373 | :return: An `IPackageset` instance or None. | 375 | :return: An `IPackageset` instance or None. |
57 | 374 | """ | 376 | """ |
58 | 375 | 377 | ||
59 | === modified file 'lib/lp/soyuz/tests/test_packageset.py' | |||
60 | --- lib/lp/soyuz/tests/test_packageset.py 2009-10-27 15:51:28 +0000 | |||
61 | +++ lib/lp/soyuz/tests/test_packageset.py 2009-10-27 22:21:31 +0000 | |||
62 | @@ -70,7 +70,7 @@ | |||
63 | 70 | 70 | ||
64 | 71 | self.failUnlessRaises( | 71 | self.failUnlessRaises( |
65 | 72 | DuplicatePackagesetName, self.packageset_set.new, | 72 | DuplicatePackagesetName, self.packageset_set.new, |
67 | 73 | u'kernel', u'A packageset with a dupliacte name', self.person1, | 73 | u'kernel', u'A packageset with a duplicate name', self.person1, |
68 | 74 | distroseries=self.distroseries_experimental) | 74 | distroseries=self.distroseries_experimental) |
69 | 75 | 75 | ||
70 | 76 | def test_new_duplicate_name_for_different_distroseries(self): | 76 | def test_new_duplicate_name_for_different_distroseries(self): |
Preview Diff
1 | === modified file 'database/schema/comments.sql' | |||
2 | --- database/schema/comments.sql 2009-10-07 12:54:03 +0000 | |||
3 | +++ database/schema/comments.sql 2009-10-27 23:43:13 +0000 | |||
4 | @@ -2239,11 +2239,20 @@ | |||
5 | 2239 | 2239 | ||
6 | 2240 | -- Packageset | 2240 | -- Packageset |
7 | 2241 | 2241 | ||
9 | 2242 | COMMENT ON TABLE Packageset IS 'Package sets facilitate the grouping of packages for purposes like the control of upload permissions, et.'; | 2242 | COMMENT ON TABLE Packageset IS 'Package sets facilitate the grouping of packages (in a given distro series) for purposes like the control of upload permissions, etc.'; |
10 | 2243 | COMMENT ON COLUMN Packageset.date_created IS 'Date and time of creation.'; | 2243 | COMMENT ON COLUMN Packageset.date_created IS 'Date and time of creation.'; |
11 | 2244 | COMMENT ON COLUMN Packageset.owner IS 'The Person or team who owns the package set'; | 2244 | COMMENT ON COLUMN Packageset.owner IS 'The Person or team who owns the package set'; |
12 | 2245 | COMMENT ON COLUMN Packageset.name IS 'The name for the package set on hand.'; | 2245 | COMMENT ON COLUMN Packageset.name IS 'The name for the package set on hand.'; |
13 | 2246 | COMMENT ON COLUMN Packageset.description IS 'The description for the package set on hand.'; | 2246 | COMMENT ON COLUMN Packageset.description IS 'The description for the package set on hand.'; |
14 | 2247 | COMMENT ON COLUMN Packageset.packagesetgroup IS 'The group this package set is affiliated with.'; | ||
15 | 2248 | COMMENT ON COLUMN Packageset.distroseries IS 'The distro series this package set belongs to.'; | ||
16 | 2249 | |||
17 | 2250 | -- PackagesetGroup | ||
18 | 2251 | |||
19 | 2252 | COMMENT ON TABLE PackagesetGroup IS 'Package set groups keep track of equivalent package sets across distro series boundaries.'; | ||
20 | 2253 | COMMENT ON COLUMN Packageset.date_created IS 'Date and time of creation.'; | ||
21 | 2254 | COMMENT ON COLUMN Packageset.owner IS 'The Person or team who owns the package | ||
22 | 2255 | set group.'; | ||
23 | 2247 | 2256 | ||
24 | 2248 | -- PackagesetSources | 2257 | -- PackagesetSources |
25 | 2249 | 2258 | ||
26 | 2250 | 2259 | ||
27 | === added file 'database/schema/patch-2207-06-0.sql' | |||
28 | --- database/schema/patch-2207-06-0.sql 1970-01-01 00:00:00 +0000 | |||
29 | +++ database/schema/patch-2207-06-0.sql 2009-10-27 23:43:13 +0000 | |||
30 | @@ -0,0 +1,122 @@ | |||
31 | 1 | -- Copyright 2009 Canonical Ltd. This software is licensed under the | ||
32 | 2 | -- GNU Affero General Public License version 3 (see the file LICENSE). | ||
33 | 3 | |||
34 | 4 | SET client_min_messages=ERROR; | ||
35 | 5 | |||
36 | 6 | -- ** PART 1 ** Create the 'packagesetgroup' table and the | ||
37 | 7 | -- 'packageset.packagesetgroup' foreign key, | ||
38 | 8 | -- populate the 'packagesetgroup' table | ||
39 | 9 | |||
40 | 10 | -- This table keeps track of package sets that are equivalent across | ||
41 | 11 | -- distro series boundaries. | ||
42 | 12 | CREATE SEQUENCE packagesetgroup_id_seq | ||
43 | 13 | START WITH 1 | ||
44 | 14 | INCREMENT BY 1 | ||
45 | 15 | NO MAXVALUE | ||
46 | 16 | NO MINVALUE | ||
47 | 17 | CACHE 1; | ||
48 | 18 | CREATE TABLE packagesetgroup ( | ||
49 | 19 | id integer NOT NULL DEFAULT nextval('packagesetgroup_id_seq'), | ||
50 | 20 | date_created timestamp without time zone DEFAULT timezone('UTC'::text, now()) NOT NULL, | ||
51 | 21 | owner integer NOT NULL, | ||
52 | 22 | -- Please note: the 'name' column is only here to ease the data migration | ||
53 | 23 | -- and will be dropped at the end of this patch. | ||
54 | 24 | name text NOT NULL | ||
55 | 25 | ); | ||
56 | 26 | ALTER SEQUENCE packagesetgroup_id_seq OWNED BY packagesetgroup.id; | ||
57 | 27 | ALTER TABLE ONLY packagesetgroup | ||
58 | 28 | ADD CONSTRAINT packagesetgroup_pkey PRIMARY KEY (id); | ||
59 | 29 | ALTER TABLE ONLY packagesetgroup | ||
60 | 30 | ADD CONSTRAINT packagesetgroup__owner__fk | ||
61 | 31 | FOREIGN KEY (owner) REFERENCES person(id); | ||
62 | 32 | |||
63 | 33 | -- Package sets and their clones belong to the same package set group. | ||
64 | 34 | ALTER TABLE ONLY packageset ADD COLUMN packagesetgroup integer; | ||
65 | 35 | ALTER TABLE ONLY packageset | ||
66 | 36 | ADD CONSTRAINT packageset__packagesetgroup__fk | ||
67 | 37 | FOREIGN KEY (packagesetgroup) REFERENCES packagesetgroup(id); | ||
68 | 38 | |||
69 | 39 | -- Create a group for each of the original (karmic koala) package sets. | ||
70 | 40 | INSERT INTO packagesetgroup(owner, name) | ||
71 | 41 | SELECT packageset.owner, packageset.name | ||
72 | 42 | FROM packageset WHERE NOT packageset.name LIKE('lucid-%'); | ||
73 | 43 | |||
74 | 44 | |||
75 | 45 | -- ** PART 2 ** Associate the karmic koala package sets and their lucid lynx | ||
76 | 46 | -- clones with the appropriate package set groups | ||
77 | 47 | |||
78 | 48 | -- Update the karmic koala package sets so they reference their groups. | ||
79 | 49 | UPDATE packageset SET packagesetgroup = packagesetgroup.id | ||
80 | 50 | FROM packagesetgroup WHERE packageset.name = packagesetgroup.name; | ||
81 | 51 | |||
82 | 52 | -- Update the lucid lynx package set *clones* so they reference their groups | ||
83 | 53 | -- as well. | ||
84 | 54 | UPDATE packageset SET packagesetgroup = packagesetgroup.id | ||
85 | 55 | FROM packagesetgroup WHERE packageset.name = 'lucid-' || packagesetgroup.name; | ||
86 | 56 | |||
87 | 57 | -- ** PART 3 ** Add the 'packageset.distroseries' foreign key and | ||
88 | 58 | -- initialise it for the existing package sets. | ||
89 | 59 | |||
90 | 60 | -- A package set lives in a distro series context. | ||
91 | 61 | ALTER TABLE ONLY packageset ADD COLUMN distroseries integer; | ||
92 | 62 | |||
93 | 63 | -- Define the foreign key constraint. | ||
94 | 64 | ALTER TABLE ONLY packageset | ||
95 | 65 | ADD CONSTRAINT packageset__distroseries__fk | ||
96 | 66 | FOREIGN KEY (distroseries) REFERENCES distroseries(id); | ||
97 | 67 | |||
98 | 68 | -- First migrate the original package sets created for the karmic koala. | ||
99 | 69 | UPDATE packageset SET distroseries = distroseries.id FROM distroseries | ||
100 | 70 | WHERE distroseries.name = 'karmic' AND NOT packageset.name LIKE('lucid-%'); | ||
101 | 71 | |||
102 | 72 | -- Migrate the lucid lynx package sets next. | ||
103 | 73 | UPDATE packageset SET distroseries = distroseries.id FROM distroseries | ||
104 | 74 | WHERE distroseries.name = 'lucid' AND packageset.name LIKE('lucid-%'); | ||
105 | 75 | |||
106 | 76 | -- Make the 'distroseries' foreign key mandatory. | ||
107 | 77 | ALTER TABLE ONLY packageset ALTER COLUMN distroseries SET NOT NULL; | ||
108 | 78 | |||
109 | 79 | -- The package set name is now only unique in conjunction with a distro series. | ||
110 | 80 | ALTER TABLE ONLY packageset | ||
111 | 81 | DROP CONSTRAINT packageset_name_key; | ||
112 | 82 | ALTER TABLE ONLY packageset | ||
113 | 83 | ADD CONSTRAINT packageset__name__distroseries__key UNIQUE (name, distroseries); | ||
114 | 84 | |||
115 | 85 | -- ** PART 4 ** Strip off the 'lucid-' prefix of the lucid lynx | ||
116 | 86 | -- package set names | ||
117 | 87 | UPDATE packageset SET name = substring(name FROM length('lucid-')+1) | ||
118 | 88 | WHERE name LIKE('lucid-%'); | ||
119 | 89 | |||
120 | 90 | -- ** PART 5 ** Create package set groups for package sets that were added in | ||
121 | 91 | -- lucid lynx but do not exist in the karmic koala, | ||
122 | 92 | -- associate these package sets with their newly created groups | ||
123 | 93 | INSERT INTO packagesetgroup(owner, name) | ||
124 | 94 | SELECT packageset.owner, packageset.name | ||
125 | 95 | FROM packageset, distroseries WHERE | ||
126 | 96 | packageset.packagesetgroup IS NULL | ||
127 | 97 | AND packageset.distroseries = distroseries.id | ||
128 | 98 | AND distroseries.name = 'lucid'; | ||
129 | 99 | |||
130 | 100 | UPDATE packageset SET packagesetgroup = packagesetgroup.id | ||
131 | 101 | FROM packagesetgroup, distroseries | ||
132 | 102 | WHERE | ||
133 | 103 | packageset.packagesetgroup IS NULL | ||
134 | 104 | AND packageset.distroseries = distroseries.id | ||
135 | 105 | AND distroseries.name = 'lucid' | ||
136 | 106 | AND packageset.name = packagesetgroup.name; | ||
137 | 107 | |||
138 | 108 | -- ** PART 6 ** Make the 'packageset.packagesetgroup' foreign key mandatory | ||
139 | 109 | ALTER TABLE ONLY packageset ALTER COLUMN packagesetgroup SET NOT NULL; | ||
140 | 110 | |||
141 | 111 | -- ** PART 7 ** Drop the 'packagesetgroup.name' column that was only added | ||
142 | 112 | -- for data migration purposes. | ||
143 | 113 | ALTER TABLE ONLY packagesetgroup DROP COLUMN name; | ||
144 | 114 | |||
145 | 115 | -- Define indices on the newly added foreign keys. | ||
146 | 116 | CREATE INDEX packageset__packagesetgroup__idx | ||
147 | 117 | ON packageset(packagesetgroup); | ||
148 | 118 | CREATE INDEX packageset__distroseries__idx | ||
149 | 119 | ON packageset(distroseries); | ||
150 | 120 | CREATE INDEX packagesetgroup__owner__idx ON PackageSetGroup(owner); | ||
151 | 121 | |||
152 | 122 | INSERT INTO LaunchpadDatabaseRevision VALUES (2207, 06, 0); | ||
153 | 0 | 123 | ||
154 | === modified file 'database/schema/security.cfg' | |||
155 | --- database/schema/security.cfg 2009-10-15 23:26:39 +0000 | |||
156 | +++ database/schema/security.cfg 2009-10-27 23:43:13 +0000 | |||
157 | @@ -226,6 +226,7 @@ | |||
158 | 226 | public.packagediff = SELECT, INSERT, UPDATE, DELETE | 226 | public.packagediff = SELECT, INSERT, UPDATE, DELETE |
159 | 227 | public.packagediff = SELECT, INSERT, UPDATE, DELETE | 227 | public.packagediff = SELECT, INSERT, UPDATE, DELETE |
160 | 228 | public.packageset = SELECT, INSERT, UPDATE, DELETE | 228 | public.packageset = SELECT, INSERT, UPDATE, DELETE |
161 | 229 | public.packagesetgroup = SELECT, INSERT, UPDATE, DELETE | ||
162 | 229 | public.packagesetsources = SELECT, INSERT, UPDATE, DELETE | 230 | public.packagesetsources = SELECT, INSERT, UPDATE, DELETE |
163 | 230 | public.packagesetinclusion = SELECT, INSERT, UPDATE, DELETE | 231 | public.packagesetinclusion = SELECT, INSERT, UPDATE, DELETE |
164 | 231 | public.flatpackagesetinclusion = SELECT, INSERT, UPDATE, DELETE | 232 | public.flatpackagesetinclusion = SELECT, INSERT, UPDATE, DELETE |
165 | @@ -777,6 +778,7 @@ | |||
166 | 777 | public.packagecopyrequest = SELECT, INSERT, UPDATE | 778 | public.packagecopyrequest = SELECT, INSERT, UPDATE |
167 | 778 | public.packagediff = SELECT, INSERT, UPDATE | 779 | public.packagediff = SELECT, INSERT, UPDATE |
168 | 779 | public.packageset = SELECT | 780 | public.packageset = SELECT |
169 | 781 | public.packagesetgroup = SELECT | ||
170 | 780 | public.packagesetsources = SELECT, INSERT, UPDATE, DELETE | 782 | public.packagesetsources = SELECT, INSERT, UPDATE, DELETE |
171 | 781 | public.packagesetinclusion = SELECT, INSERT, UPDATE, DELETE | 783 | public.packagesetinclusion = SELECT, INSERT, UPDATE, DELETE |
172 | 782 | public.flatpackagesetinclusion = SELECT, INSERT, UPDATE, DELETE | 784 | public.flatpackagesetinclusion = SELECT, INSERT, UPDATE, DELETE |
173 | @@ -854,6 +856,7 @@ | |||
174 | 854 | public.teammembership = SELECT | 856 | public.teammembership = SELECT |
175 | 855 | public.gpgkey = SELECT | 857 | public.gpgkey = SELECT |
176 | 856 | public.packageset = SELECT | 858 | public.packageset = SELECT |
177 | 859 | public.packagesetgroup = SELECT | ||
178 | 857 | public.packagesetsources = SELECT | 860 | public.packagesetsources = SELECT |
179 | 858 | public.packagesetinclusion = SELECT | 861 | public.packagesetinclusion = SELECT |
180 | 859 | public.flatpackagesetinclusion = SELECT | 862 | public.flatpackagesetinclusion = SELECT |
181 | @@ -1054,6 +1057,7 @@ | |||
182 | 1054 | public.archive = SELECT, INSERT, UPDATE | 1057 | public.archive = SELECT, INSERT, UPDATE |
183 | 1055 | public.archivearch = SELECT, INSERT, UPDATE | 1058 | public.archivearch = SELECT, INSERT, UPDATE |
184 | 1056 | public.packageset = SELECT | 1059 | public.packageset = SELECT |
185 | 1060 | public.packagesetgroup = SELECT | ||
186 | 1057 | public.packagesetsources = SELECT | 1061 | public.packagesetsources = SELECT |
187 | 1058 | public.packagesetinclusion = SELECT | 1062 | public.packagesetinclusion = SELECT |
188 | 1059 | public.flatpackagesetinclusion = SELECT | 1063 | public.flatpackagesetinclusion = SELECT |
189 | @@ -1242,6 +1246,7 @@ | |||
190 | 1242 | public.personlanguage = SELECT | 1246 | public.personlanguage = SELECT |
191 | 1243 | public.structuralsubscription = SELECT | 1247 | public.structuralsubscription = SELECT |
192 | 1244 | public.packageset = SELECT | 1248 | public.packageset = SELECT |
193 | 1249 | public.packagesetgroup = SELECT | ||
194 | 1245 | public.packagesetsources = SELECT | 1250 | public.packagesetsources = SELECT |
195 | 1246 | public.packagesetinclusion = SELECT | 1251 | public.packagesetinclusion = SELECT |
196 | 1247 | public.flatpackagesetinclusion = SELECT | 1252 | public.flatpackagesetinclusion = SELECT |
197 | 1248 | 1253 | ||
198 | === modified file 'database/schema/trusted.sql' | |||
199 | --- database/schema/trusted.sql 2009-08-19 15:35:13 +0000 | |||
200 | +++ database/schema/trusted.sql 2009-10-27 23:43:13 +0000 | |||
201 | @@ -1029,7 +1029,22 @@ | |||
202 | 1029 | DECLARE | 1029 | DECLARE |
203 | 1030 | parent_name text; | 1030 | parent_name text; |
204 | 1031 | child_name text; | 1031 | child_name text; |
205 | 1032 | parent_distroseries text; | ||
206 | 1033 | child_distroseries text; | ||
207 | 1032 | BEGIN | 1034 | BEGIN |
208 | 1035 | -- Make sure that the package sets being associated here belong | ||
209 | 1036 | -- to the same distro series. | ||
210 | 1037 | IF (SELECT parent.distroseries != child.distroseries | ||
211 | 1038 | FROM packageset parent, packageset child | ||
212 | 1039 | WHERE parent.id = NEW.parent AND child.id = NEW.child) | ||
213 | 1040 | THEN | ||
214 | 1041 | SELECT name INTO parent_name FROM packageset WHERE id = NEW.parent; | ||
215 | 1042 | SELECT name INTO child_name FROM packageset WHERE id = NEW.child; | ||
216 | 1043 | SELECT ds.name INTO parent_distroseries FROM packageset ps, distroseries ds WHERE ps.id = NEW.parent AND ps.distroseries = ds.id; | ||
217 | 1044 | SELECT ds.name INTO child_distroseries FROM packageset ps, distroseries ds WHERE ps.id = NEW.child AND ps.distroseries = ds.id; | ||
218 | 1045 | RAISE EXCEPTION 'Package sets % and % belong to different distro series (to % and % respectively) and thus cannot be associated.', child_name, parent_name, child_distroseries, parent_distroseries; | ||
219 | 1046 | END IF; | ||
220 | 1047 | |||
221 | 1033 | IF EXISTS( | 1048 | IF EXISTS( |
222 | 1034 | SELECT * FROM flatpackagesetinclusion | 1049 | SELECT * FROM flatpackagesetinclusion |
223 | 1035 | WHERE parent = NEW.child AND child = NEW.parent LIMIT 1) | 1050 | WHERE parent = NEW.child AND child = NEW.parent LIMIT 1) |
224 | 1036 | 1051 | ||
225 | === modified file 'lib/lp/soyuz/configure.zcml' | |||
226 | --- lib/lp/soyuz/configure.zcml 2009-10-05 13:31:09 +0000 | |||
227 | +++ lib/lp/soyuz/configure.zcml 2009-10-27 23:43:13 +0000 | |||
228 | @@ -856,4 +856,12 @@ | |||
229 | 856 | new"/> | 856 | new"/> |
230 | 857 | </securedutility> | 857 | </securedutility> |
231 | 858 | 858 | ||
232 | 859 | <!-- PackagesetGroup --> | ||
233 | 860 | <class | ||
234 | 861 | class="lp.soyuz.model.packagesetgroup.PackagesetGroup"> | ||
235 | 862 | <allow | ||
236 | 863 | interface="lp.soyuz.interfaces.packagesetgroup.IPackagesetGroup"/> | ||
237 | 864 | </class> | ||
238 | 865 | |||
239 | 866 | |||
240 | 859 | </configure> | 867 | </configure> |
241 | 860 | 868 | ||
242 | === modified file 'lib/lp/soyuz/interfaces/packageset.py' | |||
243 | --- lib/lp/soyuz/interfaces/packageset.py 2009-07-25 16:33:39 +0000 | |||
244 | +++ lib/lp/soyuz/interfaces/packageset.py 2009-10-27 23:43:13 +0000 | |||
245 | @@ -8,6 +8,7 @@ | |||
246 | 8 | __metaclass__ = type | 8 | __metaclass__ = type |
247 | 9 | 9 | ||
248 | 10 | __all__ = [ | 10 | __all__ = [ |
249 | 11 | 'DuplicatePackagesetName', | ||
250 | 11 | 'IPackageset', | 12 | 'IPackageset', |
251 | 12 | 'IPackagesetSet', | 13 | 'IPackagesetSet', |
252 | 13 | 'NoSuchPackageSet', | 14 | 'NoSuchPackageSet', |
253 | @@ -26,16 +27,25 @@ | |||
254 | 26 | operation_parameters, operation_returns_collection_of, | 27 | operation_parameters, operation_returns_collection_of, |
255 | 27 | operation_returns_entry, webservice_error) | 28 | operation_returns_entry, webservice_error) |
256 | 28 | from lazr.restful.fields import Reference | 29 | from lazr.restful.fields import Reference |
257 | 30 | from lp.registry.interfaces.distroseries import IDistroSeries | ||
258 | 29 | from lp.registry.interfaces.person import IPerson | 31 | from lp.registry.interfaces.person import IPerson |
259 | 30 | from lp.registry.interfaces.role import IHasOwner | 32 | from lp.registry.interfaces.role import IHasOwner |
260 | 33 | from lp.soyuz.interfaces.packagesetgroup import IPackagesetGroup | ||
261 | 31 | 34 | ||
262 | 32 | 35 | ||
263 | 33 | class NoSuchPackageSet(NameLookupFailed): | 36 | class NoSuchPackageSet(NameLookupFailed): |
264 | 34 | """Raised when we try to look up an PackageSet that doesn't exist.""" | 37 | """Raised when we try to look up an PackageSet that doesn't exist.""" |
266 | 35 | webservice_error(400) #Bad request. | 38 | # Bad request. |
267 | 39 | webservice_error(400) | ||
268 | 36 | _message_prefix = "No such packageset" | 40 | _message_prefix = "No such packageset" |
269 | 37 | 41 | ||
270 | 38 | 42 | ||
271 | 43 | class DuplicatePackagesetName(Exception): | ||
272 | 44 | """Raised for packagesets with the same name and distroseries.""" | ||
273 | 45 | # Bad request. | ||
274 | 46 | webservice_error(400) | ||
275 | 47 | |||
276 | 48 | |||
277 | 39 | class IPackagesetViewOnly(IHasOwner): | 49 | class IPackagesetViewOnly(IHasOwner): |
278 | 40 | """A read-only interface for package sets.""" | 50 | """A read-only interface for package sets.""" |
279 | 41 | export_as_webservice_entry() | 51 | export_as_webservice_entry() |
280 | @@ -48,7 +58,7 @@ | |||
281 | 48 | 58 | ||
282 | 49 | owner = exported(Reference( | 59 | owner = exported(Reference( |
283 | 50 | IPerson, title=_("Person"), required=True, readonly=True, | 60 | IPerson, title=_("Person"), required=True, readonly=True, |
285 | 51 | description=_("The person who owns the package set at hand."))) | 61 | description=_("The person who owns this package set."))) |
286 | 52 | 62 | ||
287 | 53 | name = exported(TextLine( | 63 | name = exported(TextLine( |
288 | 54 | title=_('Valid package set name'), | 64 | title=_('Valid package set name'), |
289 | @@ -58,6 +68,18 @@ | |||
290 | 58 | title=_("Description"), required=True, readonly=True, | 68 | title=_("Description"), required=True, readonly=True, |
291 | 59 | description=_("The description for the package set at hand."))) | 69 | description=_("The description for the package set at hand."))) |
292 | 60 | 70 | ||
293 | 71 | distroseries = Reference( | ||
294 | 72 | IDistroSeries, title=_("Distribution series"), required=True, | ||
295 | 73 | readonly=True, | ||
296 | 74 | description=_( | ||
297 | 75 | "The distroseries to which this package set is related.")) | ||
298 | 76 | |||
299 | 77 | packagesetgroup = Reference( | ||
300 | 78 | IPackagesetGroup, title=_('Packageset group'), required=True, | ||
301 | 79 | readonly=True, | ||
302 | 80 | description=_( | ||
303 | 81 | 'Used internally to link packagesets across distroseries')) | ||
304 | 82 | |||
305 | 61 | def sourcesIncluded(direct_inclusion=False): | 83 | def sourcesIncluded(direct_inclusion=False): |
306 | 62 | """Get all source names associated with this package set. | 84 | """Get all source names associated with this package set. |
307 | 63 | 85 | ||
308 | @@ -316,15 +338,26 @@ | |||
309 | 316 | title=_('Package set description'), required=True), | 338 | title=_('Package set description'), required=True), |
310 | 317 | owner=Reference( | 339 | owner=Reference( |
311 | 318 | IPerson, title=_("Person"), required=True, readonly=True, | 340 | IPerson, title=_("Person"), required=True, readonly=True, |
313 | 319 | description=_("The person who owns the package set at hand."))) | 341 | description=_("The person who owns this package set.")), |
314 | 342 | distroseries=Reference( | ||
315 | 343 | IDistroSeries, title=_("Distroseries"), required=False, | ||
316 | 344 | readonly=True, description=_( | ||
317 | 345 | "The distribution series to which the packageset " | ||
318 | 346 | "is related."))) | ||
319 | 320 | @export_factory_operation(IPackageset, []) | 347 | @export_factory_operation(IPackageset, []) |
321 | 321 | def new(name, description, owner): | 348 | def new(name, description, owner, distroseries=None, related_set=None): |
322 | 322 | """Create a new package set. | 349 | """Create a new package set. |
323 | 323 | 350 | ||
324 | 324 | :param name: the name of the package set to be created. | 351 | :param name: the name of the package set to be created. |
325 | 325 | :param description: the description for the package set to be created. | 352 | :param description: the description for the package set to be created. |
326 | 326 | :param owner: the owner of the package set to be created. | 353 | :param owner: the owner of the package set to be created. |
327 | 354 | :param distroseries: the distroseries to which the new packageset | ||
328 | 355 | is related. Defaults to the current Ubuntu series. | ||
329 | 356 | :param related_set: the newly created package set is to be related to | ||
330 | 357 | `related_set` (by being placed in the same package group). | ||
331 | 327 | 358 | ||
332 | 359 | :raises DuplicatePackagesetName: if a package set with the same `name` | ||
333 | 360 | exists in `distroseries` already. | ||
334 | 328 | :return: a newly created `IPackageset`. | 361 | :return: a newly created `IPackageset`. |
335 | 329 | """ | 362 | """ |
336 | 330 | 363 | ||
337 | @@ -332,10 +365,12 @@ | |||
338 | 332 | name=TextLine(title=_('Package set name'), required=True)) | 365 | name=TextLine(title=_('Package set name'), required=True)) |
339 | 333 | @operation_returns_entry(IPackageset) | 366 | @operation_returns_entry(IPackageset) |
340 | 334 | @export_read_operation() | 367 | @export_read_operation() |
342 | 335 | def getByName(name): | 368 | def getByName(name, distroseries=None): |
343 | 336 | """Return the single package set with the given name (if any). | 369 | """Return the single package set with the given name (if any). |
344 | 337 | 370 | ||
345 | 338 | :param name: the name of the package set sought. | 371 | :param name: the name of the package set sought. |
346 | 372 | :param distroseries: the distroseries to which the new packageset | ||
347 | 373 | is related. Defaults to the current Ubuntu series. | ||
348 | 339 | 374 | ||
349 | 340 | :return: An `IPackageset` instance or None. | 375 | :return: An `IPackageset` instance or None. |
350 | 341 | """ | 376 | """ |
351 | 342 | 377 | ||
352 | === added file 'lib/lp/soyuz/interfaces/packagesetgroup.py' | |||
353 | --- lib/lp/soyuz/interfaces/packagesetgroup.py 1970-01-01 00:00:00 +0000 | |||
354 | +++ lib/lp/soyuz/interfaces/packagesetgroup.py 2009-10-27 23:43:13 +0000 | |||
355 | @@ -0,0 +1,41 @@ | |||
356 | 1 | # Copyright 2009 Canonical Ltd. This software is licensed under the | ||
357 | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). | ||
358 | 3 | |||
359 | 4 | """Packageset Group interface.""" | ||
360 | 5 | |||
361 | 6 | __metaclass__ = type | ||
362 | 7 | |||
363 | 8 | __all__ = [ | ||
364 | 9 | 'IPackagesetGroup', | ||
365 | 10 | ] | ||
366 | 11 | |||
367 | 12 | from zope.schema import Datetime, Int | ||
368 | 13 | |||
369 | 14 | from lazr.restful.fields import Reference | ||
370 | 15 | |||
371 | 16 | from canonical.launchpad import _ | ||
372 | 17 | from lp.registry.interfaces.person import IPerson | ||
373 | 18 | from lp.registry.interfaces.role import IHasOwner | ||
374 | 19 | |||
375 | 20 | |||
376 | 21 | class IPackagesetGroup(IHasOwner): | ||
377 | 22 | """A group of related package sets across distroseries' | ||
378 | 23 | |||
379 | 24 | This class is used internally to group related packagesets across | ||
380 | 25 | distroseries. For example, if in Karmic there is a 'gnome-games' | ||
381 | 26 | package set, and this package set is cloned initially for Lucid, | ||
382 | 27 | then both packagesets would refer to the same packageset-group. | ||
383 | 28 | |||
384 | 29 | Packageset-groups are not exposed at all. The date_created and | ||
385 | 30 | owner fields are present for internal use only. | ||
386 | 31 | """ | ||
387 | 32 | id = Int(title=_('ID'), required=True, readonly=True) | ||
388 | 33 | |||
389 | 34 | date_created = Datetime( | ||
390 | 35 | title=_("Date Created"), required=True, readonly=True, | ||
391 | 36 | description=_("The creation date/time for this packageset group.")) | ||
392 | 37 | |||
393 | 38 | owner = Reference( | ||
394 | 39 | IPerson, title=_("Person"), required=True, readonly=True, | ||
395 | 40 | description=_("The person who created this packageset group.")) | ||
396 | 41 | |||
397 | 0 | 42 | ||
398 | === modified file 'lib/lp/soyuz/model/packageset.py' | |||
399 | --- lib/lp/soyuz/model/packageset.py 2009-07-25 16:33:39 +0000 | |||
400 | +++ lib/lp/soyuz/model/packageset.py 2009-10-27 23:43:13 +0000 | |||
401 | @@ -6,6 +6,7 @@ | |||
402 | 6 | 6 | ||
403 | 7 | import pytz | 7 | import pytz |
404 | 8 | 8 | ||
405 | 9 | from storm.exceptions import IntegrityError | ||
406 | 9 | from storm.expr import In, SQL | 10 | from storm.expr import In, SQL |
407 | 10 | from storm.locals import DateTime, Int, Reference, Storm, Unicode | 11 | from storm.locals import DateTime, Int, Reference, Storm, Unicode |
408 | 11 | 12 | ||
409 | @@ -13,12 +14,13 @@ | |||
410 | 13 | from zope.interface import implements | 14 | from zope.interface import implements |
411 | 14 | 15 | ||
412 | 15 | from canonical.launchpad.interfaces.lpstorm import IMasterStore, IStore | 16 | from canonical.launchpad.interfaces.lpstorm import IMasterStore, IStore |
413 | 17 | from lp.registry.interfaces.distribution import IDistributionSet | ||
414 | 16 | from lp.registry.interfaces.sourcepackagename import ( | 18 | from lp.registry.interfaces.sourcepackagename import ( |
415 | 17 | ISourcePackageName, ISourcePackageNameSet) | 19 | ISourcePackageName, ISourcePackageNameSet) |
416 | 18 | from lp.registry.model.sourcepackagename import SourcePackageName | 20 | from lp.registry.model.sourcepackagename import SourcePackageName |
417 | 19 | from lp.soyuz.interfaces.packageset import ( | 21 | from lp.soyuz.interfaces.packageset import ( |
420 | 20 | IPackageset, IPackagesetSet, NoSuchPackageSet) | 22 | DuplicatePackagesetName, IPackageset, IPackagesetSet, NoSuchPackageSet) |
421 | 21 | 23 | from lp.soyuz.model.packagesetgroup import PackagesetGroup | |
422 | 22 | 24 | ||
423 | 23 | def _order_result_set(result_set): | 25 | def _order_result_set(result_set): |
424 | 24 | """Default order for package set and source package name result sets.""" | 26 | """Default order for package set and source package name result sets.""" |
425 | @@ -45,6 +47,12 @@ | |||
426 | 45 | name = Unicode(name='name', allow_none=False) | 47 | name = Unicode(name='name', allow_none=False) |
427 | 46 | description = Unicode(name='description', allow_none=False) | 48 | description = Unicode(name='description', allow_none=False) |
428 | 47 | 49 | ||
429 | 50 | distroseries_id = Int(name='distroseries', allow_none=False) | ||
430 | 51 | distroseries = Reference(distroseries_id, 'DistroSeries.id') | ||
431 | 52 | |||
432 | 53 | packagesetgroup_id = Int(name='packagesetgroup', allow_none=False) | ||
433 | 54 | packagesetgroup = Reference(packagesetgroup_id, 'PackagesetGroup.id') | ||
434 | 55 | |||
435 | 48 | def add(self, data): | 56 | def add(self, data): |
436 | 49 | """See `IPackageset`.""" | 57 | """See `IPackageset`.""" |
437 | 50 | handlers = ( | 58 | handlers = ( |
438 | @@ -292,26 +300,66 @@ | |||
439 | 292 | """See `IPackagesetSet`.""" | 300 | """See `IPackagesetSet`.""" |
440 | 293 | implements(IPackagesetSet) | 301 | implements(IPackagesetSet) |
441 | 294 | 302 | ||
443 | 295 | def new(self, name, description, owner): | 303 | def new( |
444 | 304 | self, name, description, owner, distroseries=None, related_set=None): | ||
445 | 296 | """See `IPackagesetSet`.""" | 305 | """See `IPackagesetSet`.""" |
446 | 297 | store = IMasterStore(Packageset) | 306 | store = IMasterStore(Packageset) |
447 | 307 | |||
448 | 308 | packagesetgroup = None | ||
449 | 309 | if related_set is not None: | ||
450 | 310 | # Use the packagesetgroup of the `related_set`. | ||
451 | 311 | packagesetgroup = related_set.packagesetgroup | ||
452 | 312 | else: | ||
453 | 313 | # We create the related internal PackagesetGroup for this | ||
454 | 314 | # packageset so that we can later see related package sets across | ||
455 | 315 | # distroserieses. | ||
456 | 316 | packagesetgroup = PackagesetGroup() | ||
457 | 317 | packagesetgroup.owner = owner | ||
458 | 318 | store.add(packagesetgroup) | ||
459 | 319 | |||
460 | 320 | if distroseries is None: | ||
461 | 321 | ubuntu = getUtility(IDistributionSet).getByName('ubuntu') | ||
462 | 322 | distroseries = ubuntu.currentseries | ||
463 | 323 | |||
464 | 298 | packageset = Packageset() | 324 | packageset = Packageset() |
465 | 325 | packageset.packagesetgroup = packagesetgroup | ||
466 | 299 | packageset.name = name | 326 | packageset.name = name |
467 | 300 | packageset.description = description | 327 | packageset.description = description |
468 | 301 | packageset.owner = owner | 328 | packageset.owner = owner |
469 | 329 | |||
470 | 330 | packageset.distroseries = distroseries | ||
471 | 331 | |||
472 | 302 | store.add(packageset) | 332 | store.add(packageset) |
473 | 333 | |||
474 | 334 | # We need to ensure that the cached statements are flushed so that | ||
475 | 335 | # the duplicate name constraint gets triggered here. | ||
476 | 336 | try: | ||
477 | 337 | store.flush() | ||
478 | 338 | except IntegrityError: | ||
479 | 339 | raise DuplicatePackagesetName() | ||
480 | 340 | |||
481 | 303 | return packageset | 341 | return packageset |
482 | 304 | 342 | ||
483 | 305 | def __getitem__(self, name): | 343 | def __getitem__(self, name): |
484 | 306 | """See `IPackagesetSet`.""" | 344 | """See `IPackagesetSet`.""" |
485 | 307 | return self.getByName(name) | 345 | return self.getByName(name) |
486 | 308 | 346 | ||
488 | 309 | def getByName(self, name): | 347 | def getByName(self, name, distroseries=None): |
489 | 310 | """See `IPackagesetSet`.""" | 348 | """See `IPackagesetSet`.""" |
490 | 311 | store = IStore(Packageset) | 349 | store = IStore(Packageset) |
491 | 312 | if not isinstance(name, unicode): | 350 | if not isinstance(name, unicode): |
492 | 313 | name = unicode(name, 'utf-8') | 351 | name = unicode(name, 'utf-8') |
494 | 314 | package_set = store.find(Packageset, Packageset.name == name).one() | 352 | |
495 | 353 | extra_args = [] | ||
496 | 354 | if distroseries is not None: | ||
497 | 355 | extra_args.append(Packageset.distroseries == distroseries) | ||
498 | 356 | else: | ||
499 | 357 | ubuntu = getUtility(IDistributionSet).getByName('ubuntu') | ||
500 | 358 | extra_args.append(Packageset.distroseries == ubuntu.currentseries) | ||
501 | 359 | |||
502 | 360 | package_set = store.find( | ||
503 | 361 | Packageset, Packageset.name == name, *extra_args).one() | ||
504 | 362 | |||
505 | 315 | if package_set is None: | 363 | if package_set is None: |
506 | 316 | raise NoSuchPackageSet(name) | 364 | raise NoSuchPackageSet(name) |
507 | 317 | return package_set | 365 | return package_set |
508 | 318 | 366 | ||
509 | === added file 'lib/lp/soyuz/model/packagesetgroup.py' | |||
510 | --- lib/lp/soyuz/model/packagesetgroup.py 1970-01-01 00:00:00 +0000 | |||
511 | +++ lib/lp/soyuz/model/packagesetgroup.py 2009-10-27 23:43:13 +0000 | |||
512 | @@ -0,0 +1,30 @@ | |||
513 | 1 | # Copyright 2009 Canonical Ltd. This software is licensed under the | ||
514 | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). | ||
515 | 3 | |||
516 | 4 | __metaclass__ = type | ||
517 | 5 | |||
518 | 6 | __all__ = [ | ||
519 | 7 | 'PackagesetGroup', | ||
520 | 8 | ] | ||
521 | 9 | |||
522 | 10 | import pytz | ||
523 | 11 | |||
524 | 12 | from storm.locals import DateTime, Int, Reference, Storm | ||
525 | 13 | |||
526 | 14 | from zope.interface import implements | ||
527 | 15 | |||
528 | 16 | from lp.soyuz.interfaces.packagesetgroup import IPackagesetGroup | ||
529 | 17 | |||
530 | 18 | |||
531 | 19 | class PackagesetGroup(Storm): | ||
532 | 20 | """See `IPackageset`.""" | ||
533 | 21 | implements(IPackagesetGroup) | ||
534 | 22 | __storm_table__ = 'PackagesetGroup' | ||
535 | 23 | id = Int(primary=True) | ||
536 | 24 | |||
537 | 25 | date_created = DateTime( | ||
538 | 26 | name='date_created', allow_none=False, tzinfo=pytz.UTC) | ||
539 | 27 | |||
540 | 28 | owner_id = Int(name='owner', allow_none=False) | ||
541 | 29 | owner = Reference(owner_id, 'Person.id') | ||
542 | 30 | |||
543 | 0 | 31 | ||
544 | === added file 'lib/lp/soyuz/tests/test_packageset.py' | |||
545 | --- lib/lp/soyuz/tests/test_packageset.py 1970-01-01 00:00:00 +0000 | |||
546 | +++ lib/lp/soyuz/tests/test_packageset.py 2009-10-27 23:43:13 +0000 | |||
547 | @@ -0,0 +1,121 @@ | |||
548 | 1 | # Copyright 2009 Canonical Ltd. This software is licensed under the | ||
549 | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). | ||
550 | 3 | |||
551 | 4 | """Test Packageset features.""" | ||
552 | 5 | |||
553 | 6 | from zope.component import getUtility | ||
554 | 7 | |||
555 | 8 | from canonical.testing import LaunchpadZopelessLayer | ||
556 | 9 | |||
557 | 10 | from lp.testing import TestCaseWithFactory | ||
558 | 11 | from lp.registry.interfaces.distribution import IDistributionSet | ||
559 | 12 | from lp.registry.interfaces.distroseries import DistroSeriesStatus | ||
560 | 13 | from lp.soyuz.interfaces.packageset import ( | ||
561 | 14 | DuplicatePackagesetName, IPackagesetSet) | ||
562 | 15 | |||
563 | 16 | |||
564 | 17 | class TestPackagesetSetNew(TestCaseWithFactory): | ||
565 | 18 | |||
566 | 19 | layer = LaunchpadZopelessLayer | ||
567 | 20 | |||
568 | 21 | def setUp(self): | ||
569 | 22 | """Setup a distribution with multiple distroseries.""" | ||
570 | 23 | super(TestPackagesetSetNew, self).setUp() | ||
571 | 24 | self.distribution = getUtility(IDistributionSet).getByName( | ||
572 | 25 | 'ubuntu') | ||
573 | 26 | self.distroseries_current = self.distribution.currentseries | ||
574 | 27 | self.distroseries_experimental = self.factory.makeDistroRelease( | ||
575 | 28 | distribution = self.distribution, name="experimental", | ||
576 | 29 | status=DistroSeriesStatus.EXPERIMENTAL) | ||
577 | 30 | |||
578 | 31 | self.person1 = self.factory.makePerson( | ||
579 | 32 | name='hacker', displayname=u'Happy Hacker') | ||
580 | 33 | |||
581 | 34 | self.packageset_set = getUtility(IPackagesetSet) | ||
582 | 35 | |||
583 | 36 | def test_new_defaults_to_current_distroseries(self): | ||
584 | 37 | # If the distroseries is not provided, the current development | ||
585 | 38 | # distroseries will be assumed. | ||
586 | 39 | packageset = self.packageset_set.new( | ||
587 | 40 | u'kernel', u'Contains all OS kernel packages', self.person1) | ||
588 | 41 | |||
589 | 42 | self.failUnlessEqual( | ||
590 | 43 | self.distroseries_current, packageset.distroseries) | ||
591 | 44 | |||
592 | 45 | def test_new_with_specified_distroseries(self): | ||
593 | 46 | # A distroseries can be provided when creating a package set. | ||
594 | 47 | packageset = self.packageset_set.new( | ||
595 | 48 | u'kernel', u'Contains all OS kernel packages', self.person1, | ||
596 | 49 | distroseries=self.distroseries_experimental) | ||
597 | 50 | |||
598 | 51 | self.failUnlessEqual( | ||
599 | 52 | self.distroseries_experimental, packageset.distroseries) | ||
600 | 53 | |||
601 | 54 | def test_new_creates_new_packageset_group(self): | ||
602 | 55 | # Creating a new packageset should also create a new packageset | ||
603 | 56 | # group with the same owner. | ||
604 | 57 | packageset = self.packageset_set.new( | ||
605 | 58 | u'kernel', u'Contains all OS kernel packages', self.person1, | ||
606 | 59 | distroseries=self.distroseries_experimental) | ||
607 | 60 | |||
608 | 61 | self.failUnlessEqual( | ||
609 | 62 | self.person1, packageset.packagesetgroup.owner) | ||
610 | 63 | |||
611 | 64 | def test_new_duplicate_name_for_same_distroseries(self): | ||
612 | 65 | # Creating a packageset with a duplicate name for the | ||
613 | 66 | # given distroseries will fail. | ||
614 | 67 | packageset = self.packageset_set.new( | ||
615 | 68 | u'kernel', u'Contains all OS kernel packages', self.person1, | ||
616 | 69 | distroseries=self.distroseries_experimental) | ||
617 | 70 | |||
618 | 71 | self.failUnlessRaises( | ||
619 | 72 | DuplicatePackagesetName, self.packageset_set.new, | ||
620 | 73 | u'kernel', u'A packageset with a duplicate name', self.person1, | ||
621 | 74 | distroseries=self.distroseries_experimental) | ||
622 | 75 | |||
623 | 76 | def test_new_duplicate_name_for_different_distroseries(self): | ||
624 | 77 | # Creating a packageset with a duplicate name but for a different | ||
625 | 78 | # series is no problem. | ||
626 | 79 | packageset = self.packageset_set.new( | ||
627 | 80 | u'kernel', u'Contains all OS kernel packages', self.person1) | ||
628 | 81 | |||
629 | 82 | packageset2 = self.packageset_set.new( | ||
630 | 83 | u'kernel', u'A packageset with a duplicate name', self.person1, | ||
631 | 84 | distroseries=self.distroseries_experimental) | ||
632 | 85 | self.assertEqual(packageset.name, packageset2.name) | ||
633 | 86 | |||
634 | 87 | def test_new_related_packageset(self): | ||
635 | 88 | # Creating a new package set while specifying a `related_set` should | ||
636 | 89 | # have the effect that the former ends up in the same group as the | ||
637 | 90 | # latter. | ||
638 | 91 | pset1 = self.packageset_set.new( | ||
639 | 92 | u'kernel', u'Contains all OS kernel packages', self.person1) | ||
640 | 93 | |||
641 | 94 | pset2 = self.packageset_set.new( | ||
642 | 95 | u'kernel', u'A related package set.', self.person1, | ||
643 | 96 | distroseries=self.distroseries_experimental, related_set=pset1) | ||
644 | 97 | self.assertEqual(pset1.packagesetgroup, pset2.packagesetgroup) | ||
645 | 98 | |||
646 | 99 | def test_get_by_name_in_current_distroseries(self): | ||
647 | 100 | # IPackagesetSet.getByName() will return the package set in the | ||
648 | 101 | # current distroseries if the optional `distroseries` parameter is | ||
649 | 102 | # omitted. | ||
650 | 103 | pset1 = self.packageset_set.new( | ||
651 | 104 | u'kernel', u'Contains all OS kernel packages', self.person1) | ||
652 | 105 | pset2 = self.packageset_set.new( | ||
653 | 106 | u'kernel', u'A related package set.', self.person1, | ||
654 | 107 | distroseries=self.distroseries_experimental, related_set=pset1) | ||
655 | 108 | pset_found = getUtility(IPackagesetSet).getByName('kernel') | ||
656 | 109 | self.assertEqual(pset1, pset_found) | ||
657 | 110 | |||
658 | 111 | def test_get_by_name_in_specified_distroseries(self): | ||
659 | 112 | # IPackagesetSet.getByName() will return the package set in the | ||
660 | 113 | # specified distroseries. | ||
661 | 114 | pset1 = self.packageset_set.new( | ||
662 | 115 | u'kernel', u'Contains all OS kernel packages', self.person1) | ||
663 | 116 | pset2 = self.packageset_set.new( | ||
664 | 117 | u'kernel', u'A related package set.', self.person1, | ||
665 | 118 | distroseries=self.distroseries_experimental, related_set=pset1) | ||
666 | 119 | pset_found = getUtility(IPackagesetSet).getByName( | ||
667 | 120 | 'kernel', distroseries=self.distroseries_experimental) | ||
668 | 121 | self.assertEqual(pset2, pset_found) |
Hello there!
The branch at hand introduces the association between package sets and
distro series as well as a new model class (PackagesetGroup) that
facilitates the tracking of equivalent package sets across distro series
boundaries.
For more detail on these changes and why they are needed, please see:
* the original "package set and distro series" meeting minutes: pastebin. ubuntu. com/302054/ pastebin. ubuntu. com/302058/
http://
* Julian's update: http://
Please note that the underlying db schema patch (http:// tinyurl. com/ykkwb97) has already been approved.
This branch is based on the respective schema patch branch (lp:~al-maisan/launchpad/psds-399186). The *actual* diff for it is here:
http:// pastebin. ubuntu. com/302886/
Tests to run:
bin/test -vvt packageset
No pertinent "make lint" errors or warnings.