Merge lp:~wgrant/launchpad/sprb-new-model-columns into lp:launchpad/db-devel
- sprb-new-model-columns
- Merge into db-devel
Proposed by
William Grant
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Approved by: | Tim Penhey | ||||||||
Approved revision: | not available | ||||||||
Merged at revision: | not available | ||||||||
Proposed branch: | lp:~wgrant/launchpad/sprb-new-model-columns | ||||||||
Merge into: | lp:launchpad/db-devel | ||||||||
Prerequisite: | lp:~wgrant/launchpad/sprbu-columns-to-sprb | ||||||||
Diff against target: |
355 lines (+89/-61) 9 files modified
.bzrignore (+1/-0) database/sampledata/current-dev.sql (+0/-7) database/sampledata/current.sql (+0/-7) database/schema/security.cfg (+0/-2) lib/lp/buildmaster/model/buildbase.py (+29/-1) lib/lp/code/model/sourcepackagerecipebuild.py (+13/-19) lib/lp/soyuz/doc/build.txt (+1/-1) lib/lp/soyuz/model/build.py (+1/-24) lib/lp/soyuz/tests/test_build.py (+44/-0) |
||||||||
To merge this branch: | bzr merge lp:~wgrant/launchpad/sprb-new-model-columns | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Julian Edwards (community) | Approve | ||
Review via email: mp+19172@code.launchpad.net |
Commit message
Drop SourcePackageRe
Description of the change
To post a comment you must log in.
Revision history for this message
William Grant (wgrant) wrote : | # |
Revision history for this message
Julian Edwards (julian-edwards) wrote : | # |
Looks good, thanks for this. Just a couple of comments:
1. s/exist/exists/ in the assertion text message.
2. You get brownie points if you can remove the commit from the tests - we found out that they slow the tests down massively so now I am on a jihad against them. Try using store.flush() or if that fails, try store.commit() as it's a bit closer to the metal than transaction.
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file '.bzrignore' | |||
2 | --- .bzrignore 2010-01-13 22:16:04 +0000 | |||
3 | +++ .bzrignore 2010-02-15 21:43:48 +0000 | |||
4 | @@ -58,3 +58,4 @@ | |||
5 | 58 | .subversion | 58 | .subversion |
6 | 59 | lib/canonical/buildd/launchpad-files | 59 | lib/canonical/buildd/launchpad-files |
7 | 60 | .testrepository | 60 | .testrepository |
8 | 61 | ./pipes | ||
9 | 61 | 62 | ||
10 | === modified file 'database/sampledata/current-dev.sql' | |||
11 | --- database/sampledata/current-dev.sql 2010-02-04 11:12:20 +0000 | |||
12 | +++ database/sampledata/current-dev.sql 2010-02-15 21:43:48 +0000 | |||
13 | @@ -9062,13 +9062,6 @@ | |||
14 | 9062 | ALTER TABLE sourcepackagerecipebuildjob ENABLE TRIGGER ALL; | 9062 | ALTER TABLE sourcepackagerecipebuildjob ENABLE TRIGGER ALL; |
15 | 9063 | 9063 | ||
16 | 9064 | 9064 | ||
17 | 9065 | ALTER TABLE sourcepackagerecipebuildupload DISABLE TRIGGER ALL; | ||
18 | 9066 | |||
19 | 9067 | |||
20 | 9068 | |||
21 | 9069 | ALTER TABLE sourcepackagerecipebuildupload ENABLE TRIGGER ALL; | ||
22 | 9070 | |||
23 | 9071 | |||
24 | 9072 | ALTER TABLE sourcepackagerecipedata DISABLE TRIGGER ALL; | 9065 | ALTER TABLE sourcepackagerecipedata DISABLE TRIGGER ALL; |
25 | 9073 | 9066 | ||
26 | 9074 | 9067 | ||
27 | 9075 | 9068 | ||
28 | === modified file 'database/sampledata/current.sql' | |||
29 | --- database/sampledata/current.sql 2010-02-04 11:12:20 +0000 | |||
30 | +++ database/sampledata/current.sql 2010-02-15 21:43:48 +0000 | |||
31 | @@ -8948,13 +8948,6 @@ | |||
32 | 8948 | ALTER TABLE sourcepackagerecipebuildjob ENABLE TRIGGER ALL; | 8948 | ALTER TABLE sourcepackagerecipebuildjob ENABLE TRIGGER ALL; |
33 | 8949 | 8949 | ||
34 | 8950 | 8950 | ||
35 | 8951 | ALTER TABLE sourcepackagerecipebuildupload DISABLE TRIGGER ALL; | ||
36 | 8952 | |||
37 | 8953 | |||
38 | 8954 | |||
39 | 8955 | ALTER TABLE sourcepackagerecipebuildupload ENABLE TRIGGER ALL; | ||
40 | 8956 | |||
41 | 8957 | |||
42 | 8958 | ALTER TABLE sourcepackagerecipedata DISABLE TRIGGER ALL; | 8951 | ALTER TABLE sourcepackagerecipedata DISABLE TRIGGER ALL; |
43 | 8959 | 8952 | ||
44 | 8960 | 8953 | ||
45 | 8961 | 8954 | ||
46 | === modified file 'database/schema/security.cfg' | |||
47 | --- database/schema/security.cfg 2010-02-15 13:33:06 +0000 | |||
48 | +++ database/schema/security.cfg 2010-02-15 21:43:48 +0000 | |||
49 | @@ -281,7 +281,6 @@ | |||
50 | 281 | public.sourcepackagerecipe = SELECT, INSERT, UPDATE, DELETE | 281 | public.sourcepackagerecipe = SELECT, INSERT, UPDATE, DELETE |
51 | 282 | public.sourcepackagerecipebuild = SELECT, INSERT, UPDATE, DELETE | 282 | public.sourcepackagerecipebuild = SELECT, INSERT, UPDATE, DELETE |
52 | 283 | public.sourcepackagerecipebuildjob = SELECT, INSERT, UPDATE | 283 | public.sourcepackagerecipebuildjob = SELECT, INSERT, UPDATE |
53 | 284 | public.sourcepackagerecipebuildupload = SELECT, INSERT, UPDATE, DELETE | ||
54 | 285 | public.sourcepackagerecipedata = SELECT, INSERT, UPDATE, DELETE | 284 | public.sourcepackagerecipedata = SELECT, INSERT, UPDATE, DELETE |
55 | 286 | public.sourcepackagerecipedatainstruction = SELECT, INSERT, UPDATE, DELETE | 285 | public.sourcepackagerecipedatainstruction = SELECT, INSERT, UPDATE, DELETE |
56 | 287 | public.specificationbranch = SELECT, INSERT, UPDATE, DELETE | 286 | public.specificationbranch = SELECT, INSERT, UPDATE, DELETE |
57 | @@ -413,7 +412,6 @@ | |||
58 | 413 | public.sprint = SELECT | 412 | public.sprint = SELECT |
59 | 414 | public.sourcepackagereleasefile = SELECT | 413 | public.sourcepackagereleasefile = SELECT |
60 | 415 | public.sourcepackagerecipebuild = SELECT | 414 | public.sourcepackagerecipebuild = SELECT |
61 | 416 | public.sourcepackagerecipebuildupload = SELECT | ||
62 | 417 | public.temporaryblobstorage = SELECT, DELETE | 415 | public.temporaryblobstorage = SELECT, DELETE |
63 | 418 | public.translationimportqueueentry = SELECT | 416 | public.translationimportqueueentry = SELECT |
64 | 419 | 417 | ||
65 | 420 | 418 | ||
66 | === modified file 'lib/lp/buildmaster/model/buildbase.py' | |||
67 | --- lib/lp/buildmaster/model/buildbase.py 2010-02-10 15:02:42 +0000 | |||
68 | +++ lib/lp/buildmaster/model/buildbase.py 2010-02-15 21:43:48 +0000 | |||
69 | @@ -14,14 +14,18 @@ | |||
70 | 14 | import os | 14 | import os |
71 | 15 | import pytz | 15 | import pytz |
72 | 16 | import subprocess | 16 | import subprocess |
73 | 17 | from cStringIO import StringIO | ||
74 | 17 | 18 | ||
75 | 18 | from storm.store import Store | 19 | from storm.store import Store |
76 | 20 | from zope.component import getUtility | ||
77 | 19 | from zope.security.proxy import removeSecurityProxy | 21 | from zope.security.proxy import removeSecurityProxy |
78 | 20 | 22 | ||
79 | 21 | from canonical.config import config | 23 | from canonical.config import config |
80 | 22 | from canonical.database.constants import UTC_NOW | 24 | from canonical.database.constants import UTC_NOW |
81 | 23 | from canonical.database.sqlbase import ( | 25 | from canonical.database.sqlbase import ( |
82 | 24 | clear_current_connection_cache, cursor, flush_database_updates) | 26 | clear_current_connection_cache, cursor, flush_database_updates) |
83 | 27 | from canonical.launchpad.helpers import filenameToContentType | ||
84 | 28 | from canonical.launchpad.interfaces.librarian import ILibraryFileAliasSet | ||
85 | 25 | from canonical.librarian.utils import copy_and_close | 29 | from canonical.librarian.utils import copy_and_close |
86 | 26 | from lp.registry.interfaces.pocket import pocketsuffix | 30 | from lp.registry.interfaces.pocket import pocketsuffix |
87 | 27 | from lp.soyuz.interfaces.build import BuildStatus | 31 | from lp.soyuz.interfaces.build import BuildStatus |
88 | @@ -354,7 +358,31 @@ | |||
89 | 354 | # the time operations for duration. | 358 | # the time operations for duration. |
90 | 355 | RIGHT_NOW = datetime.datetime.now(pytz.timezone('UTC')) | 359 | RIGHT_NOW = datetime.datetime.now(pytz.timezone('UTC')) |
91 | 356 | self.buildduration = RIGHT_NOW - self.buildqueue_record.date_started | 360 | self.buildduration = RIGHT_NOW - self.buildqueue_record.date_started |
93 | 357 | self.dependencies = slave_status.get('dependencies') | 361 | if slave_status.get('dependencies') is not None: |
94 | 362 | self.dependencies = unicode(slave_status.get('dependencies')) | ||
95 | 363 | else: | ||
96 | 364 | self.dependencies = None | ||
97 | 365 | |||
98 | 366 | def storeUploadLog(self, content): | ||
99 | 367 | """See `IBuildBase`.""" | ||
100 | 368 | # The given content is stored in the librarian, restricted as | ||
101 | 369 | # necessary according to the targeted archive's privacy. The content | ||
102 | 370 | # object's 'upload_log' attribute will point to the | ||
103 | 371 | # `LibrarianFileAlias`. | ||
104 | 372 | |||
105 | 373 | assert self.upload_log is None, ( | ||
106 | 374 | "Upload log information already exists and cannot be overridden.") | ||
107 | 375 | |||
108 | 376 | filename = 'upload_%s_log.txt' % self.id | ||
109 | 377 | contentType = filenameToContentType(filename) | ||
110 | 378 | file_size = len(content) | ||
111 | 379 | file_content = StringIO(content) | ||
112 | 380 | restricted = self.is_private | ||
113 | 381 | |||
114 | 382 | library_file = getUtility(ILibraryFileAliasSet).create( | ||
115 | 383 | filename, file_size, file_content, contentType=contentType, | ||
116 | 384 | restricted=restricted) | ||
117 | 385 | self.upload_log = library_file | ||
118 | 358 | 386 | ||
119 | 359 | def queueBuild(self, suspended=False): | 387 | def queueBuild(self, suspended=False): |
120 | 360 | """See `IBuildBase`""" | 388 | """See `IBuildBase`""" |
121 | 361 | 389 | ||
122 | === modified file 'lib/lp/code/model/sourcepackagerecipebuild.py' | |||
123 | --- lib/lp/code/model/sourcepackagerecipebuild.py 2010-02-05 15:06:28 +0000 | |||
124 | +++ lib/lp/code/model/sourcepackagerecipebuild.py 2010-02-15 21:43:48 +0000 | |||
125 | @@ -12,10 +12,10 @@ | |||
126 | 12 | 12 | ||
127 | 13 | from canonical.database.constants import UTC_NOW | 13 | from canonical.database.constants import UTC_NOW |
128 | 14 | from canonical.database.datetimecol import UtcDateTimeCol | 14 | from canonical.database.datetimecol import UtcDateTimeCol |
130 | 15 | from canonical.database.enumcol import EnumCol | 15 | from canonical.database.enumcol import DBEnum |
131 | 16 | from canonical.launchpad.interfaces.lpstorm import IMasterStore | 16 | from canonical.launchpad.interfaces.lpstorm import IMasterStore |
132 | 17 | 17 | ||
134 | 18 | from storm.locals import Int, Reference, Storm, TimeDelta | 18 | from storm.locals import Int, Reference, Storm, TimeDelta, Unicode |
135 | 19 | from storm.store import Store | 19 | from storm.store import Store |
136 | 20 | 20 | ||
137 | 21 | from zope.component import getUtility | 21 | from zope.component import getUtility |
138 | @@ -62,8 +62,12 @@ | |||
139 | 62 | buildlog_id = Int(name='build_log', allow_none=True) | 62 | buildlog_id = Int(name='build_log', allow_none=True) |
140 | 63 | buildlog = Reference(buildlog_id, 'LibraryFileAlias.id') | 63 | buildlog = Reference(buildlog_id, 'LibraryFileAlias.id') |
141 | 64 | 64 | ||
144 | 65 | buildstate = EnumCol( | 65 | buildstate = DBEnum(enum=BuildStatus, name='build_state') |
145 | 66 | dbName='build_state', notNull=True, schema=BuildStatus) | 66 | |
146 | 67 | dependencies = Unicode(allow_none=True) | ||
147 | 68 | |||
148 | 69 | upload_log_id = Int(name='upload_log', allow_none=True) | ||
149 | 70 | upload_log = Reference(upload_log_id, 'LibraryFileAlias.id') | ||
150 | 67 | 71 | ||
151 | 68 | @property | 72 | @property |
152 | 69 | def current_component(self): | 73 | def current_component(self): |
153 | @@ -76,9 +80,6 @@ | |||
154 | 76 | distroseries_id = Int(name='distroseries', allow_none=True) | 80 | distroseries_id = Int(name='distroseries', allow_none=True) |
155 | 77 | distroseries = Reference(distroseries_id, 'DistroSeries.id') | 81 | distroseries = Reference(distroseries_id, 'DistroSeries.id') |
156 | 78 | 82 | ||
157 | 79 | # XXX wgrant 2010-01-15 bug=507751: Need a DB field for this. | ||
158 | 80 | dependencies = None | ||
159 | 81 | |||
160 | 82 | sourcepackagename_id = Int(name='sourcepackagename', allow_none=True) | 83 | sourcepackagename_id = Int(name='sourcepackagename', allow_none=True) |
161 | 83 | sourcepackagename = Reference( | 84 | sourcepackagename = Reference( |
162 | 84 | sourcepackagename_id, 'SourcePackageName.id') | 85 | sourcepackagename_id, 'SourcePackageName.id') |
163 | @@ -88,12 +89,7 @@ | |||
164 | 88 | """See `IBuildBase`.""" | 89 | """See `IBuildBase`.""" |
165 | 89 | return self.distroseries.distribution | 90 | return self.distroseries.distribution |
166 | 90 | 91 | ||
173 | 91 | @property | 92 | pocket = DBEnum(enum=PackagePublishingPocket) |
168 | 92 | def pocket(self): | ||
169 | 93 | # XXX: JRV 2010-01-15 bug=507307: The database table really should | ||
170 | 94 | # have a pocket column, although this is not a big problem at the | ||
171 | 95 | # moment as recipe builds only happen for PPA's (so far). | ||
172 | 96 | return PackagePublishingPocket.RELEASE | ||
174 | 97 | 93 | ||
175 | 98 | recipe_id = Int(name='recipe', allow_none=False) | 94 | recipe_id = Int(name='recipe', allow_none=False) |
176 | 99 | recipe = Reference(recipe_id, 'SourcePackageRecipe.id') | 95 | recipe = Reference(recipe_id, 'SourcePackageRecipe.id') |
177 | @@ -112,13 +108,14 @@ | |||
178 | 112 | return results.one() | 108 | return results.one() |
179 | 113 | 109 | ||
180 | 114 | def __init__(self, distroseries, sourcepackagename, recipe, requester, | 110 | def __init__(self, distroseries, sourcepackagename, recipe, requester, |
182 | 115 | archive, date_created=None, date_first_dispatched=None, | 111 | archive, pocket, date_created=None, date_first_dispatched=None, |
183 | 116 | date_built=None, builder=None, | 112 | date_built=None, builder=None, |
184 | 117 | build_state=BuildStatus.NEEDSBUILD, build_log=None, | 113 | build_state=BuildStatus.NEEDSBUILD, build_log=None, |
185 | 118 | build_duration=None): | 114 | build_duration=None): |
186 | 119 | """Construct a SourcePackageRecipeBuild.""" | 115 | """Construct a SourcePackageRecipeBuild.""" |
187 | 120 | super(SourcePackageRecipeBuild, self).__init__() | 116 | super(SourcePackageRecipeBuild, self).__init__() |
188 | 121 | self.archive = archive | 117 | self.archive = archive |
189 | 118 | self.pocket = pocket | ||
190 | 122 | self.buildduration = build_duration | 119 | self.buildduration = build_duration |
191 | 123 | self.buildlog = build_log | 120 | self.buildlog = build_log |
192 | 124 | self.builder = builder | 121 | self.builder = builder |
193 | @@ -133,6 +130,7 @@ | |||
194 | 133 | 130 | ||
195 | 134 | @classmethod | 131 | @classmethod |
196 | 135 | def new(cls, sourcepackage, recipe, requester, archive, | 132 | def new(cls, sourcepackage, recipe, requester, archive, |
197 | 133 | pocket=PackagePublishingPocket.RELEASE, | ||
198 | 136 | date_created=None): | 134 | date_created=None): |
199 | 137 | """See `ISourcePackageRecipeBuildSource`.""" | 135 | """See `ISourcePackageRecipeBuildSource`.""" |
200 | 138 | store = IMasterStore(SourcePackageRecipeBuild) | 136 | store = IMasterStore(SourcePackageRecipeBuild) |
201 | @@ -144,6 +142,7 @@ | |||
202 | 144 | recipe, | 142 | recipe, |
203 | 145 | requester, | 143 | requester, |
204 | 146 | archive, | 144 | archive, |
205 | 145 | pocket, | ||
206 | 147 | date_created=date_created) | 146 | date_created=date_created) |
207 | 148 | store.add(spbuild) | 147 | store.add(spbuild) |
208 | 149 | return spbuild | 148 | return spbuild |
209 | @@ -168,11 +167,6 @@ | |||
210 | 168 | # XXX: wgrant 2010-01-19 bug=507764: Need proper implementation. | 167 | # XXX: wgrant 2010-01-19 bug=507764: Need proper implementation. |
211 | 169 | return datetime.timedelta(minutes=2) | 168 | return datetime.timedelta(minutes=2) |
212 | 170 | 169 | ||
213 | 171 | def storeUploadLog(self, content): | ||
214 | 172 | """See `IBuildBase`.""" | ||
215 | 173 | # XXX: wgrant 2010-01-20 bug=509892: Store in the DB. | ||
216 | 174 | return | ||
217 | 175 | |||
218 | 176 | def notify(self, extra_info=None): | 170 | def notify(self, extra_info=None): |
219 | 177 | """See `IBuildBase`.""" | 171 | """See `IBuildBase`.""" |
220 | 178 | # XXX: wgrant 2010-01-20 bug=509893: Implement this. | 172 | # XXX: wgrant 2010-01-20 bug=509893: Implement this. |
221 | 179 | 173 | ||
222 | === modified file 'lib/lp/soyuz/doc/build.txt' | |||
223 | --- lib/lp/soyuz/doc/build.txt 2010-02-15 12:59:55 +0000 | |||
224 | +++ lib/lp/soyuz/doc/build.txt 2010-02-15 21:43:48 +0000 | |||
225 | @@ -966,7 +966,7 @@ | |||
226 | 966 | >>> failedtoupload_build.storeUploadLog('something') | 966 | >>> failedtoupload_build.storeUploadLog('something') |
227 | 967 | Traceback (most recent call last): | 967 | Traceback (most recent call last): |
228 | 968 | ... | 968 | ... |
230 | 969 | AssertionError: Upload log information already exist and cannot be | 969 | AssertionError: Upload log information already exists and cannot be |
231 | 970 | overridden. | 970 | overridden. |
232 | 971 | 971 | ||
233 | 972 | It's only possible to store another 'upload_log' content once the | 972 | It's only possible to store another 'upload_log' content once the |
234 | 973 | 973 | ||
235 | === modified file 'lib/lp/soyuz/model/build.py' | |||
236 | --- lib/lp/soyuz/model/build.py 2010-02-10 10:31:15 +0000 | |||
237 | +++ lib/lp/soyuz/model/build.py 2010-02-15 21:43:48 +0000 | |||
238 | @@ -7,7 +7,6 @@ | |||
239 | 7 | __all__ = ['Build', 'BuildSet'] | 7 | __all__ = ['Build', 'BuildSet'] |
240 | 8 | 8 | ||
241 | 9 | import apt_pkg | 9 | import apt_pkg |
242 | 10 | from cStringIO import StringIO | ||
243 | 11 | import datetime | 10 | import datetime |
244 | 12 | import logging | 11 | import logging |
245 | 13 | import operator | 12 | import operator |
246 | @@ -32,10 +31,9 @@ | |||
247 | 32 | from canonical.launchpad.database.librarian import ( | 31 | from canonical.launchpad.database.librarian import ( |
248 | 33 | LibraryFileAlias, LibraryFileContent) | 32 | LibraryFileAlias, LibraryFileContent) |
249 | 34 | from canonical.launchpad.helpers import ( | 33 | from canonical.launchpad.helpers import ( |
251 | 35 | get_contact_email_addresses, filenameToContentType, get_email_template) | 34 | get_contact_email_addresses, get_email_template) |
252 | 36 | from canonical.launchpad.interfaces.launchpad import ( | 35 | from canonical.launchpad.interfaces.launchpad import ( |
253 | 37 | NotFoundError, ILaunchpadCelebrities) | 36 | NotFoundError, ILaunchpadCelebrities) |
254 | 38 | from canonical.launchpad.interfaces.librarian import ILibraryFileAliasSet | ||
255 | 39 | from canonical.launchpad.mail import ( | 37 | from canonical.launchpad.mail import ( |
256 | 40 | simple_sendmail, format_address) | 38 | simple_sendmail, format_address) |
257 | 41 | from canonical.launchpad.webapp import canonical_url | 39 | from canonical.launchpad.webapp import canonical_url |
258 | @@ -668,27 +666,6 @@ | |||
259 | 668 | fromaddress, toaddress, subject, message, | 666 | fromaddress, toaddress, subject, message, |
260 | 669 | headers=extra_headers) | 667 | headers=extra_headers) |
261 | 670 | 668 | ||
262 | 671 | def storeUploadLog(self, content): | ||
263 | 672 | """See `IBuildBase`.""" | ||
264 | 673 | # The given content is stored in the librarian, restricted as | ||
265 | 674 | # necessary according to the targeted archive's privacy. The content | ||
266 | 675 | # object's 'upload_log' attribute will point to the | ||
267 | 676 | # `LibrarianFileAlias`. | ||
268 | 677 | |||
269 | 678 | assert self.upload_log is None, ( | ||
270 | 679 | "Upload log information already exist and cannot be overridden.") | ||
271 | 680 | |||
272 | 681 | filename = 'upload_%s_log.txt' % self.id | ||
273 | 682 | contentType = filenameToContentType(filename) | ||
274 | 683 | file_size = len(content) | ||
275 | 684 | file_content = StringIO(content) | ||
276 | 685 | restricted = self.archive.private | ||
277 | 686 | |||
278 | 687 | library_file = getUtility(ILibraryFileAliasSet).create( | ||
279 | 688 | filename, file_size, file_content, contentType=contentType, | ||
280 | 689 | restricted=restricted) | ||
281 | 690 | self.upload_log = library_file | ||
282 | 691 | |||
283 | 692 | def _getDebByFileName(self, filename): | 669 | def _getDebByFileName(self, filename): |
284 | 693 | """Helper function to get a .deb LFA in the context of this build.""" | 670 | """Helper function to get a .deb LFA in the context of this build.""" |
285 | 694 | store = Store.of(self) | 671 | store = Store.of(self) |
286 | 695 | 672 | ||
287 | === modified file 'lib/lp/soyuz/tests/test_build.py' | |||
288 | --- lib/lp/soyuz/tests/test_build.py 2010-02-03 16:21:57 +0000 | |||
289 | +++ lib/lp/soyuz/tests/test_build.py 2010-02-15 21:43:48 +0000 | |||
290 | @@ -8,8 +8,10 @@ | |||
291 | 8 | import unittest | 8 | import unittest |
292 | 9 | 9 | ||
293 | 10 | from storm.store import Store | 10 | from storm.store import Store |
294 | 11 | import transaction | ||
295 | 11 | from zope.component import getUtility | 12 | from zope.component import getUtility |
296 | 12 | 13 | ||
297 | 14 | from canonical.database.constants import UTC_NOW | ||
298 | 13 | from canonical.testing import LaunchpadZopelessLayer | 15 | from canonical.testing import LaunchpadZopelessLayer |
299 | 14 | from lp.services.job.model.job import Job | 16 | from lp.services.job.model.job import Job |
300 | 15 | from lp.buildmaster.interfaces.buildbase import IBuildBase | 17 | from lp.buildmaster.interfaces.buildbase import IBuildBase |
301 | @@ -21,6 +23,7 @@ | |||
302 | 21 | from lp.soyuz.model.buildpackagejob import BuildPackageJob | 23 | from lp.soyuz.model.buildpackagejob import BuildPackageJob |
303 | 22 | from lp.soyuz.model.processor import ProcessorFamilySet | 24 | from lp.soyuz.model.processor import ProcessorFamilySet |
304 | 23 | from lp.soyuz.tests.test_publishing import SoyuzTestPublisher | 25 | from lp.soyuz.tests.test_publishing import SoyuzTestPublisher |
305 | 26 | from lp.soyuz.tests.soyuzbuilddhelpers import WaitingSlave | ||
306 | 24 | from lp.testing import TestCaseWithFactory | 27 | from lp.testing import TestCaseWithFactory |
307 | 25 | 28 | ||
308 | 26 | 29 | ||
309 | @@ -248,5 +251,46 @@ | |||
310 | 248 | self.assertContentEqual(builds, i386_builds) | 251 | self.assertContentEqual(builds, i386_builds) |
311 | 249 | 252 | ||
312 | 250 | 253 | ||
313 | 254 | class TestStoreBuildInfo(TestCaseWithFactory): | ||
314 | 255 | |||
315 | 256 | layer = LaunchpadZopelessLayer | ||
316 | 257 | |||
317 | 258 | def setUp(self): | ||
318 | 259 | super(TestStoreBuildInfo, self).setUp() | ||
319 | 260 | self.publisher = SoyuzTestPublisher() | ||
320 | 261 | self.publisher.prepareBreezyAutotest() | ||
321 | 262 | |||
322 | 263 | gedit_src_hist = self.publisher.getPubSource( | ||
323 | 264 | sourcename="gedit", status=PackagePublishingStatus.PUBLISHED) | ||
324 | 265 | self.build = gedit_src_hist.createMissingBuilds()[0] | ||
325 | 266 | |||
326 | 267 | self.builder = self.factory.makeBuilder() | ||
327 | 268 | self.builder.setSlaveForTesting(WaitingSlave('BuildStatus.OK')) | ||
328 | 269 | self.build.buildqueue_record.builder = self.builder | ||
329 | 270 | self.build.buildqueue_record.setDateStarted(UTC_NOW) | ||
330 | 271 | |||
331 | 272 | def testDependencies(self): | ||
332 | 273 | """Verify that storeBuildInfo sets any dependencies.""" | ||
333 | 274 | self.build.storeBuildInfo(None, {'dependencies': 'somepackage'}) | ||
334 | 275 | self.assertIsNot(None, self.build.buildlog) | ||
335 | 276 | self.assertEqual(self.builder, self.build.builder) | ||
336 | 277 | self.assertEqual(u'somepackage', self.build.dependencies) | ||
337 | 278 | self.assertIsNot(None, self.build.datebuilt) | ||
338 | 279 | self.assertIsNot(None, self.build.buildduration) | ||
339 | 280 | |||
340 | 281 | def testWithoutDependencies(self): | ||
341 | 282 | """Verify that storeBuildInfo clears the build's dependencies.""" | ||
342 | 283 | # Set something just to make sure that storeBuildInfo actually | ||
343 | 284 | # empties it. | ||
344 | 285 | self.build.dependencies = u'something' | ||
345 | 286 | |||
346 | 287 | self.build.storeBuildInfo(None, {}) | ||
347 | 288 | self.assertIsNot(None, self.build.buildlog) | ||
348 | 289 | self.assertEqual(self.builder, self.build.builder) | ||
349 | 290 | self.assertIs(None, self.build.dependencies) | ||
350 | 291 | self.assertIsNot(None, self.build.datebuilt) | ||
351 | 292 | self.assertIsNot(None, self.build.buildduration) | ||
352 | 293 | |||
353 | 294 | |||
354 | 251 | def test_suite(): | 295 | def test_suite(): |
355 | 252 | return unittest.TestLoader().loadTestsFromName(__name__) | 296 | return unittest.TestLoader().loadTestsFromName(__name__) |
This branch extends the prerequisite DB branch by adding the new dependencies, upload_log and pocket columns to the SourcePackageRe cipeBuild model class. It also moves Build.storeUplo adLog onto BuildBase, where it can be used by SPRB.
I had to alter BuildBase. storeBuildInfo to explicitly turn the dependencies str into a unicode, since plain Storm is less forgiving than its SQLObject compatibility layer. Since the method didn't appear to be tested anywhere, I've added some unit tests for the dependencies behaviour.