Merge lp:~james-w/launchpad/no-more-sampledata-2 into lp:launchpad
- no-more-sampledata-2
- Merge into devel
Status: | Work in progress |
---|---|
Proposed branch: | lp:~james-w/launchpad/no-more-sampledata-2 |
Merge into: | lp:launchpad |
Prerequisite: | lp:~james-w/launchpad/soyuz-factory-improvements |
Diff against target: |
1355 lines (+305/-266) 15 files modified
lib/lp/archivepublisher/tests/test_publisher.py (+0/-6) lib/lp/archiveuploader/tests/nascentupload-ddebs.txt (+2/-0) lib/lp/soyuz/doc/archive-files.txt (+5/-1) lib/lp/soyuz/doc/packageupload-lookups.txt (+3/-1) lib/lp/soyuz/doc/publishing.txt (+41/-18) lib/lp/soyuz/doc/sourcepackagerelease.txt (+8/-5) lib/lp/soyuz/scripts/tests/test_changeoverride.py (+13/-6) lib/lp/soyuz/scripts/tests/test_copypackage.py (+52/-54) lib/lp/soyuz/scripts/tests/test_publishdistro.py (+5/-13) lib/lp/soyuz/tests/test_binarypackagebuild.py (+3/-3) lib/lp/soyuz/tests/test_publish_archive_indexes.py (+51/-21) lib/lp/soyuz/tests/test_publishing.py (+102/-124) lib/lp/soyuz/tests/test_publishing_top_level_api.py (+0/-2) lib/lp/testing/factory.py (+9/-12) lib/lp/testing/tests/test_factory.py (+11/-0) |
To merge this branch: | bzr merge lp:~james-w/launchpad/no-more-sampledata-2 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jonathan Lange (community) | Approve | ||
Abel Deuring (community) | code | Approve | |
Review via email: mp+31891@code.launchpad.net |
Commit message
The SoyuzTestPublisher now uses the factory. The main difference for now is that you are more likely to get a proxied object from it.
Description of the change
Hi,
Apologies for the bumper branch. Very small changes snowballed
very quickly.
This branch moves SoyuzTestPublisher to back on to the
factory, as a precursor to moving it away from sampledata.
It now runs pretty much the same code inside the factory as it
was running before, and now SoyuzTestPublisher is just a layer
on top of the factory with some conveniences for complex
tests.
The major change is that there are now lots more proxied objects
in soyuz tests, so most of the changes are fallout from that.
There's a lot of removeSecurityProxy involved there, as most of
the problems we in test setup code that is reaching around the
interface to do test set up. I'm not entirely happy that we have
to do that, they should be able to come in by the front door, but
fixing all of that would be too much for one branch.
There's also a bit of having the tests specify the parameters
for the creation of objects where they will assert something
based on that parameter. I didn't do that across the board though.
Plus there are a few drive-by fixes and cleanups as always.
Breakdown of the changes, as not all are immediately obvious. It's perhaps
best to review in reverse order of the changes listed here (odd that bzr
diff gave me the files in roughly reverse order).
lib/lp/
lib/lp/
on the interface.
lib/lp/
requires the extra setup that only used to be done later.
lib/lp/
if there were an appropriate way to do that. It's just set up though, so this has the
same effect.
lib/lp/
what is expected.
lib/lp/
component isn't possible, but you could republish in the new component.
lib/lp/
cleanup, so we don't care.
lib/lp/
version of a publication, which isn't normally allowed.
lib/lp/
interface for test setup.
lib/lp/
listify each of them.
lib/lp/
a case of forcing invalid data in to a field. I also deleted some copy paste comments
that made no sense in the context.
lib/lp/
from the fallout of this due to the proxy.
Thanks,
James
Jonathan Lange (jml) wrote : | # |
James Westby (james-w) wrote : | # |
Thanks for the review.
> Most of the review comments are about dropping calls to sync()
> entirely and adding comments to certain calls to removeSecurityProxy –
> it's good to know why a test feels the need to fiddle with internals.
wgrant said pretty much the same things too, I'm going to take a bit
more time to try and do things more cleanly.
> Also, I feel obliged to include this snippet of a conversation I had
> with Julian, in case they are relevant to this patch or trigger new
> thinking about the no-more-sampledata work you've been doing.
>
> #launchpad-code, 2010-08-03, 16:13-16:19:
> <bigjools> jml: I'm a bit uncomfortable with the factory changes to skip STP
> <jml> bigjools, why so?
> <bigjools> jml: a few reasons. One, because it's not differentiating
> between binary and source publications. Two, someone will want to make
> it do binaries at some point and there will be pain because they're an
> order of magnitiude more complicated to set up, and three, the STP
> relies on sample data because there's a load of publisher config in it
> which is not being set up in the factory methods so you can end up
> with data
> <bigjools> that can't exist in the real world.
> <bigjools> and probably more problems if I look harder
> <bigjools> not insurmountable of course, but nonetheless the problems exist
I saw this conversation. I'm keen to solve these problems such that the
factory is sufficient, but I don't know of many concrete cases where the
sampledata is different, one of the problems of sampledata.
One thing I know is that lucilleconfig isn't set on factory created
distributions and distroseries, and I am working on a way to deal
with that. That's an issue where your tests won't run, rather than
testing the wrong thing though.
Thanks,
James
Abel Deuring (adeuring) wrote : | # |
Hi James,
again, a nice branch!
Just one minor remark:
> @@ -540,7 +518,8 @@
> for pub in pubs:
> self.checkPastD
> if supersededby is not None:
> - if isinstance(pub, BinaryPackagePu
> + if isinstance(
> + removeSecurityP
> dominant = supersededby.
> else:
> dominant = supersededby.
I think this is one occasion where you don't need to call removeSecurityP
Francis J. Lacoste (flacoste) wrote : | # |
On August 6, 2010, Abel Deuring wrote:
> Review: Approve code
> Hi James,
>
> again, a nice branch!
>
> Just one minor remark:
> > @@ -540,7 +518,8 @@
> >
> > for pub in pubs:
> > self.checkPastD
> >
> > if supersededby is not None:
> > - if isinstance(pub, BinaryPackagePu
> > + if isinstance(
> >
> > + removeSecurityP
BinaryPackagePu
> > dominant = supersededby.
> >
> > else:
> > dominant = supersededby.
>
> I think this is one occasion where you don't need to call
> removeSecurityP
> isinstance() so that a possibly existing security proxy is removed before
> the "real" isinstance function is called.
It doesn't monkeypatch by default, but it is common to shadow it by importing
from zope.security.proxy import isinstance
And that one will do the right thing.
--
Francis J. Lacoste
<email address hidden>
- 11319. By James Westby
-
Merged soyuz-factory-
improvements into no-more- sampledata- 2. - 11320. By James Westby
-
Drop all the calls to sync, as they are now unnecessary.
- 11321. By James Westby
-
Document why we rSP the package diff.
- 11322. By James Westby
-
Avoid rSP by logging in as the owner.
- 11323. By James Westby
-
Avoid an rSP by passing dsc_binaries to getPubSource.
- 11324. By James Westby
-
Remove more uses of rSP by changing the setup to allow specifying the needed values.
Also use zope's isinstance rather than the builtin one to avoid the proxy.
- 11325. By James Westby
-
Comment why we are calling removeSecurityProxy when printing.
- 11326. By James Westby
-
Avoid changing the purpose of an existing archive.
- 11327. By James Westby
-
Avoid another rSP by improving the test publisher.
Also add a couple of comments where rSP is unavoidable.
- 11328. By James Westby
-
Remove the last of the rSP with some reorganisation.
- 11329. By James Westby
-
Damn, missed one that required a comment.
James Westby (james-w) wrote : | # |
Hi,
Please review again.
All should be much rosier now.
Some of the changes are now more complex, as I opted to
restructure some things rather than using
removeSecurityP
Thanks,
James
- 11330. By James Westby
-
Merge devel.
Jonathan Lange (jml) wrote : | # |
Looks good. There are a few comments that aren't correctly punctuated sentences, but since I don't care enough to enumerate them, you needn't bother to fix them. :)
- 11331. By James Westby
-
Merge devel.
- 11332. By James Westby
-
Merge improve-
soyuz-factory in to no-more- sampledata- 2.
Brad Crittenden (bac) wrote : | # |
James is this branch ready to land? Is there any way I can assist you in landing the several approved branches?
Unmerged revisions
- 11332. By James Westby
-
Merge improve-
soyuz-factory in to no-more- sampledata- 2. - 11331. By James Westby
-
Merge devel.
- 11330. By James Westby
-
Merge devel.
- 11329. By James Westby
-
Damn, missed one that required a comment.
- 11328. By James Westby
-
Remove the last of the rSP with some reorganisation.
- 11327. By James Westby
-
Avoid another rSP by improving the test publisher.
Also add a couple of comments where rSP is unavoidable.
- 11326. By James Westby
-
Avoid changing the purpose of an existing archive.
- 11325. By James Westby
-
Comment why we are calling removeSecurityProxy when printing.
- 11324. By James Westby
-
Remove more uses of rSP by changing the setup to allow specifying the needed values.
Also use zope's isinstance rather than the builtin one to avoid the proxy.
- 11323. By James Westby
-
Avoid an rSP by passing dsc_binaries to getPubSource.
Preview Diff
1 | === modified file 'lib/lp/archivepublisher/tests/test_publisher.py' |
2 | --- lib/lp/archivepublisher/tests/test_publisher.py 2010-07-22 08:19:27 +0000 |
3 | +++ lib/lp/archivepublisher/tests/test_publisher.py 2010-08-16 22:07:55 +0000 |
4 | @@ -83,7 +83,6 @@ |
5 | publisher.A_publish(False) |
6 | self.layer.txn.commit() |
7 | |
8 | - pub_source.sync() |
9 | self.assertDirtyPocketsContents( |
10 | [('breezy-autotest', 'RELEASE')], publisher.dirty_pockets) |
11 | self.assertEqual(pub_source.status, PackagePublishingStatus.PUBLISHED) |
12 | @@ -226,8 +225,6 @@ |
13 | publisher.A_publish(force_publishing=False) |
14 | self.layer.txn.commit() |
15 | |
16 | - pub_source.sync() |
17 | - pub_source2.sync() |
18 | self.assertDirtyPocketsContents( |
19 | [('hoary-test', 'RELEASE')], publisher.dirty_pockets) |
20 | self.assertEqual(pub_source2.status, |
21 | @@ -259,8 +256,6 @@ |
22 | publisher.A_publish(force_publishing=False) |
23 | self.layer.txn.commit() |
24 | |
25 | - pub_source.sync() |
26 | - pub_source2.sync() |
27 | self.assertDirtyPocketsContents( |
28 | [('breezy-autotest', 'UPDATES')], publisher.dirty_pockets) |
29 | self.assertEqual(pub_source.status, PackagePublishingStatus.PUBLISHED) |
30 | @@ -360,7 +355,6 @@ |
31 | publisher.A_publish(False) |
32 | self.layer.txn.commit() |
33 | |
34 | - pub_source.sync() |
35 | self.assertDirtyPocketsContents( |
36 | [('breezy-autotest', 'RELEASE')], publisher.dirty_pockets) |
37 | self.assertEqual(pub_source.status, PackagePublishingStatus.PUBLISHED) |
38 | |
39 | === modified file 'lib/lp/archiveuploader/tests/nascentupload-ddebs.txt' |
40 | --- lib/lp/archiveuploader/tests/nascentupload-ddebs.txt 2010-07-21 08:07:08 +0000 |
41 | +++ lib/lp/archiveuploader/tests/nascentupload-ddebs.txt 2010-08-16 22:07:55 +0000 |
42 | @@ -15,6 +15,8 @@ |
43 | |
44 | >>> from lp.soyuz.tests.test_publishing import ( |
45 | ... SoyuzTestPublisher) |
46 | + >>> from canonical.config import config |
47 | + >>> from canonical.testing import LaunchpadZopelessLayer |
48 | |
49 | >>> test_publisher = SoyuzTestPublisher() |
50 | |
51 | |
52 | === modified file 'lib/lp/soyuz/doc/archive-files.txt' |
53 | --- lib/lp/soyuz/doc/archive-files.txt 2010-07-21 11:06:37 +0000 |
54 | +++ lib/lp/soyuz/doc/archive-files.txt 2010-08-16 22:07:55 +0000 |
55 | @@ -143,9 +143,13 @@ |
56 | >>> print another_test_source.sourcepackagerelease.package_diffs.count() |
57 | 1 |
58 | |
59 | +We don't care about having a realistic diff for the two packages, for this |
60 | +test, and getting one through the normal means would be expensive, so |
61 | +we'll take a shortcut and set the content to be a dummy file. |
62 | + |
63 | >>> diff_name = 'test-pkg_1.0_1.1.diff.gz' |
64 | >>> diff = test_publisher.addMockFile(diff_name) |
65 | - >>> package_diff.diff_content = diff |
66 | + >>> removeSecurityProxy(package_diff).diff_content = diff |
67 | |
68 | >>> diff == cprov.archive.getFileByName(diff_name) |
69 | True |
70 | |
71 | === modified file 'lib/lp/soyuz/doc/packageupload-lookups.txt' |
72 | --- lib/lp/soyuz/doc/packageupload-lookups.txt 2010-03-06 04:57:40 +0000 |
73 | +++ lib/lp/soyuz/doc/packageupload-lookups.txt 2010-08-16 22:07:55 +0000 |
74 | @@ -98,6 +98,7 @@ |
75 | # Create a testing source and its binaries in |
76 | # ubuntutest/breezy-autotest/i386. |
77 | >>> from lp.soyuz.tests.test_publishing import SoyuzTestPublisher |
78 | + >>> from zope.security.proxy import removeSecurityProxy |
79 | >>> login('foo.bar@canonical.com') |
80 | >>> test_publisher = SoyuzTestPublisher() |
81 | >>> test_publisher.prepareBreezyAutotest() |
82 | @@ -112,7 +113,8 @@ |
83 | The `SourcePackageRelease` 'package_upload' and 'upload_changesfile' |
84 | |
85 | >>> original_source_upload = source.sourcepackagerelease.package_upload |
86 | - >>> print original_source_upload |
87 | + >>> # avoid the __repr__ of the security proxy |
88 | + >>> print removeSecurityProxy(original_source_upload) |
89 | <PackageUpload ...> |
90 | |
91 | >>> source_changesfile = source.sourcepackagerelease.upload_changesfile |
92 | |
93 | === modified file 'lib/lp/soyuz/doc/publishing.txt' |
94 | --- lib/lp/soyuz/doc/publishing.txt 2010-07-12 03:14:42 +0000 |
95 | +++ lib/lp/soyuz/doc/publishing.txt 2010-08-16 22:07:55 +0000 |
96 | @@ -2,10 +2,11 @@ |
97 | SourcePackagePublishingHistory |
98 | ============================== |
99 | |
100 | -This class provides public access to publishing records via a SQL view. |
101 | +This class provides public access to publishing records. |
102 | |
103 | - >>> from canonical.launchpad.database import SourcePackagePublishingHistory |
104 | - >>> from canonical.launchpad.database import BinaryPackagePublishingHistory |
105 | + >>> from lp.soyuz.model.publishing import ( |
106 | + ... BinaryPackagePublishingHistory, SourcePackagePublishingHistory) |
107 | + >>> from zope.security.proxy import removeSecurityProxy |
108 | |
109 | Select a publishing record from the sampledata (pmount is a |
110 | interesting one): |
111 | @@ -172,17 +173,36 @@ |
112 | a rebuild archive then the status summary will always display |
113 | FULLY_BUILT. |
114 | |
115 | +Create a COPY archive that will build for hppa and i386. |
116 | + |
117 | >>> from lp.soyuz.interfaces.archive import ArchivePurpose |
118 | - >>> spph.archive.purpose = ArchivePurpose.COPY |
119 | - >>> build_status_summary = spph.getStatusSummaryForBuilds() |
120 | + >>> from lp.soyuz.interfaces.archivearch import IArchiveArchSet |
121 | + >>> from lp.soyuz.interfaces.processor import IProcessorFamilySet |
122 | + >>> archive = factory.makeArchive( |
123 | + ... purpose=ArchivePurpose.COPY, |
124 | + ... distribution=test_publisher.ubuntutest, |
125 | + ... virtualized=False) |
126 | + >>> processor_family = getUtility(IProcessorFamilySet).getByName('hppa') |
127 | + >>> archive_arch_set = getUtility(IArchiveArchSet).new( |
128 | + ... archive, processor_family) |
129 | + |
130 | +Publish a source to it, create the builds and mark them fully built. |
131 | + |
132 | + >>> copy_spph = test_publisher.getPubSource( |
133 | + ... sourcename="abc", version="666", archive=archive, |
134 | + ... architecturehintlist='any') |
135 | + >>> copy_builds = copy_spph.createMissingBuilds() |
136 | + >>> for build in copy_builds: |
137 | + ... build.status = BuildStatus.FULLYBUILT |
138 | + |
139 | +The check that the status summary marks all builds as FULLYBUILT. |
140 | + |
141 | + >>> build_status_summary = copy_spph.getStatusSummaryForBuilds() |
142 | >>> print_build_status_summary(build_status_summary) |
143 | FULLYBUILT |
144 | hppa build of abc 666 in ubuntutest breezy-autotest RELEASE |
145 | i386 build of abc 666 in ubuntutest breezy-autotest RELEASE |
146 | |
147 | - # Just set the purpose back before continuing on. |
148 | - >>> spph.archive.purpose = ArchivePurpose.PRIMARY |
149 | - |
150 | If one of the builds becomes published, it will not appear in the summary: |
151 | |
152 | >>> from lp.soyuz.interfaces.publishing import ( |
153 | @@ -779,8 +799,10 @@ |
154 | This simulates a rebuild in of the same source in a more recent |
155 | distroseries, like rebuilding SRUs for constant sources. |
156 | |
157 | - >>> breezy_autotest.parent_series = None |
158 | - >>> hoary_test.parent_series = breezy_autotest |
159 | + >>> # removeSecurityProxy is required as no-one normally has the |
160 | + >>> # permission to do this |
161 | + >>> removeSecurityProxy(breezy_autotest).parent_series = None |
162 | + >>> removeSecurityProxy(hoary_test).parent_series = breezy_autotest |
163 | |
164 | >>> ppa_source.createMissingBuilds() |
165 | [] |
166 | @@ -791,8 +813,10 @@ |
167 | Now, let's check the opposite, as if the copy was from a more recent |
168 | distroseries to a older one, like a backport rebuild. |
169 | |
170 | - >>> breezy_autotest.parent_series = hoary_test |
171 | - >>> hoary_test.parent_series = None |
172 | + >>> # removeSecurityProxy is required as no-one normally has the |
173 | + >>> # permission to do this |
174 | + >>> removeSecurityProxy(breezy_autotest).parent_series = hoary_test |
175 | + >>> removeSecurityProxy(hoary_test).parent_series = None |
176 | |
177 | >>> ppa_source.createMissingBuilds() |
178 | [] |
179 | @@ -1064,7 +1088,7 @@ |
180 | main |
181 | |
182 | >>> test_bin_pubs = test_publisher.getPubBinaries( |
183 | - ... pub_source=test_source_pub) |
184 | + ... pub_source=test_source_pub, component='universe') |
185 | >>> test_bin_pub = test_bin_pubs[0] |
186 | >>> ppa_pub = publishing_set.newBinaryPublication( |
187 | ... archive=mark.archive, |
188 | @@ -1330,7 +1354,6 @@ |
189 | |
190 | >>> diff_file = getUtility(ILibraryFileAliasSet)[1] |
191 | |
192 | - >>> from zope.security.proxy import removeSecurityProxy |
193 | >>> naked_diff = removeSecurityProxy(pmount_diff) |
194 | >>> naked_diff.diff_content = diff_file |
195 | >>> flush_database_updates() |
196 | @@ -1810,7 +1833,10 @@ |
197 | ... sourcename='testing', version='2.0', component='universe', |
198 | ... architecturehintlist='i386') |
199 | >>> test_binary = test_publisher.getPubBinaries( |
200 | - ... binaryname='testing-bin', pub_source=test_source)[0] |
201 | + ... binaryname='testing-bin', pub_source=test_source, |
202 | + ... component='multiverse')[0] |
203 | + >>> test_binary = test_binary.changeOverride( |
204 | + ... new_component=factory.makeComponent(name='universe')) |
205 | |
206 | We will create a helper function to inspect ancestries. It simply pass |
207 | any given keyword argument to 'test_source' and 'test_binary' |
208 | @@ -1876,9 +1902,6 @@ |
209 | |
210 | It works in the same way for binaries. |
211 | |
212 | - >>> multiverse = getUtility(IComponentSet)['multiverse'] |
213 | - >>> test_binary.binarypackagerelease.component = multiverse |
214 | - |
215 | >>> print test_binary.component.name |
216 | universe |
217 | |
218 | |
219 | === modified file 'lib/lp/soyuz/doc/sourcepackagerelease.txt' |
220 | --- lib/lp/soyuz/doc/sourcepackagerelease.txt 2010-05-19 15:39:52 +0000 |
221 | +++ lib/lp/soyuz/doc/sourcepackagerelease.txt 2010-08-16 22:07:55 +0000 |
222 | @@ -14,6 +14,7 @@ |
223 | |
224 | Let's get one from the database: |
225 | |
226 | + >>> from __future__ import with_statement |
227 | >>> from canonical.launchpad.database import SourcePackageRelease |
228 | >>> spr = SourcePackageRelease.get(14) |
229 | >>> spr.name |
230 | @@ -196,10 +197,10 @@ |
231 | |
232 | >>> new_spr = hoary.createUploadedSourcePackageRelease( |
233 | ... arg_name, version, arg_maintainer, |
234 | - ... builddepends, builddependsindep, archhintlist, arg_comp, arg_creator, |
235 | - ... arg_urgency, changelog, changelog_entry, dsc, arg_key, arg_sect, |
236 | - ... dsc_maintainer_rfc822, dsc_standards_version, dsc_format, |
237 | - ... dsc_binaries, archive, copyright=copyright, |
238 | + ... builddepends, builddependsindep, archhintlist, arg_comp, |
239 | + ... arg_creator, arg_urgency, changelog, changelog_entry, dsc, |
240 | + ... arg_key, arg_sect, dsc_maintainer_rfc822, dsc_standards_version, |
241 | + ... dsc_format, dsc_binaries, archive, copyright=copyright, |
242 | ... build_conflicts=None, build_conflicts_indep=None, |
243 | ... source_package_recipe_build=arg_recipebuild) |
244 | |
245 | @@ -349,7 +350,9 @@ |
246 | private PPA, it gets deleted from that private PPA. At this point the |
247 | package is still public: |
248 | |
249 | - >>> private_publication.requestDeletion(cprov) |
250 | + >>> from lp.testing import person_logged_in |
251 | + >>> with person_logged_in(cprov): |
252 | + ... private_publication.requestDeletion(cprov) |
253 | >>> transaction.commit() |
254 | >>> login('no-priv@canonical.com') |
255 | >>> check_permission('launchpad.View', test_sourcepackagerelease) |
256 | |
257 | === modified file 'lib/lp/soyuz/scripts/tests/test_changeoverride.py' |
258 | --- lib/lp/soyuz/scripts/tests/test_changeoverride.py 2010-07-20 12:06:36 +0000 |
259 | +++ lib/lp/soyuz/scripts/tests/test_changeoverride.py 2010-08-16 22:07:55 +0000 |
260 | @@ -14,7 +14,8 @@ |
261 | from canonical.launchpad.interfaces.librarian import ILibraryFileAliasSet |
262 | from lp.registry.interfaces.person import IPersonSet |
263 | from lp.registry.interfaces.pocket import PackagePublishingPocket |
264 | -from lp.soyuz.interfaces.publishing import PackagePublishingPriority |
265 | +from lp.soyuz.interfaces.publishing import ( |
266 | + PackagePublishingPriority, PackagePublishingStatus) |
267 | from lp.soyuz.interfaces.section import ISectionSet |
268 | from canonical.launchpad.scripts import FakeLogger |
269 | from lp.soyuz.scripts.changeoverride import ( |
270 | @@ -252,18 +253,24 @@ |
271 | * 'boingo-data' binaries PENDING in warty i386 & hppa. |
272 | """ |
273 | source = self.test_publisher.getPubSource( |
274 | - sourcename="boingo", version='1.0', distroseries=self.warty) |
275 | + sourcename="boingo", version='1.0', distroseries=self.warty, |
276 | + component="main", section="base", |
277 | + status=PackagePublishingStatus.PENDING) |
278 | |
279 | binaries = self.test_publisher.getPubBinaries( |
280 | - 'boingo-bin', pub_source=source, distroseries=self.warty) |
281 | + 'boingo-bin', pub_source=source, distroseries=self.warty, |
282 | + version="1.0", component="main", section="base", |
283 | + priority=PackagePublishingPriority.STANDARD, |
284 | + status=PackagePublishingStatus.PENDING) |
285 | |
286 | build = binaries[0].binarypackagerelease.build |
287 | other_binary = self.test_publisher.uploadBinaryForBuild( |
288 | - build, 'boingo-data') |
289 | - other_binary.version = '0.9' |
290 | + build, 'boingo-data', version='0.9') |
291 | binaries.extend( |
292 | self.test_publisher.publishBinaryInArchive( |
293 | - other_binary, source.archive)) |
294 | + other_binary, source.archive, section="base", |
295 | + priority=PackagePublishingPriority.STANDARD, |
296 | + status=PackagePublishingStatus.PENDING)) |
297 | |
298 | def test_changeoverride_operations(self): |
299 | """Check if `IArchivePublisher.changeOverride` is wrapped correctly. |
300 | |
301 | === modified file 'lib/lp/soyuz/scripts/tests/test_copypackage.py' |
302 | --- lib/lp/soyuz/scripts/tests/test_copypackage.py 2010-07-20 12:06:36 +0000 |
303 | +++ lib/lp/soyuz/scripts/tests/test_copypackage.py 2010-08-16 22:07:55 +0000 |
304 | @@ -654,6 +654,24 @@ |
305 | self.test_publisher = SoyuzTestPublisher() |
306 | self.test_publisher.prepareBreezyAutotest() |
307 | |
308 | + def makeTargetArchive(self): |
309 | + return self.factory.makeArchive( |
310 | + distribution=self.test_publisher.ubuntutest, |
311 | + purpose=ArchivePurpose.PPA) |
312 | + |
313 | + def test_checkCopy_can_copy_unexpired_binaries(self): |
314 | + source = self.test_publisher.getPubSource() |
315 | + binaries = self.test_publisher.getPubBinaries(pub_source=source) |
316 | + archive = self.makeTargetArchive() |
317 | + series = source.distroseries |
318 | + pocket = source.pocket |
319 | + copy_checker = CopyChecker(archive, include_binaries=False) |
320 | + self.assertIs( |
321 | + None, copy_checker.checkCopy(source, series, pocket)) |
322 | + copy_checker = CopyChecker(archive, include_binaries=True) |
323 | + self.assertIs( |
324 | + None, copy_checker.checkCopy(source, series, pocket)) |
325 | + |
326 | def test_checkCopy_cannot_copy_expired_binaries(self): |
327 | # checkCopy() raises CannotCopy if the copy includes binaries |
328 | # and the binaries contain expired files. Publications of |
329 | @@ -661,30 +679,14 @@ |
330 | # the file is unreachable. |
331 | |
332 | # Create a testing source and binaries. |
333 | + old_date = datetime.datetime(1970, 1, 1, tzinfo=pytz.UTC) |
334 | source = self.test_publisher.getPubSource() |
335 | - binaries = self.test_publisher.getPubBinaries(pub_source=source) |
336 | - |
337 | - # Create a fresh PPA which will be the destination copy. |
338 | - archive = self.factory.makeArchive( |
339 | - distribution=self.test_publisher.ubuntutest, |
340 | - purpose=ArchivePurpose.PPA) |
341 | + binaries = self.test_publisher.getPubBinaries( |
342 | + pub_source=source, files_expire=old_date) |
343 | + archive = self.makeTargetArchive() |
344 | series = source.distroseries |
345 | pocket = source.pocket |
346 | |
347 | - # At this point copy is allowed with or without binaries. |
348 | - copy_checker = CopyChecker(archive, include_binaries=False) |
349 | - self.assertIs( |
350 | - None, copy_checker.checkCopy(source, series, pocket)) |
351 | - copy_checker = CopyChecker(archive, include_binaries=True) |
352 | - self.assertIs( |
353 | - None, copy_checker.checkCopy(source, series, pocket)) |
354 | - |
355 | - # Set the expiration date of one of the testing binary files. |
356 | - utc = pytz.timezone('UTC') |
357 | - old_date = datetime.datetime(1970, 1, 1, tzinfo=utc) |
358 | - a_binary_file = binaries[0].binarypackagerelease.files[0] |
359 | - a_binary_file.libraryfile.expires = old_date |
360 | - |
361 | # Now source-only copies are allowed. |
362 | copy_checker = CopyChecker(archive, include_binaries=False) |
363 | self.assertIs( |
364 | @@ -702,20 +704,13 @@ |
365 | # source that contain expired files. Publications of expired |
366 | # files can't be processed by the publisher since the file is |
367 | # unreachable. |
368 | - source = self.test_publisher.getPubSource() |
369 | - |
370 | - archive = self.factory.makeArchive( |
371 | - distribution=self.test_publisher.ubuntutest, |
372 | - purpose=ArchivePurpose.PPA) |
373 | + expire = datetime.datetime.now( |
374 | + pytz.UTC) + datetime.timedelta(days=365) |
375 | + source = self.test_publisher.getPubSource( |
376 | + files_expire=expire) |
377 | + archive = self.makeTargetArchive() |
378 | series = source.distroseries |
379 | pocket = source.pocket |
380 | - |
381 | - utc = pytz.timezone('UTC') |
382 | - expire = datetime.datetime.now(utc) + datetime.timedelta(days=365) |
383 | - |
384 | - a_source_file = source.sourcepackagerelease.files[0] |
385 | - a_source_file.libraryfile.expires = expire |
386 | - |
387 | copy_checker = CopyChecker(archive, include_binaries=False) |
388 | self.assertRaisesWithContent( |
389 | CannotCopy, |
390 | @@ -974,7 +969,7 @@ |
391 | self.test_publisher.breezy_autotest.status = ( |
392 | SeriesStatus.CURRENT) |
393 | |
394 | - def createDelayedCopyContext(self): |
395 | + def createDelayedCopyContext(self, component='main'): |
396 | """Create a context to allow delayed-copies test. |
397 | |
398 | The returned source publication in a private archive with |
399 | @@ -986,7 +981,8 @@ |
400 | ppa.buildd_secret = 'x' |
401 | ppa.private = True |
402 | |
403 | - source = self.test_publisher.createSource(ppa, 'foocomm', '1.0-2') |
404 | + source = self.test_publisher.createSource( |
405 | + ppa, 'foocomm', '1.0-2', component=component) |
406 | self.test_publisher.getPubBinaries(pub_source=source) |
407 | |
408 | [build] = source.getBuilds() |
409 | @@ -1060,14 +1056,13 @@ |
410 | overridden when uploaded to the PPA, but when copying it to another |
411 | archive, only the ancestry in the destination archive can be used. |
412 | If that ancestry doesn't exist, an exception is raised.""" |
413 | - # We'll simulate an upload that was overridden to main in the |
414 | - # ppa, by explicitly setting the spr's and bpr's component to |
415 | - # something else. |
416 | - source = self.createDelayedCopyContext() |
417 | - contrib = getUtility(IComponentSet).new('contrib') |
418 | - source.sourcepackagerelease.component = contrib |
419 | + # Upload to contrib, with automatic override to main due |
420 | + # to it being a PPA. |
421 | + source = self.createDelayedCopyContext(component='contrib') |
422 | + # But then override in to main, like a PPA would |
423 | [build] = source.getBuilds() |
424 | [binary] = build.binarypackages |
425 | + contrib = self.factory.makeComponent(name="contrib") |
426 | binary.override(component=contrib) |
427 | self.layer.txn.commit() |
428 | |
429 | @@ -1084,14 +1079,12 @@ |
430 | archive, only the ancestry in the destination archive can be used. |
431 | If an ancestor is found in the destination archive, its component |
432 | is assumed for this package upload.""" |
433 | - # We'll simulate an upload that was overridden to main in the |
434 | - # ppa, by explicitly setting the spr's and bpr's component to |
435 | - # something else. |
436 | - source = self.createDelayedCopyContext() |
437 | - contrib = getUtility(IComponentSet).new('contrib') |
438 | - source.sourcepackagerelease.component = contrib |
439 | + # Upload to contrib, with automatic override to main due |
440 | + # to it being a PPA. |
441 | + source = self.createDelayedCopyContext(component='contrib') |
442 | [build] = source.getBuilds() |
443 | [binary] = build.binarypackages |
444 | + contrib = self.factory.makeComponent(name='contrib') |
445 | binary.override(component=contrib) |
446 | |
447 | # This time, we'll ensure that there is already an ancestor for |
448 | @@ -2234,7 +2227,16 @@ |
449 | test_publisher.addFakeChroots(warty) |
450 | ppa_binaries = test_publisher.getPubBinaries( |
451 | pub_source=ppa_source, distroseries=warty, |
452 | - status=PackagePublishingStatus.PUBLISHED) |
453 | + status=PackagePublishingStatus.PUBLISHED, |
454 | + component='universe') |
455 | + |
456 | + # Override the ppa binaries to main, like a PPA would |
457 | + new_ppa_binaries = [] |
458 | + main = self.factory.makeComponent(name="main") |
459 | + for binary in ppa_binaries: |
460 | + new_ppa_binaries.append( |
461 | + binary.changeOverride(new_component=main)) |
462 | + ppa_binaries = new_ppa_binaries |
463 | |
464 | # Give the new source a private package diff. |
465 | sourcepackagerelease = other_source.sourcepackagerelease |
466 | @@ -2263,10 +2265,6 @@ |
467 | universe = getUtility(IComponentSet)['universe'] |
468 | ancestry_source.component = universe |
469 | |
470 | - # Override the copied binarypackagerelease to 'universe'. |
471 | - for binary in ppa_binaries: |
472 | - binary.binarypackagerelease.component = universe |
473 | - |
474 | self.layer.txn.commit() |
475 | |
476 | # Now we can invoke the unembargo script and check its results. |
477 | @@ -2364,9 +2362,9 @@ |
478 | sourcename='buggy-source', version=version, |
479 | distroseries=warty, archive=archive, pocket=pocket, |
480 | changes_file_content=changes_file_content, |
481 | - status=PackagePublishingStatus.PUBLISHED) |
482 | - source.sourcepackagerelease.changelog_entry = ( |
483 | - "Required for close_bugs_for_sourcepublication") |
484 | + status=PackagePublishingStatus.PUBLISHED, |
485 | + changelog_entry="Required for " |
486 | + "close_bugs_for_sourcepublication") |
487 | binaries = test_publisher.getPubBinaries( |
488 | pub_source=source, distroseries=warty, archive=archive, |
489 | pocket=pocket, status=PackagePublishingStatus.PUBLISHED) |
490 | |
491 | === modified file 'lib/lp/soyuz/scripts/tests/test_publishdistro.py' |
492 | --- lib/lp/soyuz/scripts/tests/test_publishdistro.py 2010-03-09 07:29:18 +0000 |
493 | +++ lib/lp/soyuz/scripts/tests/test_publishdistro.py 2010-08-16 22:07:55 +0000 |
494 | @@ -72,7 +72,6 @@ |
495 | |
496 | rc, out, err = self.runPublishDistroScript() |
497 | |
498 | - pub_source.sync() |
499 | self.assertEqual(0, rc, "Publisher failed with:\n%s\n%s" % (out, err)) |
500 | self.assertEqual(pub_source.status, PackagePublishingStatus.PUBLISHED) |
501 | |
502 | @@ -88,7 +87,6 @@ |
503 | pub_source = self.getPubSource(filecontent='foo') |
504 | self.layer.txn.commit() |
505 | self.runPublishDistro() |
506 | - pub_source.sync() |
507 | |
508 | random_person = getUtility(IPersonSet).getByName('name16') |
509 | pub_source.requestDeletion(random_person) |
510 | @@ -96,7 +94,6 @@ |
511 | self.assertTrue(pub_source.scheduleddeletiondate is None, |
512 | "pub_source.scheduleddeletiondate should not be set, and it is.") |
513 | self.runPublishDistro() |
514 | - pub_source.sync() |
515 | self.assertTrue(pub_source.scheduleddeletiondate is not None, |
516 | "pub_source.scheduleddeletiondate should be set, and it's not.") |
517 | |
518 | @@ -123,8 +120,6 @@ |
519 | |
520 | self.runPublishDistro(['-s', 'hoary-test']) |
521 | |
522 | - pub_source.sync() |
523 | - pub_source2.sync() |
524 | self.assertEqual(pub_source.status, PackagePublishingStatus.PENDING) |
525 | self.assertEqual( |
526 | pub_source2.status, PackagePublishingStatus.PUBLISHED) |
527 | @@ -212,9 +207,6 @@ |
528 | |
529 | self.runPublishDistro(['--ppa']) |
530 | |
531 | - pub_source.sync() |
532 | - pub_source2.sync() |
533 | - pub_source3.sync() |
534 | self.assertEqual(pub_source.status, PackagePublishingStatus.PENDING) |
535 | self.assertEqual( |
536 | pub_source2.status, PackagePublishingStatus.PUBLISHED) |
537 | @@ -246,21 +238,19 @@ |
538 | private=True, distribution=ubuntutest) |
539 | |
540 | # Publish something to the private PPA: |
541 | - pub_source = self.getPubSource( |
542 | + pub_source = self.getPubSource( |
543 | sourcename='baz', filecontent='baz', archive=private_ppa) |
544 | self.layer.txn.commit() |
545 | |
546 | # Try a plain PPA run, to ensure the private one is NOT published. |
547 | self.runPublishDistro(['--ppa']) |
548 | |
549 | - pub_source.sync() |
550 | self.assertEqual(pub_source.status, PackagePublishingStatus.PENDING) |
551 | |
552 | # Now publish the private PPAs and make sure they are really |
553 | # published. |
554 | self.runPublishDistro(['--private-ppa']) |
555 | |
556 | - pub_source.sync() |
557 | self.assertEqual(pub_source.status, PackagePublishingStatus.PUBLISHED) |
558 | |
559 | def testPublishPrimaryDebug(self): |
560 | @@ -288,8 +278,10 @@ |
561 | # operation, see nascentupload-ddebs.txt. |
562 | self.prepareBreezyAutotest() |
563 | pub_binaries = self.getPubBinaries(format=BinaryPackageFormat.DDEB) |
564 | + # changing the archive of a publication is not normally |
565 | + # possible, so we have to use removeSecurityProxy. |
566 | for binary in pub_binaries: |
567 | - binary.archive = debug_archive |
568 | + removeSecurityProxy(binary).archive = debug_archive |
569 | |
570 | # Commit setup changes, so the script can operate on them. |
571 | self.layer.txn.commit() |
572 | @@ -330,7 +322,7 @@ |
573 | removeSecurityProxy(copy_archive).publish = True |
574 | |
575 | # Publish something. |
576 | - pub_source = self.getPubSource( |
577 | + pub_source = self.getPubSource( |
578 | sourcename='baz', filecontent='baz', archive=copy_archive) |
579 | |
580 | # Try a plain PPA run, to ensure the copy archive is not published. |
581 | |
582 | === modified file 'lib/lp/soyuz/tests/test_binarypackagebuild.py' |
583 | --- lib/lp/soyuz/tests/test_binarypackagebuild.py 2010-08-04 13:30:49 +0000 |
584 | +++ lib/lp/soyuz/tests/test_binarypackagebuild.py 2010-08-16 22:07:55 +0000 |
585 | @@ -314,18 +314,18 @@ |
586 | self.sources = [] |
587 | gedit_src_hist = self.publisher.getPubSource( |
588 | sourcename="gedit", status=PackagePublishingStatus.PUBLISHED) |
589 | - self.builds += gedit_src_hist.createMissingBuilds() |
590 | + self.builds += list(gedit_src_hist.createMissingBuilds()) |
591 | self.sources.append(gedit_src_hist) |
592 | |
593 | firefox_src_hist = self.publisher.getPubSource( |
594 | sourcename="firefox", status=PackagePublishingStatus.PUBLISHED) |
595 | - self.builds += firefox_src_hist.createMissingBuilds() |
596 | + self.builds += list(firefox_src_hist.createMissingBuilds()) |
597 | self.sources.append(firefox_src_hist) |
598 | |
599 | gtg_src_hist = self.publisher.getPubSource( |
600 | sourcename="getting-things-gnome", |
601 | status=PackagePublishingStatus.PUBLISHED) |
602 | - self.builds += gtg_src_hist.createMissingBuilds() |
603 | + self.builds += list(gtg_src_hist.createMissingBuilds()) |
604 | self.sources.append(gtg_src_hist) |
605 | |
606 | |
607 | |
608 | === modified file 'lib/lp/soyuz/tests/test_publish_archive_indexes.py' |
609 | --- lib/lp/soyuz/tests/test_publish_archive_indexes.py 2010-07-20 12:06:36 +0000 |
610 | +++ lib/lp/soyuz/tests/test_publish_archive_indexes.py 2010-08-16 22:07:55 +0000 |
611 | @@ -8,6 +8,10 @@ |
612 | import tempfile |
613 | import unittest |
614 | |
615 | +from zope.security.proxy import removeSecurityProxy |
616 | + |
617 | +from lp.soyuz.interfaces.binarypackagerelease import BinaryPackageFormat |
618 | +from lp.soyuz.interfaces.publishing import PackagePublishingPriority |
619 | from lp.soyuz.tests.test_publishing import TestNativePublishingBase |
620 | |
621 | |
622 | @@ -31,8 +35,14 @@ |
623 | the package in question. |
624 | """ |
625 | pub_source = self.getPubSource( |
626 | + sourcename='foo', dsc_binaries='foo-bin', |
627 | + version='666', section='base', |
628 | builddepends='fooish', builddependsindep='pyfoo', |
629 | - build_conflicts='bar', build_conflicts_indep='pybar') |
630 | + build_conflicts='bar', build_conflicts_indep='pybar', |
631 | + dsc_maintainer_rfc822='Foo Bar <foo@bar.com>', |
632 | + architecturehintlist='all', dsc_standards_version='3.6.2', |
633 | + dsc_format='1.0', filename='foo_666.dsc', |
634 | + filecontent='I do not care about sources.') |
635 | |
636 | self.assertEqual( |
637 | [u'Package: foo', |
638 | @@ -52,16 +62,29 @@ |
639 | u' 5913c3ad52c14a62e6ae7eef51f9ef42 28 foo_666.dsc'], |
640 | pub_source.getIndexStanza().splitlines()) |
641 | |
642 | + def getPubSourceForBinary(self): |
643 | + return self.getPubSource( |
644 | + sourcename='foo', dsc_maintainer_rfc822='Foo Bar <foo@bar.com>') |
645 | + |
646 | def testBinaryStanza(self): |
647 | """Check just-created binary publication Index stanza. |
648 | |
649 | See also testSourceStanza, it must present something similar for |
650 | binary packages. |
651 | """ |
652 | + pub_source = self.getPubSourceForBinary() |
653 | pub_binaries = self.getPubBinaries( |
654 | + binaryname='foo-bin', |
655 | + priority=PackagePublishingPriority.STANDARD, section="base", |
656 | + installed_size=100, architecturespecific=True, |
657 | + version='666', |
658 | depends='biscuit', recommends='foo-dev', suggests='pyfoo', |
659 | conflicts='old-foo', replaces='old-foo', provides='foo-master', |
660 | - pre_depends='master-foo', enhances='foo-super', breaks='old-foo') |
661 | + pre_depends='master-foo', enhances='foo-super', breaks='old-foo', |
662 | + filecontent='bbbiiinnnaaarrryyy', summary='Foo app is great', |
663 | + format=BinaryPackageFormat.DEB, |
664 | + description='Well ...\nit does nothing, though', |
665 | + pub_source=pub_source) |
666 | pub_binary = pub_binaries[0] |
667 | self.assertEqual( |
668 | [u'Package: foo-bin', |
669 | @@ -114,8 +137,15 @@ |
670 | "Normal\nNormal" |
671 | "\n.\n.\n." |
672 | "\n %s" % ('x' * 100)) |
673 | + pub_source = self.getPubSourceForBinary() |
674 | pub_binary = self.getPubBinaries( |
675 | - description=description)[0] |
676 | + description=description, pub_source=pub_source, |
677 | + binaryname='foo-bin', |
678 | + priority=PackagePublishingPriority.STANDARD, |
679 | + section="base", installed_size=100, architecturespecific=False, |
680 | + format=BinaryPackageFormat.DEB, |
681 | + version="666", filecontent="bbbiiinnnaaarrryyy", |
682 | + summary='Foo app is great')[0] |
683 | |
684 | self.assertEqual( |
685 | [u'Package: foo-bin', |
686 | @@ -150,8 +180,14 @@ |
687 | 'utf-8' for disk writing. |
688 | """ |
689 | description = u'Using non-ascii as: \xe7\xe3\xe9\xf3' |
690 | + pub_source = self.getPubSourceForBinary() |
691 | pub_binary = self.getPubBinaries( |
692 | - description=description)[0] |
693 | + description=description, pub_source=pub_source, |
694 | + binaryname='foo-bin', |
695 | + priority=PackagePublishingPriority.STANDARD, section="base", |
696 | + installed_size=100, architecturespecific=False, |
697 | + version="666", format=BinaryPackageFormat.DEB, |
698 | + filecontent='bbbiiinnnaaarrryyy', summary='Foo app is great')[0] |
699 | |
700 | self.assertEqual( |
701 | [u'Package: foo-bin', |
702 | @@ -200,7 +236,9 @@ |
703 | |
704 | def test_getIndexStanza_binary_stanza(self): |
705 | """Check a binary stanza with APT parser.""" |
706 | - pub_binary = self.getPubBinaries()[0] |
707 | + pub_binary = self.getPubBinaries( |
708 | + binaryname='foo-bin', summary='Foo app is great', |
709 | + description='Well ...\n it does nothing, though')[0] |
710 | |
711 | parser = self.write_stanza_and_reparse(pub_binary.getIndexStanza()) |
712 | |
713 | @@ -211,7 +249,8 @@ |
714 | |
715 | def test_getIndexStanza_source_stanza(self): |
716 | """Check a source stanza with APT parser.""" |
717 | - pub_source = self.getPubSource() |
718 | + pub_source = self.getPubSource( |
719 | + sourcename="foo", dsc_maintainer_rfc822='Foo Bar <foo@bar.com>') |
720 | |
721 | parser = self.write_stanza_and_reparse(pub_source.getIndexStanza()) |
722 | |
723 | @@ -243,12 +282,11 @@ |
724 | This test can be removed if the parser is fixed and the corrupt |
725 | data has been cleaned. |
726 | """ |
727 | - pub_source = self.getPubSource() |
728 | - |
729 | # An example of a corrupt dsc_binaries field. We need to ensure |
730 | # that the corruption is not carried over into the index stanza. |
731 | - pub_source.sourcepackagerelease.dsc_binaries = ( |
732 | - 'foo_bin,\nbar_bin,\nzed_bin') |
733 | + pub_source = self.getPubSource( |
734 | + sourcename="foo", version="666", |
735 | + dsc_binaries="foo_bin,\nbar_bin,\nzed_bin") |
736 | |
737 | parser = self.write_stanza_and_reparse(pub_source.getIndexStanza()) |
738 | |
739 | @@ -278,24 +316,16 @@ |
740 | the binary field in the same way that apt_pkg.ParseTagFiles would, |
741 | that it will continue to be written correctly to index files. |
742 | """ |
743 | - pub_source = self.getPubSource() |
744 | - |
745 | - # An example of a corrupt dsc_binaries field. We need to ensure |
746 | - # that the corruption is not carried over into the index stanza. |
747 | - pub_source.sourcepackagerelease.dsc_binaries = ( |
748 | - 'foo_bin,\n bar_bin,\n zed_bin') |
749 | + pub_source = self.getPubSource( |
750 | + sourcename='foo', version="666", |
751 | + dsc_binaries='foo_bin,\n bar_bin,\n zed_bin') |
752 | |
753 | parser = self.write_stanza_and_reparse(pub_source.getIndexStanza()) |
754 | |
755 | self.assertEqual('foo', parser.Section['Package']) |
756 | - |
757 | - # Without the fix, this raises a key-error due to apt-pkg not |
758 | - # being able to parse the file. |
759 | self.assertEqual( |
760 | '666', parser.Section['Version'], |
761 | 'The Version field should be parsed correctly.') |
762 | - |
763 | - # Without the fix, the second binary would not be parsed at all. |
764 | self.assertEqual( |
765 | 'foo_bin,\n bar_bin,\n zed_bin', parser.Section['Binary']) |
766 | |
767 | |
768 | === modified file 'lib/lp/soyuz/tests/test_publishing.py' |
769 | --- lib/lp/soyuz/tests/test_publishing.py 2010-08-12 14:03:47 +0000 |
770 | +++ lib/lp/soyuz/tests/test_publishing.py 2010-08-16 22:07:55 +0000 |
771 | @@ -13,11 +13,10 @@ |
772 | import transaction |
773 | import pytz |
774 | from zope.component import getUtility |
775 | -from zope.security.proxy import removeSecurityProxy |
776 | +from zope.security.proxy import isinstance, removeSecurityProxy |
777 | |
778 | from canonical.config import config |
779 | from canonical.database.constants import UTC_NOW |
780 | -from canonical.launchpad.interfaces.librarian import ILibraryFileAliasSet |
781 | from canonical.launchpad.webapp.errorlog import ErrorReportingUtility |
782 | from canonical.testing.layers import reconnect_stores |
783 | from canonical.testing import ( |
784 | @@ -34,21 +33,18 @@ |
785 | from lp.registry.interfaces.sourcepackage import SourcePackageUrgency |
786 | from lp.registry.interfaces.sourcepackagename import ISourcePackageNameSet |
787 | from lp.soyuz.model.processor import ProcessorFamily |
788 | -from lp.soyuz.model.publishing import ( |
789 | - SourcePackagePublishingHistory, BinaryPackagePublishingHistory) |
790 | +from lp.soyuz.model.publishing import BinaryPackagePublishingHistory |
791 | from lp.soyuz.interfaces.archive import ArchivePurpose, IArchiveSet |
792 | from lp.soyuz.interfaces.archivearch import IArchiveArchSet |
793 | -from lp.soyuz.interfaces.binarypackagename import IBinaryPackageNameSet |
794 | from lp.soyuz.interfaces.binarypackagerelease import BinaryPackageFormat |
795 | from lp.soyuz.interfaces.component import IComponentSet |
796 | -from lp.soyuz.interfaces.section import ISectionSet |
797 | from lp.soyuz.interfaces.publishing import ( |
798 | IPublishingSet, PackagePublishingPriority, PackagePublishingStatus) |
799 | from lp.soyuz.interfaces.queue import PackageUploadStatus |
800 | from canonical.launchpad.scripts import FakeLogger |
801 | from lp.testing import TestCaseWithFactory |
802 | -from lp.testing.factory import ( |
803 | - LaunchpadObjectFactory, remove_security_proxy_and_shout_at_engineer) |
804 | +from lp.testing.factory import LaunchpadObjectFactory |
805 | +from lp.testing.sampledata import UBUNTU_DEVELOPER_ADMIN_NAME |
806 | from lp.testing.fakemethod import FakeMethod |
807 | |
808 | |
809 | @@ -77,7 +73,8 @@ |
810 | distroseries = self.factory.makeDistroRelease() |
811 | self.distroseries = distroseries |
812 | # Set up a person that has a GPG key. |
813 | - self.person = getUtility(IPersonSet).getByName('name16') |
814 | + self.person = getUtility(IPersonSet).getByName( |
815 | + UBUNTU_DEVELOPER_ADMIN_NAME) |
816 | # Make sure the name exists in the database, to make it easier |
817 | # to get packages from distributions and distro series. |
818 | name_set = getUtility(ISourcePackageNameSet) |
819 | @@ -126,35 +123,28 @@ |
820 | self.breezy_autotest_i386 = self.breezy_autotest['i386'] |
821 | self.breezy_autotest_hppa = self.breezy_autotest['hppa'] |
822 | |
823 | - def addMockFile(self, filename, filecontent='nothing', restricted=False): |
824 | + def addMockFile(self, filename, filecontent='nothing', restricted=False, |
825 | + expires=None): |
826 | """Add a mock file in Librarian. |
827 | |
828 | Returns a ILibraryFileAlias corresponding to the file uploaded. |
829 | """ |
830 | - library_file = getUtility(ILibraryFileAliasSet).create( |
831 | - filename, len(filecontent), StringIO(filecontent), |
832 | - 'application/text', restricted=restricted) |
833 | - return library_file |
834 | + return self.factory.makeLibraryFileAlias( |
835 | + filename=filename, content=filecontent, restricted=restricted, |
836 | + content_type='application/text', expires=expires) |
837 | |
838 | def addPackageUpload(self, archive, distroseries, |
839 | pocket=PackagePublishingPocket.RELEASE, |
840 | changes_file_name="foo_666_source.changes", |
841 | changes_file_content="fake changes file content", |
842 | upload_status=PackageUploadStatus.DONE): |
843 | - signing_key = self.person.gpg_keys[0] |
844 | - package_upload = distroseries.createQueueEntry( |
845 | - pocket, changes_file_name, changes_file_content, archive, |
846 | - signing_key) |
847 | - |
848 | - status_to_method = { |
849 | - PackageUploadStatus.DONE: 'setDone', |
850 | - PackageUploadStatus.ACCEPTED: 'setAccepted', |
851 | - } |
852 | - naked_package_upload = removeSecurityProxy(package_upload) |
853 | - method = getattr( |
854 | - naked_package_upload, status_to_method[upload_status]) |
855 | - method() |
856 | - |
857 | + person = self.factory.makePerson() |
858 | + signing_key = self.factory.makeGPGKey(person) |
859 | + package_upload = self.factory.makePackageUpload( |
860 | + archive=archive, distroseries=distroseries, pocket=pocket, |
861 | + changes_filename=changes_file_name, |
862 | + changes_file_content=changes_file_content, |
863 | + signing_key=signing_key, status=upload_status) |
864 | return package_upload |
865 | |
866 | def getPubSource(self, sourcename=None, version='666', component='main', |
867 | @@ -172,7 +162,8 @@ |
868 | build_conflicts_indep=None, |
869 | dsc_maintainer_rfc822='Foo Bar <foo@bar.com>', |
870 | maintainer=None, creator=None, date_uploaded=UTC_NOW, |
871 | - spr_only=False): |
872 | + spr_only=False, files_expire=None, |
873 | + changelog_entry=None): |
874 | """Return a mock source publishing record. |
875 | |
876 | if spr_only is specified, the source is not published and the |
877 | @@ -180,26 +171,35 @@ |
878 | """ |
879 | if sourcename is None: |
880 | sourcename = self.default_package_name |
881 | - spn = getUtility(ISourcePackageNameSet).getOrCreateByName(sourcename) |
882 | - |
883 | - component = getUtility(IComponentSet)[component] |
884 | - section = getUtility(ISectionSet)[section] |
885 | + spn = self.factory.getOrMakeSourcePackageName(name=sourcename) |
886 | + component = self.factory.makeComponent(name=component) |
887 | |
888 | if distroseries is None: |
889 | distroseries = self.distroseries |
890 | if archive is None: |
891 | archive = distroseries.main_archive |
892 | - if maintainer is None: |
893 | - maintainer = self.person |
894 | if creator is None: |
895 | - creator = self.person |
896 | - |
897 | - spr = distroseries.createUploadedSourcePackageRelease( |
898 | + creator = self.factory.makePerson() |
899 | + self.factory.makeGPGKey(creator) |
900 | + |
901 | + changes_file_name = "%s_%s_source.changes" % (sourcename, version) |
902 | + if spr_only: |
903 | + upload_status = PackageUploadStatus.ACCEPTED |
904 | + else: |
905 | + upload_status = PackageUploadStatus.DONE |
906 | + package_upload = self.addPackageUpload( |
907 | + archive, distroseries, pocket, |
908 | + changes_file_name=changes_file_name, |
909 | + changes_file_content=changes_file_content, |
910 | + upload_status=upload_status) |
911 | + |
912 | + spr = self.factory.makeSourcePackageRelease( |
913 | + distroseries=distroseries, |
914 | sourcepackagename=spn, |
915 | maintainer=maintainer, |
916 | creator=creator, |
917 | component=component, |
918 | - section=section, |
919 | + section_name=section, |
920 | urgency=urgency, |
921 | version=version, |
922 | builddepends=builddepends, |
923 | @@ -207,58 +207,39 @@ |
924 | build_conflicts=build_conflicts, |
925 | build_conflicts_indep=build_conflicts_indep, |
926 | architecturehintlist=architecturehintlist, |
927 | - changelog=None, |
928 | - changelog_entry=None, |
929 | - dsc=None, |
930 | - copyright='placeholder ...', |
931 | - dscsigningkey=self.person.gpg_keys[0], |
932 | + dscsigningkey=creator.gpg_keys[0], |
933 | dsc_maintainer_rfc822=dsc_maintainer_rfc822, |
934 | dsc_standards_version=dsc_standards_version, |
935 | dsc_format=dsc_format, |
936 | dsc_binaries=dsc_binaries, |
937 | - archive=archive, dateuploaded=date_uploaded) |
938 | - |
939 | - changes_file_name = "%s_%s_source.changes" % (sourcename, version) |
940 | - if spr_only: |
941 | - upload_status = PackageUploadStatus.ACCEPTED |
942 | - else: |
943 | - upload_status = PackageUploadStatus.DONE |
944 | - package_upload = self.addPackageUpload( |
945 | - archive, distroseries, pocket, |
946 | - changes_file_name=changes_file_name, |
947 | - changes_file_content=changes_file_content, |
948 | - upload_status=upload_status) |
949 | - naked_package_upload = removeSecurityProxy( |
950 | - package_upload) |
951 | - naked_package_upload.addSource(spr) |
952 | + archive=archive, |
953 | + date_uploaded=date_uploaded, |
954 | + changelog_entry=changelog_entry, |
955 | + ) |
956 | + removeSecurityProxy(package_upload).addSource(spr) |
957 | |
958 | if filename is None: |
959 | filename = "%s_%s.dsc" % (sourcename, version) |
960 | alias = self.addMockFile( |
961 | - filename, filecontent, restricted=archive.private) |
962 | + filename, filecontent, restricted=archive.private, |
963 | + expires=files_expire) |
964 | spr.addFile(alias) |
965 | |
966 | if spr_only: |
967 | return spr |
968 | |
969 | - if status == PackagePublishingStatus.PUBLISHED: |
970 | - datepublished = UTC_NOW |
971 | - else: |
972 | - datepublished = None |
973 | - |
974 | - spph = SourcePackagePublishingHistory( |
975 | + spph = self.factory.makeSourcePackagePublishingHistory( |
976 | distroseries=distroseries, |
977 | sourcepackagerelease=spr, |
978 | component=spr.component, |
979 | - section=spr.section, |
980 | + section_name=spr.section.name, |
981 | status=status, |
982 | - datecreated=date_uploaded, |
983 | + date_uploaded=date_uploaded, |
984 | dateremoved=dateremoved, |
985 | - datepublished=datepublished, |
986 | scheduleddeletiondate=scheduleddeletiondate, |
987 | pocket=pocket, |
988 | - archive=archive) |
989 | - |
990 | + archive=archive, |
991 | + ) |
992 | return spph |
993 | |
994 | def getPubBinaries(self, binaryname='foo-bin', summary='Foo app is great', |
995 | @@ -279,7 +260,11 @@ |
996 | architecturespecific=False, |
997 | builder=None, |
998 | component='main', |
999 | - with_debug=False): |
1000 | + section='base', |
1001 | + priority=PackagePublishingPriority.STANDARD, |
1002 | + installed_size=100, files_expire=None, |
1003 | + with_debug=False, |
1004 | + ): |
1005 | """Return a list of binary publishing records.""" |
1006 | if distroseries is None: |
1007 | distroseries = self.distroseries |
1008 | @@ -298,7 +283,7 @@ |
1009 | sourcename=sourcename, status=status, pocket=pocket, |
1010 | archive=archive, distroseries=distroseries, |
1011 | version=version, architecturehintlist=architecturehintlist, |
1012 | - component=component) |
1013 | + component=component, files_expire=files_expire) |
1014 | else: |
1015 | archive = pub_source.archive |
1016 | |
1017 | @@ -323,10 +308,12 @@ |
1018 | build, binaryname, filecontent, summary, description, |
1019 | shlibdep, depends, recommends, suggests, conflicts, replaces, |
1020 | provides, pre_depends, enhances, breaks, format, |
1021 | - binarypackagerelease_ddeb) |
1022 | + installed_size=installed_size, component=component, |
1023 | + files_expire=files_expire, |
1024 | + debug_package=binarypackagerelease_ddeb) |
1025 | pub_binaries += self.publishBinaryInArchive( |
1026 | binarypackagerelease, archive, status, pocket, |
1027 | - scheduleddeletiondate, dateremoved) |
1028 | + scheduleddeletiondate, dateremoved, section, priority) |
1029 | published_binaries.extend(pub_binaries) |
1030 | package_upload = self.addPackageUpload( |
1031 | archive, distroseries, pocket, |
1032 | @@ -344,20 +331,21 @@ |
1033 | summary="summary", description="description", shlibdep=None, |
1034 | depends=None, recommends=None, suggests=None, conflicts=None, |
1035 | replaces=None, provides=None, pre_depends=None, enhances=None, |
1036 | - breaks=None, format=BinaryPackageFormat.DEB, debug_package=None): |
1037 | + breaks=None, format=BinaryPackageFormat.DEB, installed_size=None, |
1038 | + component=None, version=None, files_expire=None, debug_package=None): |
1039 | """Return the corresponding `BinaryPackageRelease`.""" |
1040 | sourcepackagerelease = build.source_package_release |
1041 | distroarchseries = build.distro_arch_series |
1042 | architecturespecific = ( |
1043 | not sourcepackagerelease.architecturehintlist == 'all') |
1044 | - |
1045 | - binarypackagename = getUtility( |
1046 | - IBinaryPackageNameSet).getOrCreateByName(binaryname) |
1047 | - |
1048 | - binarypackagerelease = build.createBinaryPackageRelease( |
1049 | - version=sourcepackagerelease.version, |
1050 | - component=sourcepackagerelease.component, |
1051 | - section=sourcepackagerelease.section, |
1052 | + if component is not None: |
1053 | + component = self.factory.makeComponent(name=component) |
1054 | + |
1055 | + binarypackagename = self.factory.getOrMakeBinaryPackageName( |
1056 | + name=binaryname) |
1057 | + |
1058 | + binarypackagerelease = self.factory.makeBinaryPackageRelease( |
1059 | + build=build, |
1060 | binarypackagename=binarypackagename, |
1061 | summary=summary, |
1062 | description=description, |
1063 | @@ -372,11 +360,14 @@ |
1064 | enhances=enhances, |
1065 | breaks=breaks, |
1066 | essential=False, |
1067 | - installedsize=100, |
1068 | architecturespecific=architecturespecific, |
1069 | binpackageformat=format, |
1070 | priority=PackagePublishingPriority.STANDARD, |
1071 | - debug_package=debug_package) |
1072 | + installed_size=installed_size, |
1073 | + component=component, |
1074 | + version=version, |
1075 | + debug_package=debug_package, |
1076 | + ) |
1077 | |
1078 | # Create the corresponding binary file. |
1079 | if architecturespecific: |
1080 | @@ -387,7 +378,7 @@ |
1081 | filearchtag, format.name.lower()) |
1082 | alias = self.addMockFile( |
1083 | filename, filecontent=filecontent, |
1084 | - restricted=build.archive.private) |
1085 | + restricted=build.archive.private, expires=files_expire) |
1086 | binarypackagerelease.addFile(alias) |
1087 | |
1088 | # Adjust the build record in way it looks complete. |
1089 | @@ -414,7 +405,8 @@ |
1090 | self, binarypackagerelease, archive, |
1091 | status=PackagePublishingStatus.PENDING, |
1092 | pocket=PackagePublishingPocket.RELEASE, |
1093 | - scheduleddeletiondate=None, dateremoved=None): |
1094 | + scheduleddeletiondate=None, dateremoved=None, section=None, |
1095 | + priority=None, component=None): |
1096 | """Return the corresponding BinaryPackagePublishingHistory.""" |
1097 | distroarchseries = binarypackagerelease.build.distro_arch_series |
1098 | |
1099 | @@ -426,20 +418,17 @@ |
1100 | |
1101 | pub_binaries = [] |
1102 | for arch in archs: |
1103 | - pub = BinaryPackagePublishingHistory( |
1104 | + pub = self.factory.makeBinaryPackagePublishingHistory( |
1105 | distroarchseries=arch, |
1106 | binarypackagerelease=binarypackagerelease, |
1107 | - component=binarypackagerelease.component, |
1108 | - section=binarypackagerelease.section, |
1109 | - priority=binarypackagerelease.priority, |
1110 | status=status, |
1111 | scheduleddeletiondate=scheduleddeletiondate, |
1112 | dateremoved=dateremoved, |
1113 | - datecreated=UTC_NOW, |
1114 | pocket=pocket, |
1115 | - archive=archive) |
1116 | - if status == PackagePublishingStatus.PUBLISHED: |
1117 | - pub.datepublished = UTC_NOW |
1118 | + archive=archive, |
1119 | + section_name=section, |
1120 | + priority=priority, |
1121 | + ) |
1122 | pub_binaries.append(pub) |
1123 | |
1124 | return pub_binaries |
1125 | @@ -455,7 +444,7 @@ |
1126 | |
1127 | def createSource( |
1128 | self, archive, sourcename, version, distroseries=None, |
1129 | - new_version=None): |
1130 | + new_version=None, component='main'): |
1131 | """Create source with meaningful '.changes' file.""" |
1132 | top = 'lib/lp/archiveuploader/tests/data/suite' |
1133 | name_fragment = '%s_%s' % (sourcename, version) |
1134 | @@ -476,7 +465,7 @@ |
1135 | source = self.getPubSource( |
1136 | sourcename=sourcename, archive=archive, version=new_version, |
1137 | changes_file_content=changesfile_content, |
1138 | - distroseries=distroseries) |
1139 | + distroseries=distroseries, component=component) |
1140 | |
1141 | return source |
1142 | |
1143 | @@ -691,7 +680,6 @@ |
1144 | self.layer.commit() |
1145 | |
1146 | foo_name = "%s/main/f/foo/foo_666.dsc" % self.pool_dir |
1147 | - pub_source.sync() |
1148 | self.assertEqual( |
1149 | pub_source.status, PackagePublishingStatus.PUBLISHED) |
1150 | self.assertEqual(open(foo_name).read().strip(), 'foo is happy') |
1151 | @@ -703,7 +691,6 @@ |
1152 | pub_source2.publish(self.disk_pool, self.logger) |
1153 | self.layer.commit() |
1154 | |
1155 | - pub_source2.sync() |
1156 | self.assertEqual( |
1157 | pub_source2.status, PackagePublishingStatus.PENDING) |
1158 | self.assertEqual(open(foo_name).read().strip(), 'foo is happy') |
1159 | @@ -720,7 +707,6 @@ |
1160 | self.layer.commit() |
1161 | bar_name = "%s/main/b/bar/bar_666.dsc" % self.pool_dir |
1162 | self.assertEqual(open(bar_name).read().strip(), 'bar is good') |
1163 | - pub_source.sync() |
1164 | self.assertEqual( |
1165 | pub_source.status, PackagePublishingStatus.PUBLISHED) |
1166 | |
1167 | @@ -728,7 +714,6 @@ |
1168 | sourcename='bar', filecontent='bar is good') |
1169 | pub_source2.publish(self.disk_pool, self.logger) |
1170 | self.layer.commit() |
1171 | - pub_source2.sync() |
1172 | self.assertEqual( |
1173 | pub_source2.status, PackagePublishingStatus.PUBLISHED) |
1174 | |
1175 | @@ -748,8 +733,6 @@ |
1176 | pub_source2.publish(self.disk_pool, self.logger) |
1177 | self.layer.commit() |
1178 | |
1179 | - pub_source.sync() |
1180 | - pub_source2.sync() |
1181 | self.assertEqual( |
1182 | pub_source.status, PackagePublishingStatus.PUBLISHED) |
1183 | self.assertEqual( |
1184 | @@ -768,7 +751,6 @@ |
1185 | pub_source3.publish(self.disk_pool, self.logger) |
1186 | self.layer.commit() |
1187 | |
1188 | - pub_source3.sync() |
1189 | self.assertEqual( |
1190 | pub_source3.status, PackagePublishingStatus.PENDING) |
1191 | |
1192 | @@ -789,7 +771,6 @@ |
1193 | pub_source.publish(test_disk_pool, self.logger) |
1194 | self.layer.commit() |
1195 | |
1196 | - pub_source.sync() |
1197 | self.assertEqual(pub_source.status, PackagePublishingStatus.PUBLISHED) |
1198 | self.assertEqual(pub_source.sourcepackagerelease.upload_archive, |
1199 | cprov.archive) |
1200 | @@ -833,17 +814,21 @@ |
1201 | 'Cannot override published records.', |
1202 | source.overrideFromAncestry) |
1203 | |
1204 | - def makeSource(self): |
1205 | + def makeSource(self, source_component='main', binary_component='main'): |
1206 | """Return a 'source' publication. |
1207 | |
1208 | It's pending publication with binaries in a brand new PPA |
1209 | - and in 'main' component. |
1210 | + and in 'main' component, unless otherwise specified. The binaries |
1211 | + can be placed in a different component to the source by |
1212 | + passing binary_component different to source_component. |
1213 | """ |
1214 | test_archive = self.factory.makeArchive( |
1215 | distribution=self.test_publisher.ubuntutest, |
1216 | purpose = ArchivePurpose.PPA) |
1217 | - source = self.test_publisher.getPubSource(archive=test_archive) |
1218 | - self.test_publisher.getPubBinaries(pub_source=source) |
1219 | + source = self.test_publisher.getPubSource( |
1220 | + archive=test_archive, component=source_component) |
1221 | + self.test_publisher.getPubBinaries( |
1222 | + pub_source=source, component=binary_component) |
1223 | return source |
1224 | |
1225 | def copyAndCheck(self, pub_record, series, component_name): |
1226 | @@ -871,23 +856,14 @@ |
1227 | def test_overrideFromAncestry_fallback_to_source_component(self): |
1228 | # overrideFromancestry on the lack of ancestry, falls back to the |
1229 | # component the source was originally uploaded to. |
1230 | - source = self.makeSource() |
1231 | - |
1232 | - # Adjust the source package release original component. |
1233 | - universe = getUtility(IComponentSet)['universe'] |
1234 | - source.sourcepackagerelease.component = universe |
1235 | - |
1236 | + source = self.makeSource(source_component='universe') |
1237 | self.copyAndCheck(source, source.distroseries, 'universe') |
1238 | |
1239 | def test_overrideFromAncestry_fallback_to_binary_component(self): |
1240 | # overrideFromAncestry on the lack of ancestry, falls back to the |
1241 | # component the binary was originally uploaded to. |
1242 | - binary = self.makeSource().getPublishedBinaries()[0] |
1243 | - |
1244 | - # Adjust the binary package release original component. |
1245 | - universe = getUtility(IComponentSet)['universe'] |
1246 | - removeSecurityProxy(binary.binarypackagerelease).component = universe |
1247 | - |
1248 | + binary = self.makeSource( |
1249 | + binary_component='universe').getPublishedBinaries()[0] |
1250 | self.copyAndCheck( |
1251 | binary, binary.distroarchseries.distroseries, 'universe') |
1252 | |
1253 | @@ -985,8 +961,9 @@ |
1254 | """ |
1255 | available_archs = [self.sparc_distroarch, self.avr_distroarch] |
1256 | pubrec = self.getPubSource(architecturehintlist='any') |
1257 | + naked_pubrec = removeSecurityProxy(pubrec) |
1258 | self.assertEquals([self.sparc_distroarch], |
1259 | - pubrec._getAllowedArchitectures(available_archs)) |
1260 | + naked_pubrec._getAllowedArchitectures(available_archs)) |
1261 | |
1262 | def test__getAllowedArchitectures_restricted_override(self): |
1263 | """Test _getAllowedArchitectures honors overrides of restricted archs. |
1264 | @@ -997,8 +974,9 @@ |
1265 | available_archs = [self.sparc_distroarch, self.avr_distroarch] |
1266 | getUtility(IArchiveArchSet).new(self.archive, self.avr_family) |
1267 | pubrec = self.getPubSource(architecturehintlist='any') |
1268 | + naked_pubrec = removeSecurityProxy(pubrec) |
1269 | self.assertEquals([self.sparc_distroarch, self.avr_distroarch], |
1270 | - pubrec._getAllowedArchitectures(available_archs)) |
1271 | + naked_pubrec._getAllowedArchitectures(available_archs)) |
1272 | |
1273 | def test_createMissingBuilds_restricts_any(self): |
1274 | """createMissingBuilds() should limit builds targeted at 'any' |
1275 | |
1276 | === modified file 'lib/lp/soyuz/tests/test_publishing_top_level_api.py' |
1277 | --- lib/lp/soyuz/tests/test_publishing_top_level_api.py 2010-07-20 12:06:36 +0000 |
1278 | +++ lib/lp/soyuz/tests/test_publishing_top_level_api.py 2010-08-16 22:07:55 +0000 |
1279 | @@ -109,8 +109,6 @@ |
1280 | self._publish(pocket=pocket) |
1281 | |
1282 | # source and binary PUBLISHED in database. |
1283 | - pub_source.sync() |
1284 | - pub_bin.sync() |
1285 | self.assertEqual(pub_source.status, PackagePublishingStatus.PUBLISHED) |
1286 | self.assertEqual(pub_bin.status, PackagePublishingStatus.PUBLISHED) |
1287 | |
1288 | |
1289 | === modified file 'lib/lp/testing/factory.py' |
1290 | --- lib/lp/testing/factory.py 2010-08-16 22:07:51 +0000 |
1291 | +++ lib/lp/testing/factory.py 2010-08-16 22:07:55 +0000 |
1292 | @@ -2319,7 +2319,8 @@ |
1293 | dsc_format='1.0', dsc_binaries='foo-bin', |
1294 | date_uploaded=UTC_NOW, |
1295 | source_package_recipe_build=None, |
1296 | - dscsigningkey=None): |
1297 | + dscsigningkey=None, |
1298 | + changelog_entry=None): |
1299 | """Make a `SourcePackageRelease`.""" |
1300 | if distroseries is None: |
1301 | if source_package_recipe_build is not None: |
1302 | @@ -2376,7 +2377,7 @@ |
1303 | build_conflicts_indep=build_conflicts_indep, |
1304 | architecturehintlist=architecturehintlist, |
1305 | changelog=None, |
1306 | - changelog_entry=None, |
1307 | + changelog_entry=changelog_entry, |
1308 | dsc=None, |
1309 | copyright=self.getUniqueString(), |
1310 | dscsigningkey=dscsigningkey, |
1311 | @@ -2636,16 +2637,12 @@ |
1312 | if installed_size is None: |
1313 | installed_size = self.getUniqueInteger() |
1314 | bpr = build.createBinaryPackageRelease( |
1315 | - binarypackagename=binarypackagename, version=version, |
1316 | - binpackageformat=binpackageformat, |
1317 | - component=component, section=section, priority=priority, |
1318 | - summary=summary, description=description, |
1319 | - architecturespecific=architecturespecific, |
1320 | - shlibdeps=shlibdeps, depends=depends, recommends=recommends, |
1321 | - suggests=suggests, conflicts=conflicts, replaces=replaces, |
1322 | - provides=provides, pre_depends=pre_depends, |
1323 | - enhances=enhances, breaks=breaks, essential=essential, |
1324 | - installedsize=installed_size, debug_package=debug_package) |
1325 | + binarypackagename, version, summary, description, |
1326 | + binpackageformat, component, section, priority, |
1327 | + shlibdeps, depends, recommends, suggests, conflicts, |
1328 | + replaces, provides, pre_depends, enhances, breaks, |
1329 | + essential, installed_size, architecturespecific, |
1330 | + debug_package) |
1331 | if date_created is not None: |
1332 | removeSecurityProxy(bpr).datecreated = date_created |
1333 | return bpr |
1334 | |
1335 | === modified file 'lib/lp/testing/tests/test_factory.py' |
1336 | --- lib/lp/testing/tests/test_factory.py 2010-08-16 22:07:51 +0000 |
1337 | +++ lib/lp/testing/tests/test_factory.py 2010-08-16 22:07:55 +0000 |
1338 | @@ -458,6 +458,17 @@ |
1339 | dsc_maintainer_rfc822=maintainer) |
1340 | self.assertEqual(maintainer, spr.dsc_maintainer_rfc822) |
1341 | |
1342 | + def test_makeSourcePackageRelease_allows_None_changelog_entry(self): |
1343 | + spr = self.factory.makeSourcePackageRelease( |
1344 | + changelog_entry=None) |
1345 | + self.assertEqual(None, spr.changelog_entry) |
1346 | + |
1347 | + def test_makeSourcePackageRelease_uses_changelog_entry(self): |
1348 | + changelog_entry = "Best release evar!!1!1!" |
1349 | + spr = self.factory.makeSourcePackageRelease( |
1350 | + changelog_entry=changelog_entry) |
1351 | + self.assertEqual(changelog_entry, spr.changelog_entry) |
1352 | + |
1353 | # makeSuiteSourcePackage |
1354 | def test_makeSuiteSourcePackage_returns_ISuiteSourcePackage(self): |
1355 | ssp = self.factory.makeSuiteSourcePackage() |
On Thu, Aug 5, 2010 at 10:00 PM, James Westby <email address hidden> wrote:
...
> Hi,
>
> Apologies for the bumper branch. Very small changes snowballed
> very quickly.
It happens.
> This branch moves SoyuzTestPublisher to back on to the
> factory, as a precursor to moving it away from sampledata.
>
> It now runs pretty much the same code inside the factory as it
> was running before, and now SoyuzTestPublisher is just a layer
> on top of the factory with some conveniences for complex
> tests.
>
This seems like a sensible approach.
> The major change is that there are now lots more proxied objects
> in soyuz tests, so most of the changes are fallout from that.
> There's a lot of removeSecurityProxy involved there, as most of
> the problems we in test setup code that is reaching around the
> interface to do test set up. I'm not entirely happy that we have
> to do that, they should be able to come in by the front door, but
> fixing all of that would be too much for one branch.
>
Agreed.
... archivepublishe r/tests/ test_dominator. py - just making the values explicit. archivepublishe r/tests/ test_publisher. py, lib/lp/ soyuz/scripts/ tests/test_ publishdistro. py, lib/lp/ soyuz/tests/ test_publishing _top_level_ api.py - using sync() from SQLObject, which isn't archiveuploader /tests/ nascentupload- ddebs.txt - getPubSource now creates a user, which soyuz/doc/ archive- files.txt - setting a value that could be set at creation time soyuz/doc/ packageupload- lookups. txt - Using rSP to ensure that the repr is soyuz/doc/ publishing. txt - changing purpose of an archive or parent series aren't normally allowed. New archives/series could be created instead. Changing the published soyuz/doc/ sourcepackagere lease.txt - deletion is protected, but this is just test soyuz/scripts/ tests/test_ changeoverride. py - specifying values and changing the soyuz/scripts/ tests/test_ copypackage. py - various instances of bypassing the soyuz/tests/ test_binarypack agebuild. py - the proxy stops you concatenating lists, so soyuz/tests/ test_publish_ archive_ indexes. py - specify all the tested values. Also soyuz/tests/ test_publishing .py - the big one, using the factory and lp.testing. sampledata rather than creating objects itself, then a whole bunch of fixes
> Breakdown of the changes, as not all are immediately obvious. It's perhaps
> best to review in reverse order of the changes listed here (odd that bzr
> diff gave me the files in roughly reverse order).
>
> lib/lp/
>
> lib/lp/
> on the interface.
>
> lib/lp/
> requires the extra setup that only used to be done later.
>
> lib/lp/
> if there were an appropriate way to do that. It's just set up though, so this has the
> same effect.
>
> lib/lp/
> what is expected.
>
> lib/lp/
> component isn't possible, but you could republish in the new component.
>
> lib/lp/
> cleanup, so we don't care.
>
> lib/lp/
> version of a publication, which isn't normally allowed.
>
> lib/lp/
> interface for test setup.
>
> lib/lp/
> listify each of them.
>
> lib/lp/
> a case of forcing invalid data in to a field. I also deleted some copy paste comments
> that made no sense in the context.
>
> lib/lp/
> from the fallout of this due to the proxy.
>
> Thanks,
>
My pleasure....