Merge lp:~james-w/launchpad/no-more-sampledata-2 into lp:launchpad

Proposed by James Westby
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
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/archivepublisher/tests/test_dominator.py - just making the values explicit.

lib/lp/archivepublisher/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
on the interface.

lib/lp/archiveuploader/tests/nascentupload-ddebs.txt - getPubSource now creates a user, which
requires the extra setup that only used to be done later.

lib/lp/soyuz/doc/archive-files.txt - setting a value that could be set at creation time
if there were an appropriate way to do that. It's just set up though, so this has the
same effect.

lib/lp/soyuz/doc/packageupload-lookups.txt - Using rSP to ensure that the repr is
what is expected.

lib/lp/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
component isn't possible, but you could republish in the new component.

lib/lp/soyuz/doc/sourcepackagerelease.txt - deletion is protected, but this is just test
cleanup, so we don't care.

lib/lp/soyuz/scripts/tests/test_changeoverride.py - specifying values and changing the
version of a publication, which isn't normally allowed.

lib/lp/soyuz/scripts/tests/test_copypackage.py - various instances of bypassing the
interface for test setup.

lib/lp/soyuz/tests/test_binarypackagebuild.py - the proxy stops you concatenating lists, so
listify each of them.

lib/lp/soyuz/tests/test_publish_archive_indexes.py - specify all the tested values. Also
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/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
from the fallout of this due to the proxy.

Thanks,

James

To post a comment you must log in.
Revision history for this message
Jonathan Lange (jml) wrote :
Download full text (28.0 KiB)

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.

...
> 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/archivepublisher/tests/test_dominator.py - just making the values explicit.
>
> lib/lp/archivepublisher/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
> on the interface.
>
> lib/lp/archiveuploader/tests/nascentupload-ddebs.txt - getPubSource now creates a user, which
> requires the extra setup that only used to be done later.
>
> lib/lp/soyuz/doc/archive-files.txt - setting a value that could be set at creation time
> if there were an appropriate way to do that. It's just set up though, so this has the
> same effect.
>
> lib/lp/soyuz/doc/packageupload-lookups.txt - Using rSP to ensure that the repr is
> what is expected.
>
> lib/lp/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
> component isn't possible, but you could republish in the new component.
>
> lib/lp/soyuz/doc/sourcepackagerelease.txt - deletion is protected, but this is just test
> cleanup, so we don't care.
>
> lib/lp/soyuz/scripts/tests/test_changeoverride.py - specifying values and changing the
> version of a publication, which isn't normally allowed.
>
> lib/lp/soyuz/scripts/tests/test_copypackage.py - various instances of bypassing the
> interface for test setup.
>
> lib/lp/soyuz/tests/test_binarypackagebuild.py - the proxy stops you concatenating lists, so
> listify each of them.
>
> lib/lp/soyuz/tests/test_publish_archive_indexes.py - specify all the tested values. Also
> 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/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
> from the fallout of this due to the proxy.
>
> Thanks,
>

My pleasure....

Revision history for this message
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

Revision history for this message
Abel Deuring (adeuring) wrote :

Hi James,

again, a nice branch!

Just one minor remark:

> @@ -540,7 +518,8 @@
> for pub in pubs:
> self.checkPastDate(pub.datesuperseded)
> if supersededby is not None:
> - if isinstance(pub, BinaryPackagePublishingHistory):
> + if isinstance(
> + removeSecurityProxy(pub), BinaryPackagePublishingHistory):
> dominant = supersededby.binarypackagerelease.build
> else:
> dominant = supersededby.sourcepackagerelease

I think this is one occasion where you don't need to call removeSecurityProxy(): The Zope security machinery monkeypatches isinstance() so that a possibly existing security proxy is removed before the "real" isinstance function is called.

review: Approve (code)
Revision history for this message
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.checkPastDate(pub.datesuperseded)
> >
> > if supersededby is not None:
> > - if isinstance(pub, BinaryPackagePublishingHistory):
> > + if isinstance(
> >
> > + removeSecurityProxy(pub),
BinaryPackagePublishingHistory):
> > dominant = supersededby.binarypackagerelease.build
> >
> > else:
> > dominant = supersededby.sourcepackagerelease
>
> I think this is one occasion where you don't need to call
> removeSecurityProxy(): The Zope security machinery monkeypatches
> 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.

Revision history for this message
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
removeSecurityProxy.

Thanks,

James

11330. By James Westby

Merge devel.

Revision history for this message
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. :)

review: Approve
11331. By James Westby

Merge devel.

11332. By James Westby

Merge improve-soyuz-factory in to no-more-sampledata-2.

Revision history for this message
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

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/archivepublisher/tests/test_publisher.py'
--- lib/lp/archivepublisher/tests/test_publisher.py 2010-07-22 08:19:27 +0000
+++ lib/lp/archivepublisher/tests/test_publisher.py 2010-08-16 22:07:55 +0000
@@ -83,7 +83,6 @@
83 publisher.A_publish(False)83 publisher.A_publish(False)
84 self.layer.txn.commit()84 self.layer.txn.commit()
8585
86 pub_source.sync()
87 self.assertDirtyPocketsContents(86 self.assertDirtyPocketsContents(
88 [('breezy-autotest', 'RELEASE')], publisher.dirty_pockets)87 [('breezy-autotest', 'RELEASE')], publisher.dirty_pockets)
89 self.assertEqual(pub_source.status, PackagePublishingStatus.PUBLISHED)88 self.assertEqual(pub_source.status, PackagePublishingStatus.PUBLISHED)
@@ -226,8 +225,6 @@
226 publisher.A_publish(force_publishing=False)225 publisher.A_publish(force_publishing=False)
227 self.layer.txn.commit()226 self.layer.txn.commit()
228227
229 pub_source.sync()
230 pub_source2.sync()
231 self.assertDirtyPocketsContents(228 self.assertDirtyPocketsContents(
232 [('hoary-test', 'RELEASE')], publisher.dirty_pockets)229 [('hoary-test', 'RELEASE')], publisher.dirty_pockets)
233 self.assertEqual(pub_source2.status,230 self.assertEqual(pub_source2.status,
@@ -259,8 +256,6 @@
259 publisher.A_publish(force_publishing=False)256 publisher.A_publish(force_publishing=False)
260 self.layer.txn.commit()257 self.layer.txn.commit()
261258
262 pub_source.sync()
263 pub_source2.sync()
264 self.assertDirtyPocketsContents(259 self.assertDirtyPocketsContents(
265 [('breezy-autotest', 'UPDATES')], publisher.dirty_pockets)260 [('breezy-autotest', 'UPDATES')], publisher.dirty_pockets)
266 self.assertEqual(pub_source.status, PackagePublishingStatus.PUBLISHED)261 self.assertEqual(pub_source.status, PackagePublishingStatus.PUBLISHED)
@@ -360,7 +355,6 @@
360 publisher.A_publish(False)355 publisher.A_publish(False)
361 self.layer.txn.commit()356 self.layer.txn.commit()
362357
363 pub_source.sync()
364 self.assertDirtyPocketsContents(358 self.assertDirtyPocketsContents(
365 [('breezy-autotest', 'RELEASE')], publisher.dirty_pockets)359 [('breezy-autotest', 'RELEASE')], publisher.dirty_pockets)
366 self.assertEqual(pub_source.status, PackagePublishingStatus.PUBLISHED)360 self.assertEqual(pub_source.status, PackagePublishingStatus.PUBLISHED)
367361
=== modified file 'lib/lp/archiveuploader/tests/nascentupload-ddebs.txt'
--- lib/lp/archiveuploader/tests/nascentupload-ddebs.txt 2010-07-21 08:07:08 +0000
+++ lib/lp/archiveuploader/tests/nascentupload-ddebs.txt 2010-08-16 22:07:55 +0000
@@ -15,6 +15,8 @@
1515
16 >>> from lp.soyuz.tests.test_publishing import (16 >>> from lp.soyuz.tests.test_publishing import (
17 ... SoyuzTestPublisher)17 ... SoyuzTestPublisher)
18 >>> from canonical.config import config
19 >>> from canonical.testing import LaunchpadZopelessLayer
1820
19 >>> test_publisher = SoyuzTestPublisher()21 >>> test_publisher = SoyuzTestPublisher()
2022
2123
=== modified file 'lib/lp/soyuz/doc/archive-files.txt'
--- lib/lp/soyuz/doc/archive-files.txt 2010-07-21 11:06:37 +0000
+++ lib/lp/soyuz/doc/archive-files.txt 2010-08-16 22:07:55 +0000
@@ -143,9 +143,13 @@
143 >>> print another_test_source.sourcepackagerelease.package_diffs.count()143 >>> print another_test_source.sourcepackagerelease.package_diffs.count()
144 1144 1
145145
146We don't care about having a realistic diff for the two packages, for this
147test, and getting one through the normal means would be expensive, so
148we'll take a shortcut and set the content to be a dummy file.
149
146 >>> diff_name = 'test-pkg_1.0_1.1.diff.gz'150 >>> diff_name = 'test-pkg_1.0_1.1.diff.gz'
147 >>> diff = test_publisher.addMockFile(diff_name)151 >>> diff = test_publisher.addMockFile(diff_name)
148 >>> package_diff.diff_content = diff152 >>> removeSecurityProxy(package_diff).diff_content = diff
149153
150 >>> diff == cprov.archive.getFileByName(diff_name)154 >>> diff == cprov.archive.getFileByName(diff_name)
151 True155 True
152156
=== modified file 'lib/lp/soyuz/doc/packageupload-lookups.txt'
--- lib/lp/soyuz/doc/packageupload-lookups.txt 2010-03-06 04:57:40 +0000
+++ lib/lp/soyuz/doc/packageupload-lookups.txt 2010-08-16 22:07:55 +0000
@@ -98,6 +98,7 @@
98 # Create a testing source and its binaries in98 # Create a testing source and its binaries in
99 # ubuntutest/breezy-autotest/i386.99 # ubuntutest/breezy-autotest/i386.
100 >>> from lp.soyuz.tests.test_publishing import SoyuzTestPublisher100 >>> from lp.soyuz.tests.test_publishing import SoyuzTestPublisher
101 >>> from zope.security.proxy import removeSecurityProxy
101 >>> login('foo.bar@canonical.com')102 >>> login('foo.bar@canonical.com')
102 >>> test_publisher = SoyuzTestPublisher()103 >>> test_publisher = SoyuzTestPublisher()
103 >>> test_publisher.prepareBreezyAutotest()104 >>> test_publisher.prepareBreezyAutotest()
@@ -112,7 +113,8 @@
112The `SourcePackageRelease` 'package_upload' and 'upload_changesfile'113The `SourcePackageRelease` 'package_upload' and 'upload_changesfile'
113114
114 >>> original_source_upload = source.sourcepackagerelease.package_upload115 >>> original_source_upload = source.sourcepackagerelease.package_upload
115 >>> print original_source_upload116 >>> # avoid the __repr__ of the security proxy
117 >>> print removeSecurityProxy(original_source_upload)
116 <PackageUpload ...>118 <PackageUpload ...>
117119
118 >>> source_changesfile = source.sourcepackagerelease.upload_changesfile120 >>> source_changesfile = source.sourcepackagerelease.upload_changesfile
119121
=== modified file 'lib/lp/soyuz/doc/publishing.txt'
--- lib/lp/soyuz/doc/publishing.txt 2010-07-12 03:14:42 +0000
+++ lib/lp/soyuz/doc/publishing.txt 2010-08-16 22:07:55 +0000
@@ -2,10 +2,11 @@
2SourcePackagePublishingHistory2SourcePackagePublishingHistory
3==============================3==============================
44
5This class provides public access to publishing records via a SQL view.5This class provides public access to publishing records.
66
7 >>> from canonical.launchpad.database import SourcePackagePublishingHistory7 >>> from lp.soyuz.model.publishing import (
8 >>> from canonical.launchpad.database import BinaryPackagePublishingHistory8 ... BinaryPackagePublishingHistory, SourcePackagePublishingHistory)
9 >>> from zope.security.proxy import removeSecurityProxy
910
10Select a publishing record from the sampledata (pmount is a11Select a publishing record from the sampledata (pmount is a
11interesting one):12interesting one):
@@ -172,17 +173,36 @@
172a rebuild archive then the status summary will always display173a rebuild archive then the status summary will always display
173FULLY_BUILT.174FULLY_BUILT.
174175
176Create a COPY archive that will build for hppa and i386.
177
175 >>> from lp.soyuz.interfaces.archive import ArchivePurpose178 >>> from lp.soyuz.interfaces.archive import ArchivePurpose
176 >>> spph.archive.purpose = ArchivePurpose.COPY179 >>> from lp.soyuz.interfaces.archivearch import IArchiveArchSet
177 >>> build_status_summary = spph.getStatusSummaryForBuilds()180 >>> from lp.soyuz.interfaces.processor import IProcessorFamilySet
181 >>> archive = factory.makeArchive(
182 ... purpose=ArchivePurpose.COPY,
183 ... distribution=test_publisher.ubuntutest,
184 ... virtualized=False)
185 >>> processor_family = getUtility(IProcessorFamilySet).getByName('hppa')
186 >>> archive_arch_set = getUtility(IArchiveArchSet).new(
187 ... archive, processor_family)
188
189Publish a source to it, create the builds and mark them fully built.
190
191 >>> copy_spph = test_publisher.getPubSource(
192 ... sourcename="abc", version="666", archive=archive,
193 ... architecturehintlist='any')
194 >>> copy_builds = copy_spph.createMissingBuilds()
195 >>> for build in copy_builds:
196 ... build.status = BuildStatus.FULLYBUILT
197
198The check that the status summary marks all builds as FULLYBUILT.
199
200 >>> build_status_summary = copy_spph.getStatusSummaryForBuilds()
178 >>> print_build_status_summary(build_status_summary)201 >>> print_build_status_summary(build_status_summary)
179 FULLYBUILT202 FULLYBUILT
180 hppa build of abc 666 in ubuntutest breezy-autotest RELEASE203 hppa build of abc 666 in ubuntutest breezy-autotest RELEASE
181 i386 build of abc 666 in ubuntutest breezy-autotest RELEASE204 i386 build of abc 666 in ubuntutest breezy-autotest RELEASE
182205
183 # Just set the purpose back before continuing on.
184 >>> spph.archive.purpose = ArchivePurpose.PRIMARY
185
186If one of the builds becomes published, it will not appear in the summary:206If one of the builds becomes published, it will not appear in the summary:
187207
188 >>> from lp.soyuz.interfaces.publishing import (208 >>> from lp.soyuz.interfaces.publishing import (
@@ -779,8 +799,10 @@
779This simulates a rebuild in of the same source in a more recent799This simulates a rebuild in of the same source in a more recent
780distroseries, like rebuilding SRUs for constant sources.800distroseries, like rebuilding SRUs for constant sources.
781801
782 >>> breezy_autotest.parent_series = None802 >>> # removeSecurityProxy is required as no-one normally has the
783 >>> hoary_test.parent_series = breezy_autotest803 >>> # permission to do this
804 >>> removeSecurityProxy(breezy_autotest).parent_series = None
805 >>> removeSecurityProxy(hoary_test).parent_series = breezy_autotest
784806
785 >>> ppa_source.createMissingBuilds()807 >>> ppa_source.createMissingBuilds()
786 []808 []
@@ -791,8 +813,10 @@
791Now, let's check the opposite, as if the copy was from a more recent813Now, let's check the opposite, as if the copy was from a more recent
792distroseries to a older one, like a backport rebuild.814distroseries to a older one, like a backport rebuild.
793815
794 >>> breezy_autotest.parent_series = hoary_test816 >>> # removeSecurityProxy is required as no-one normally has the
795 >>> hoary_test.parent_series = None817 >>> # permission to do this
818 >>> removeSecurityProxy(breezy_autotest).parent_series = hoary_test
819 >>> removeSecurityProxy(hoary_test).parent_series = None
796820
797 >>> ppa_source.createMissingBuilds()821 >>> ppa_source.createMissingBuilds()
798 []822 []
@@ -1064,7 +1088,7 @@
1064 main1088 main
10651089
1066 >>> test_bin_pubs = test_publisher.getPubBinaries(1090 >>> test_bin_pubs = test_publisher.getPubBinaries(
1067 ... pub_source=test_source_pub)1091 ... pub_source=test_source_pub, component='universe')
1068 >>> test_bin_pub = test_bin_pubs[0]1092 >>> test_bin_pub = test_bin_pubs[0]
1069 >>> ppa_pub = publishing_set.newBinaryPublication(1093 >>> ppa_pub = publishing_set.newBinaryPublication(
1070 ... archive=mark.archive,1094 ... archive=mark.archive,
@@ -1330,7 +1354,6 @@
13301354
1331 >>> diff_file = getUtility(ILibraryFileAliasSet)[1]1355 >>> diff_file = getUtility(ILibraryFileAliasSet)[1]
13321356
1333 >>> from zope.security.proxy import removeSecurityProxy
1334 >>> naked_diff = removeSecurityProxy(pmount_diff)1357 >>> naked_diff = removeSecurityProxy(pmount_diff)
1335 >>> naked_diff.diff_content = diff_file1358 >>> naked_diff.diff_content = diff_file
1336 >>> flush_database_updates()1359 >>> flush_database_updates()
@@ -1810,7 +1833,10 @@
1810 ... sourcename='testing', version='2.0', component='universe',1833 ... sourcename='testing', version='2.0', component='universe',
1811 ... architecturehintlist='i386')1834 ... architecturehintlist='i386')
1812 >>> test_binary = test_publisher.getPubBinaries(1835 >>> test_binary = test_publisher.getPubBinaries(
1813 ... binaryname='testing-bin', pub_source=test_source)[0]1836 ... binaryname='testing-bin', pub_source=test_source,
1837 ... component='multiverse')[0]
1838 >>> test_binary = test_binary.changeOverride(
1839 ... new_component=factory.makeComponent(name='universe'))
18141840
1815We will create a helper function to inspect ancestries. It simply pass1841We will create a helper function to inspect ancestries. It simply pass
1816any given keyword argument to 'test_source' and 'test_binary'1842any given keyword argument to 'test_source' and 'test_binary'
@@ -1876,9 +1902,6 @@
18761902
1877It works in the same way for binaries.1903It works in the same way for binaries.
18781904
1879 >>> multiverse = getUtility(IComponentSet)['multiverse']
1880 >>> test_binary.binarypackagerelease.component = multiverse
1881
1882 >>> print test_binary.component.name1905 >>> print test_binary.component.name
1883 universe1906 universe
18841907
18851908
=== modified file 'lib/lp/soyuz/doc/sourcepackagerelease.txt'
--- lib/lp/soyuz/doc/sourcepackagerelease.txt 2010-05-19 15:39:52 +0000
+++ lib/lp/soyuz/doc/sourcepackagerelease.txt 2010-08-16 22:07:55 +0000
@@ -14,6 +14,7 @@
1414
15Let's get one from the database:15Let's get one from the database:
1616
17 >>> from __future__ import with_statement
17 >>> from canonical.launchpad.database import SourcePackageRelease18 >>> from canonical.launchpad.database import SourcePackageRelease
18 >>> spr = SourcePackageRelease.get(14)19 >>> spr = SourcePackageRelease.get(14)
19 >>> spr.name20 >>> spr.name
@@ -196,10 +197,10 @@
196197
197 >>> new_spr = hoary.createUploadedSourcePackageRelease(198 >>> new_spr = hoary.createUploadedSourcePackageRelease(
198 ... arg_name, version, arg_maintainer,199 ... arg_name, version, arg_maintainer,
199 ... builddepends, builddependsindep, archhintlist, arg_comp, arg_creator,200 ... builddepends, builddependsindep, archhintlist, arg_comp,
200 ... arg_urgency, changelog, changelog_entry, dsc, arg_key, arg_sect,201 ... arg_creator, arg_urgency, changelog, changelog_entry, dsc,
201 ... dsc_maintainer_rfc822, dsc_standards_version, dsc_format,202 ... arg_key, arg_sect, dsc_maintainer_rfc822, dsc_standards_version,
202 ... dsc_binaries, archive, copyright=copyright,203 ... dsc_format, dsc_binaries, archive, copyright=copyright,
203 ... build_conflicts=None, build_conflicts_indep=None,204 ... build_conflicts=None, build_conflicts_indep=None,
204 ... source_package_recipe_build=arg_recipebuild)205 ... source_package_recipe_build=arg_recipebuild)
205206
@@ -349,7 +350,9 @@
349private PPA, it gets deleted from that private PPA. At this point the350private PPA, it gets deleted from that private PPA. At this point the
350package is still public:351package is still public:
351352
352 >>> private_publication.requestDeletion(cprov)353 >>> from lp.testing import person_logged_in
354 >>> with person_logged_in(cprov):
355 ... private_publication.requestDeletion(cprov)
353 >>> transaction.commit()356 >>> transaction.commit()
354 >>> login('no-priv@canonical.com')357 >>> login('no-priv@canonical.com')
355 >>> check_permission('launchpad.View', test_sourcepackagerelease)358 >>> check_permission('launchpad.View', test_sourcepackagerelease)
356359
=== modified file 'lib/lp/soyuz/scripts/tests/test_changeoverride.py'
--- lib/lp/soyuz/scripts/tests/test_changeoverride.py 2010-07-20 12:06:36 +0000
+++ lib/lp/soyuz/scripts/tests/test_changeoverride.py 2010-08-16 22:07:55 +0000
@@ -14,7 +14,8 @@
14from canonical.launchpad.interfaces.librarian import ILibraryFileAliasSet14from canonical.launchpad.interfaces.librarian import ILibraryFileAliasSet
15from lp.registry.interfaces.person import IPersonSet15from lp.registry.interfaces.person import IPersonSet
16from lp.registry.interfaces.pocket import PackagePublishingPocket16from lp.registry.interfaces.pocket import PackagePublishingPocket
17from lp.soyuz.interfaces.publishing import PackagePublishingPriority17from lp.soyuz.interfaces.publishing import (
18 PackagePublishingPriority, PackagePublishingStatus)
18from lp.soyuz.interfaces.section import ISectionSet19from lp.soyuz.interfaces.section import ISectionSet
19from canonical.launchpad.scripts import FakeLogger20from canonical.launchpad.scripts import FakeLogger
20from lp.soyuz.scripts.changeoverride import (21from lp.soyuz.scripts.changeoverride import (
@@ -252,18 +253,24 @@
252 * 'boingo-data' binaries PENDING in warty i386 & hppa.253 * 'boingo-data' binaries PENDING in warty i386 & hppa.
253 """254 """
254 source = self.test_publisher.getPubSource(255 source = self.test_publisher.getPubSource(
255 sourcename="boingo", version='1.0', distroseries=self.warty)256 sourcename="boingo", version='1.0', distroseries=self.warty,
257 component="main", section="base",
258 status=PackagePublishingStatus.PENDING)
256259
257 binaries = self.test_publisher.getPubBinaries(260 binaries = self.test_publisher.getPubBinaries(
258 'boingo-bin', pub_source=source, distroseries=self.warty)261 'boingo-bin', pub_source=source, distroseries=self.warty,
262 version="1.0", component="main", section="base",
263 priority=PackagePublishingPriority.STANDARD,
264 status=PackagePublishingStatus.PENDING)
259265
260 build = binaries[0].binarypackagerelease.build266 build = binaries[0].binarypackagerelease.build
261 other_binary = self.test_publisher.uploadBinaryForBuild(267 other_binary = self.test_publisher.uploadBinaryForBuild(
262 build, 'boingo-data')268 build, 'boingo-data', version='0.9')
263 other_binary.version = '0.9'
264 binaries.extend(269 binaries.extend(
265 self.test_publisher.publishBinaryInArchive(270 self.test_publisher.publishBinaryInArchive(
266 other_binary, source.archive))271 other_binary, source.archive, section="base",
272 priority=PackagePublishingPriority.STANDARD,
273 status=PackagePublishingStatus.PENDING))
267274
268 def test_changeoverride_operations(self):275 def test_changeoverride_operations(self):
269 """Check if `IArchivePublisher.changeOverride` is wrapped correctly.276 """Check if `IArchivePublisher.changeOverride` is wrapped correctly.
270277
=== modified file 'lib/lp/soyuz/scripts/tests/test_copypackage.py'
--- lib/lp/soyuz/scripts/tests/test_copypackage.py 2010-07-20 12:06:36 +0000
+++ lib/lp/soyuz/scripts/tests/test_copypackage.py 2010-08-16 22:07:55 +0000
@@ -654,6 +654,24 @@
654 self.test_publisher = SoyuzTestPublisher()654 self.test_publisher = SoyuzTestPublisher()
655 self.test_publisher.prepareBreezyAutotest()655 self.test_publisher.prepareBreezyAutotest()
656656
657 def makeTargetArchive(self):
658 return self.factory.makeArchive(
659 distribution=self.test_publisher.ubuntutest,
660 purpose=ArchivePurpose.PPA)
661
662 def test_checkCopy_can_copy_unexpired_binaries(self):
663 source = self.test_publisher.getPubSource()
664 binaries = self.test_publisher.getPubBinaries(pub_source=source)
665 archive = self.makeTargetArchive()
666 series = source.distroseries
667 pocket = source.pocket
668 copy_checker = CopyChecker(archive, include_binaries=False)
669 self.assertIs(
670 None, copy_checker.checkCopy(source, series, pocket))
671 copy_checker = CopyChecker(archive, include_binaries=True)
672 self.assertIs(
673 None, copy_checker.checkCopy(source, series, pocket))
674
657 def test_checkCopy_cannot_copy_expired_binaries(self):675 def test_checkCopy_cannot_copy_expired_binaries(self):
658 # checkCopy() raises CannotCopy if the copy includes binaries676 # checkCopy() raises CannotCopy if the copy includes binaries
659 # and the binaries contain expired files. Publications of677 # and the binaries contain expired files. Publications of
@@ -661,30 +679,14 @@
661 # the file is unreachable.679 # the file is unreachable.
662680
663 # Create a testing source and binaries.681 # Create a testing source and binaries.
682 old_date = datetime.datetime(1970, 1, 1, tzinfo=pytz.UTC)
664 source = self.test_publisher.getPubSource()683 source = self.test_publisher.getPubSource()
665 binaries = self.test_publisher.getPubBinaries(pub_source=source)684 binaries = self.test_publisher.getPubBinaries(
666685 pub_source=source, files_expire=old_date)
667 # Create a fresh PPA which will be the destination copy.686 archive = self.makeTargetArchive()
668 archive = self.factory.makeArchive(
669 distribution=self.test_publisher.ubuntutest,
670 purpose=ArchivePurpose.PPA)
671 series = source.distroseries687 series = source.distroseries
672 pocket = source.pocket688 pocket = source.pocket
673689
674 # At this point copy is allowed with or without binaries.
675 copy_checker = CopyChecker(archive, include_binaries=False)
676 self.assertIs(
677 None, copy_checker.checkCopy(source, series, pocket))
678 copy_checker = CopyChecker(archive, include_binaries=True)
679 self.assertIs(
680 None, copy_checker.checkCopy(source, series, pocket))
681
682 # Set the expiration date of one of the testing binary files.
683 utc = pytz.timezone('UTC')
684 old_date = datetime.datetime(1970, 1, 1, tzinfo=utc)
685 a_binary_file = binaries[0].binarypackagerelease.files[0]
686 a_binary_file.libraryfile.expires = old_date
687
688 # Now source-only copies are allowed.690 # Now source-only copies are allowed.
689 copy_checker = CopyChecker(archive, include_binaries=False)691 copy_checker = CopyChecker(archive, include_binaries=False)
690 self.assertIs(692 self.assertIs(
@@ -702,20 +704,13 @@
702 # source that contain expired files. Publications of expired704 # source that contain expired files. Publications of expired
703 # files can't be processed by the publisher since the file is705 # files can't be processed by the publisher since the file is
704 # unreachable.706 # unreachable.
705 source = self.test_publisher.getPubSource()707 expire = datetime.datetime.now(
706708 pytz.UTC) + datetime.timedelta(days=365)
707 archive = self.factory.makeArchive(709 source = self.test_publisher.getPubSource(
708 distribution=self.test_publisher.ubuntutest,710 files_expire=expire)
709 purpose=ArchivePurpose.PPA)711 archive = self.makeTargetArchive()
710 series = source.distroseries712 series = source.distroseries
711 pocket = source.pocket713 pocket = source.pocket
712
713 utc = pytz.timezone('UTC')
714 expire = datetime.datetime.now(utc) + datetime.timedelta(days=365)
715
716 a_source_file = source.sourcepackagerelease.files[0]
717 a_source_file.libraryfile.expires = expire
718
719 copy_checker = CopyChecker(archive, include_binaries=False)714 copy_checker = CopyChecker(archive, include_binaries=False)
720 self.assertRaisesWithContent(715 self.assertRaisesWithContent(
721 CannotCopy,716 CannotCopy,
@@ -974,7 +969,7 @@
974 self.test_publisher.breezy_autotest.status = (969 self.test_publisher.breezy_autotest.status = (
975 SeriesStatus.CURRENT)970 SeriesStatus.CURRENT)
976971
977 def createDelayedCopyContext(self):972 def createDelayedCopyContext(self, component='main'):
978 """Create a context to allow delayed-copies test.973 """Create a context to allow delayed-copies test.
979974
980 The returned source publication in a private archive with975 The returned source publication in a private archive with
@@ -986,7 +981,8 @@
986 ppa.buildd_secret = 'x'981 ppa.buildd_secret = 'x'
987 ppa.private = True982 ppa.private = True
988983
989 source = self.test_publisher.createSource(ppa, 'foocomm', '1.0-2')984 source = self.test_publisher.createSource(
985 ppa, 'foocomm', '1.0-2', component=component)
990 self.test_publisher.getPubBinaries(pub_source=source)986 self.test_publisher.getPubBinaries(pub_source=source)
991987
992 [build] = source.getBuilds()988 [build] = source.getBuilds()
@@ -1060,14 +1056,13 @@
1060 overridden when uploaded to the PPA, but when copying it to another1056 overridden when uploaded to the PPA, but when copying it to another
1061 archive, only the ancestry in the destination archive can be used.1057 archive, only the ancestry in the destination archive can be used.
1062 If that ancestry doesn't exist, an exception is raised."""1058 If that ancestry doesn't exist, an exception is raised."""
1063 # We'll simulate an upload that was overridden to main in the1059 # Upload to contrib, with automatic override to main due
1064 # ppa, by explicitly setting the spr's and bpr's component to1060 # to it being a PPA.
1065 # something else.1061 source = self.createDelayedCopyContext(component='contrib')
1066 source = self.createDelayedCopyContext()1062 # But then override in to main, like a PPA would
1067 contrib = getUtility(IComponentSet).new('contrib')
1068 source.sourcepackagerelease.component = contrib
1069 [build] = source.getBuilds()1063 [build] = source.getBuilds()
1070 [binary] = build.binarypackages1064 [binary] = build.binarypackages
1065 contrib = self.factory.makeComponent(name="contrib")
1071 binary.override(component=contrib)1066 binary.override(component=contrib)
1072 self.layer.txn.commit()1067 self.layer.txn.commit()
10731068
@@ -1084,14 +1079,12 @@
1084 archive, only the ancestry in the destination archive can be used.1079 archive, only the ancestry in the destination archive can be used.
1085 If an ancestor is found in the destination archive, its component1080 If an ancestor is found in the destination archive, its component
1086 is assumed for this package upload."""1081 is assumed for this package upload."""
1087 # We'll simulate an upload that was overridden to main in the1082 # Upload to contrib, with automatic override to main due
1088 # ppa, by explicitly setting the spr's and bpr's component to1083 # to it being a PPA.
1089 # something else.1084 source = self.createDelayedCopyContext(component='contrib')
1090 source = self.createDelayedCopyContext()
1091 contrib = getUtility(IComponentSet).new('contrib')
1092 source.sourcepackagerelease.component = contrib
1093 [build] = source.getBuilds()1085 [build] = source.getBuilds()
1094 [binary] = build.binarypackages1086 [binary] = build.binarypackages
1087 contrib = self.factory.makeComponent(name='contrib')
1095 binary.override(component=contrib)1088 binary.override(component=contrib)
10961089
1097 # This time, we'll ensure that there is already an ancestor for1090 # This time, we'll ensure that there is already an ancestor for
@@ -2234,7 +2227,16 @@
2234 test_publisher.addFakeChroots(warty)2227 test_publisher.addFakeChroots(warty)
2235 ppa_binaries = test_publisher.getPubBinaries(2228 ppa_binaries = test_publisher.getPubBinaries(
2236 pub_source=ppa_source, distroseries=warty,2229 pub_source=ppa_source, distroseries=warty,
2237 status=PackagePublishingStatus.PUBLISHED)2230 status=PackagePublishingStatus.PUBLISHED,
2231 component='universe')
2232
2233 # Override the ppa binaries to main, like a PPA would
2234 new_ppa_binaries = []
2235 main = self.factory.makeComponent(name="main")
2236 for binary in ppa_binaries:
2237 new_ppa_binaries.append(
2238 binary.changeOverride(new_component=main))
2239 ppa_binaries = new_ppa_binaries
22382240
2239 # Give the new source a private package diff.2241 # Give the new source a private package diff.
2240 sourcepackagerelease = other_source.sourcepackagerelease2242 sourcepackagerelease = other_source.sourcepackagerelease
@@ -2263,10 +2265,6 @@
2263 universe = getUtility(IComponentSet)['universe']2265 universe = getUtility(IComponentSet)['universe']
2264 ancestry_source.component = universe2266 ancestry_source.component = universe
22652267
2266 # Override the copied binarypackagerelease to 'universe'.
2267 for binary in ppa_binaries:
2268 binary.binarypackagerelease.component = universe
2269
2270 self.layer.txn.commit()2268 self.layer.txn.commit()
22712269
2272 # Now we can invoke the unembargo script and check its results.2270 # Now we can invoke the unembargo script and check its results.
@@ -2364,9 +2362,9 @@
2364 sourcename='buggy-source', version=version,2362 sourcename='buggy-source', version=version,
2365 distroseries=warty, archive=archive, pocket=pocket,2363 distroseries=warty, archive=archive, pocket=pocket,
2366 changes_file_content=changes_file_content,2364 changes_file_content=changes_file_content,
2367 status=PackagePublishingStatus.PUBLISHED)2365 status=PackagePublishingStatus.PUBLISHED,
2368 source.sourcepackagerelease.changelog_entry = (2366 changelog_entry="Required for "
2369 "Required for close_bugs_for_sourcepublication")2367 "close_bugs_for_sourcepublication")
2370 binaries = test_publisher.getPubBinaries(2368 binaries = test_publisher.getPubBinaries(
2371 pub_source=source, distroseries=warty, archive=archive,2369 pub_source=source, distroseries=warty, archive=archive,
2372 pocket=pocket, status=PackagePublishingStatus.PUBLISHED)2370 pocket=pocket, status=PackagePublishingStatus.PUBLISHED)
23732371
=== modified file 'lib/lp/soyuz/scripts/tests/test_publishdistro.py'
--- lib/lp/soyuz/scripts/tests/test_publishdistro.py 2010-03-09 07:29:18 +0000
+++ lib/lp/soyuz/scripts/tests/test_publishdistro.py 2010-08-16 22:07:55 +0000
@@ -72,7 +72,6 @@
7272
73 rc, out, err = self.runPublishDistroScript()73 rc, out, err = self.runPublishDistroScript()
7474
75 pub_source.sync()
76 self.assertEqual(0, rc, "Publisher failed with:\n%s\n%s" % (out, err))75 self.assertEqual(0, rc, "Publisher failed with:\n%s\n%s" % (out, err))
77 self.assertEqual(pub_source.status, PackagePublishingStatus.PUBLISHED)76 self.assertEqual(pub_source.status, PackagePublishingStatus.PUBLISHED)
7877
@@ -88,7 +87,6 @@
88 pub_source = self.getPubSource(filecontent='foo')87 pub_source = self.getPubSource(filecontent='foo')
89 self.layer.txn.commit()88 self.layer.txn.commit()
90 self.runPublishDistro()89 self.runPublishDistro()
91 pub_source.sync()
9290
93 random_person = getUtility(IPersonSet).getByName('name16')91 random_person = getUtility(IPersonSet).getByName('name16')
94 pub_source.requestDeletion(random_person)92 pub_source.requestDeletion(random_person)
@@ -96,7 +94,6 @@
96 self.assertTrue(pub_source.scheduleddeletiondate is None,94 self.assertTrue(pub_source.scheduleddeletiondate is None,
97 "pub_source.scheduleddeletiondate should not be set, and it is.")95 "pub_source.scheduleddeletiondate should not be set, and it is.")
98 self.runPublishDistro()96 self.runPublishDistro()
99 pub_source.sync()
100 self.assertTrue(pub_source.scheduleddeletiondate is not None,97 self.assertTrue(pub_source.scheduleddeletiondate is not None,
101 "pub_source.scheduleddeletiondate should be set, and it's not.")98 "pub_source.scheduleddeletiondate should be set, and it's not.")
10299
@@ -123,8 +120,6 @@
123120
124 self.runPublishDistro(['-s', 'hoary-test'])121 self.runPublishDistro(['-s', 'hoary-test'])
125122
126 pub_source.sync()
127 pub_source2.sync()
128 self.assertEqual(pub_source.status, PackagePublishingStatus.PENDING)123 self.assertEqual(pub_source.status, PackagePublishingStatus.PENDING)
129 self.assertEqual(124 self.assertEqual(
130 pub_source2.status, PackagePublishingStatus.PUBLISHED)125 pub_source2.status, PackagePublishingStatus.PUBLISHED)
@@ -212,9 +207,6 @@
212207
213 self.runPublishDistro(['--ppa'])208 self.runPublishDistro(['--ppa'])
214209
215 pub_source.sync()
216 pub_source2.sync()
217 pub_source3.sync()
218 self.assertEqual(pub_source.status, PackagePublishingStatus.PENDING)210 self.assertEqual(pub_source.status, PackagePublishingStatus.PENDING)
219 self.assertEqual(211 self.assertEqual(
220 pub_source2.status, PackagePublishingStatus.PUBLISHED)212 pub_source2.status, PackagePublishingStatus.PUBLISHED)
@@ -246,21 +238,19 @@
246 private=True, distribution=ubuntutest)238 private=True, distribution=ubuntutest)
247239
248 # Publish something to the private PPA:240 # Publish something to the private PPA:
249 pub_source = self.getPubSource(241 pub_source = self.getPubSource(
250 sourcename='baz', filecontent='baz', archive=private_ppa)242 sourcename='baz', filecontent='baz', archive=private_ppa)
251 self.layer.txn.commit()243 self.layer.txn.commit()
252244
253 # Try a plain PPA run, to ensure the private one is NOT published.245 # Try a plain PPA run, to ensure the private one is NOT published.
254 self.runPublishDistro(['--ppa'])246 self.runPublishDistro(['--ppa'])
255247
256 pub_source.sync()
257 self.assertEqual(pub_source.status, PackagePublishingStatus.PENDING)248 self.assertEqual(pub_source.status, PackagePublishingStatus.PENDING)
258249
259 # Now publish the private PPAs and make sure they are really250 # Now publish the private PPAs and make sure they are really
260 # published.251 # published.
261 self.runPublishDistro(['--private-ppa'])252 self.runPublishDistro(['--private-ppa'])
262253
263 pub_source.sync()
264 self.assertEqual(pub_source.status, PackagePublishingStatus.PUBLISHED)254 self.assertEqual(pub_source.status, PackagePublishingStatus.PUBLISHED)
265255
266 def testPublishPrimaryDebug(self):256 def testPublishPrimaryDebug(self):
@@ -288,8 +278,10 @@
288 # operation, see nascentupload-ddebs.txt.278 # operation, see nascentupload-ddebs.txt.
289 self.prepareBreezyAutotest()279 self.prepareBreezyAutotest()
290 pub_binaries = self.getPubBinaries(format=BinaryPackageFormat.DDEB)280 pub_binaries = self.getPubBinaries(format=BinaryPackageFormat.DDEB)
281 # changing the archive of a publication is not normally
282 # possible, so we have to use removeSecurityProxy.
291 for binary in pub_binaries:283 for binary in pub_binaries:
292 binary.archive = debug_archive284 removeSecurityProxy(binary).archive = debug_archive
293285
294 # Commit setup changes, so the script can operate on them.286 # Commit setup changes, so the script can operate on them.
295 self.layer.txn.commit()287 self.layer.txn.commit()
@@ -330,7 +322,7 @@
330 removeSecurityProxy(copy_archive).publish = True322 removeSecurityProxy(copy_archive).publish = True
331323
332 # Publish something.324 # Publish something.
333 pub_source = self.getPubSource(325 pub_source = self.getPubSource(
334 sourcename='baz', filecontent='baz', archive=copy_archive)326 sourcename='baz', filecontent='baz', archive=copy_archive)
335327
336 # Try a plain PPA run, to ensure the copy archive is not published.328 # Try a plain PPA run, to ensure the copy archive is not published.
337329
=== modified file 'lib/lp/soyuz/tests/test_binarypackagebuild.py'
--- lib/lp/soyuz/tests/test_binarypackagebuild.py 2010-08-04 13:30:49 +0000
+++ lib/lp/soyuz/tests/test_binarypackagebuild.py 2010-08-16 22:07:55 +0000
@@ -314,18 +314,18 @@
314 self.sources = []314 self.sources = []
315 gedit_src_hist = self.publisher.getPubSource(315 gedit_src_hist = self.publisher.getPubSource(
316 sourcename="gedit", status=PackagePublishingStatus.PUBLISHED)316 sourcename="gedit", status=PackagePublishingStatus.PUBLISHED)
317 self.builds += gedit_src_hist.createMissingBuilds()317 self.builds += list(gedit_src_hist.createMissingBuilds())
318 self.sources.append(gedit_src_hist)318 self.sources.append(gedit_src_hist)
319319
320 firefox_src_hist = self.publisher.getPubSource(320 firefox_src_hist = self.publisher.getPubSource(
321 sourcename="firefox", status=PackagePublishingStatus.PUBLISHED)321 sourcename="firefox", status=PackagePublishingStatus.PUBLISHED)
322 self.builds += firefox_src_hist.createMissingBuilds()322 self.builds += list(firefox_src_hist.createMissingBuilds())
323 self.sources.append(firefox_src_hist)323 self.sources.append(firefox_src_hist)
324324
325 gtg_src_hist = self.publisher.getPubSource(325 gtg_src_hist = self.publisher.getPubSource(
326 sourcename="getting-things-gnome",326 sourcename="getting-things-gnome",
327 status=PackagePublishingStatus.PUBLISHED)327 status=PackagePublishingStatus.PUBLISHED)
328 self.builds += gtg_src_hist.createMissingBuilds()328 self.builds += list(gtg_src_hist.createMissingBuilds())
329 self.sources.append(gtg_src_hist)329 self.sources.append(gtg_src_hist)
330330
331331
332332
=== modified file 'lib/lp/soyuz/tests/test_publish_archive_indexes.py'
--- lib/lp/soyuz/tests/test_publish_archive_indexes.py 2010-07-20 12:06:36 +0000
+++ lib/lp/soyuz/tests/test_publish_archive_indexes.py 2010-08-16 22:07:55 +0000
@@ -8,6 +8,10 @@
8import tempfile8import tempfile
9import unittest9import unittest
1010
11from zope.security.proxy import removeSecurityProxy
12
13from lp.soyuz.interfaces.binarypackagerelease import BinaryPackageFormat
14from lp.soyuz.interfaces.publishing import PackagePublishingPriority
11from lp.soyuz.tests.test_publishing import TestNativePublishingBase15from lp.soyuz.tests.test_publishing import TestNativePublishingBase
1216
1317
@@ -31,8 +35,14 @@
31 the package in question.35 the package in question.
32 """36 """
33 pub_source = self.getPubSource(37 pub_source = self.getPubSource(
38 sourcename='foo', dsc_binaries='foo-bin',
39 version='666', section='base',
34 builddepends='fooish', builddependsindep='pyfoo',40 builddepends='fooish', builddependsindep='pyfoo',
35 build_conflicts='bar', build_conflicts_indep='pybar')41 build_conflicts='bar', build_conflicts_indep='pybar',
42 dsc_maintainer_rfc822='Foo Bar <foo@bar.com>',
43 architecturehintlist='all', dsc_standards_version='3.6.2',
44 dsc_format='1.0', filename='foo_666.dsc',
45 filecontent='I do not care about sources.')
3646
37 self.assertEqual(47 self.assertEqual(
38 [u'Package: foo',48 [u'Package: foo',
@@ -52,16 +62,29 @@
52 u' 5913c3ad52c14a62e6ae7eef51f9ef42 28 foo_666.dsc'],62 u' 5913c3ad52c14a62e6ae7eef51f9ef42 28 foo_666.dsc'],
53 pub_source.getIndexStanza().splitlines())63 pub_source.getIndexStanza().splitlines())
5464
65 def getPubSourceForBinary(self):
66 return self.getPubSource(
67 sourcename='foo', dsc_maintainer_rfc822='Foo Bar <foo@bar.com>')
68
55 def testBinaryStanza(self):69 def testBinaryStanza(self):
56 """Check just-created binary publication Index stanza.70 """Check just-created binary publication Index stanza.
5771
58 See also testSourceStanza, it must present something similar for72 See also testSourceStanza, it must present something similar for
59 binary packages.73 binary packages.
60 """74 """
75 pub_source = self.getPubSourceForBinary()
61 pub_binaries = self.getPubBinaries(76 pub_binaries = self.getPubBinaries(
77 binaryname='foo-bin',
78 priority=PackagePublishingPriority.STANDARD, section="base",
79 installed_size=100, architecturespecific=True,
80 version='666',
62 depends='biscuit', recommends='foo-dev', suggests='pyfoo',81 depends='biscuit', recommends='foo-dev', suggests='pyfoo',
63 conflicts='old-foo', replaces='old-foo', provides='foo-master',82 conflicts='old-foo', replaces='old-foo', provides='foo-master',
64 pre_depends='master-foo', enhances='foo-super', breaks='old-foo')83 pre_depends='master-foo', enhances='foo-super', breaks='old-foo',
84 filecontent='bbbiiinnnaaarrryyy', summary='Foo app is great',
85 format=BinaryPackageFormat.DEB,
86 description='Well ...\nit does nothing, though',
87 pub_source=pub_source)
65 pub_binary = pub_binaries[0]88 pub_binary = pub_binaries[0]
66 self.assertEqual(89 self.assertEqual(
67 [u'Package: foo-bin',90 [u'Package: foo-bin',
@@ -114,8 +137,15 @@
114 "Normal\nNormal"137 "Normal\nNormal"
115 "\n.\n.\n."138 "\n.\n.\n."
116 "\n %s" % ('x' * 100))139 "\n %s" % ('x' * 100))
140 pub_source = self.getPubSourceForBinary()
117 pub_binary = self.getPubBinaries(141 pub_binary = self.getPubBinaries(
118 description=description)[0]142 description=description, pub_source=pub_source,
143 binaryname='foo-bin',
144 priority=PackagePublishingPriority.STANDARD,
145 section="base", installed_size=100, architecturespecific=False,
146 format=BinaryPackageFormat.DEB,
147 version="666", filecontent="bbbiiinnnaaarrryyy",
148 summary='Foo app is great')[0]
119149
120 self.assertEqual(150 self.assertEqual(
121 [u'Package: foo-bin',151 [u'Package: foo-bin',
@@ -150,8 +180,14 @@
150 'utf-8' for disk writing.180 'utf-8' for disk writing.
151 """181 """
152 description = u'Using non-ascii as: \xe7\xe3\xe9\xf3'182 description = u'Using non-ascii as: \xe7\xe3\xe9\xf3'
183 pub_source = self.getPubSourceForBinary()
153 pub_binary = self.getPubBinaries(184 pub_binary = self.getPubBinaries(
154 description=description)[0]185 description=description, pub_source=pub_source,
186 binaryname='foo-bin',
187 priority=PackagePublishingPriority.STANDARD, section="base",
188 installed_size=100, architecturespecific=False,
189 version="666", format=BinaryPackageFormat.DEB,
190 filecontent='bbbiiinnnaaarrryyy', summary='Foo app is great')[0]
155191
156 self.assertEqual(192 self.assertEqual(
157 [u'Package: foo-bin',193 [u'Package: foo-bin',
@@ -200,7 +236,9 @@
200236
201 def test_getIndexStanza_binary_stanza(self):237 def test_getIndexStanza_binary_stanza(self):
202 """Check a binary stanza with APT parser."""238 """Check a binary stanza with APT parser."""
203 pub_binary = self.getPubBinaries()[0]239 pub_binary = self.getPubBinaries(
240 binaryname='foo-bin', summary='Foo app is great',
241 description='Well ...\n it does nothing, though')[0]
204242
205 parser = self.write_stanza_and_reparse(pub_binary.getIndexStanza())243 parser = self.write_stanza_and_reparse(pub_binary.getIndexStanza())
206244
@@ -211,7 +249,8 @@
211249
212 def test_getIndexStanza_source_stanza(self):250 def test_getIndexStanza_source_stanza(self):
213 """Check a source stanza with APT parser."""251 """Check a source stanza with APT parser."""
214 pub_source = self.getPubSource()252 pub_source = self.getPubSource(
253 sourcename="foo", dsc_maintainer_rfc822='Foo Bar <foo@bar.com>')
215254
216 parser = self.write_stanza_and_reparse(pub_source.getIndexStanza())255 parser = self.write_stanza_and_reparse(pub_source.getIndexStanza())
217256
@@ -243,12 +282,11 @@
243 This test can be removed if the parser is fixed and the corrupt282 This test can be removed if the parser is fixed and the corrupt
244 data has been cleaned.283 data has been cleaned.
245 """284 """
246 pub_source = self.getPubSource()
247
248 # An example of a corrupt dsc_binaries field. We need to ensure285 # An example of a corrupt dsc_binaries field. We need to ensure
249 # that the corruption is not carried over into the index stanza.286 # that the corruption is not carried over into the index stanza.
250 pub_source.sourcepackagerelease.dsc_binaries = (287 pub_source = self.getPubSource(
251 'foo_bin,\nbar_bin,\nzed_bin')288 sourcename="foo", version="666",
289 dsc_binaries="foo_bin,\nbar_bin,\nzed_bin")
252290
253 parser = self.write_stanza_and_reparse(pub_source.getIndexStanza())291 parser = self.write_stanza_and_reparse(pub_source.getIndexStanza())
254292
@@ -278,24 +316,16 @@
278 the binary field in the same way that apt_pkg.ParseTagFiles would,316 the binary field in the same way that apt_pkg.ParseTagFiles would,
279 that it will continue to be written correctly to index files.317 that it will continue to be written correctly to index files.
280 """318 """
281 pub_source = self.getPubSource()319 pub_source = self.getPubSource(
282320 sourcename='foo', version="666",
283 # An example of a corrupt dsc_binaries field. We need to ensure321 dsc_binaries='foo_bin,\n bar_bin,\n zed_bin')
284 # that the corruption is not carried over into the index stanza.
285 pub_source.sourcepackagerelease.dsc_binaries = (
286 'foo_bin,\n bar_bin,\n zed_bin')
287322
288 parser = self.write_stanza_and_reparse(pub_source.getIndexStanza())323 parser = self.write_stanza_and_reparse(pub_source.getIndexStanza())
289324
290 self.assertEqual('foo', parser.Section['Package'])325 self.assertEqual('foo', parser.Section['Package'])
291
292 # Without the fix, this raises a key-error due to apt-pkg not
293 # being able to parse the file.
294 self.assertEqual(326 self.assertEqual(
295 '666', parser.Section['Version'],327 '666', parser.Section['Version'],
296 'The Version field should be parsed correctly.')328 'The Version field should be parsed correctly.')
297
298 # Without the fix, the second binary would not be parsed at all.
299 self.assertEqual(329 self.assertEqual(
300 'foo_bin,\n bar_bin,\n zed_bin', parser.Section['Binary'])330 'foo_bin,\n bar_bin,\n zed_bin', parser.Section['Binary'])
301331
302332
=== modified file 'lib/lp/soyuz/tests/test_publishing.py'
--- lib/lp/soyuz/tests/test_publishing.py 2010-08-12 14:03:47 +0000
+++ lib/lp/soyuz/tests/test_publishing.py 2010-08-16 22:07:55 +0000
@@ -13,11 +13,10 @@
13import transaction13import transaction
14import pytz14import pytz
15from zope.component import getUtility15from zope.component import getUtility
16from zope.security.proxy import removeSecurityProxy16from zope.security.proxy import isinstance, removeSecurityProxy
1717
18from canonical.config import config18from canonical.config import config
19from canonical.database.constants import UTC_NOW19from canonical.database.constants import UTC_NOW
20from canonical.launchpad.interfaces.librarian import ILibraryFileAliasSet
21from canonical.launchpad.webapp.errorlog import ErrorReportingUtility20from canonical.launchpad.webapp.errorlog import ErrorReportingUtility
22from canonical.testing.layers import reconnect_stores21from canonical.testing.layers import reconnect_stores
23from canonical.testing import (22from canonical.testing import (
@@ -34,21 +33,18 @@
34from lp.registry.interfaces.sourcepackage import SourcePackageUrgency33from lp.registry.interfaces.sourcepackage import SourcePackageUrgency
35from lp.registry.interfaces.sourcepackagename import ISourcePackageNameSet34from lp.registry.interfaces.sourcepackagename import ISourcePackageNameSet
36from lp.soyuz.model.processor import ProcessorFamily35from lp.soyuz.model.processor import ProcessorFamily
37from lp.soyuz.model.publishing import (36from lp.soyuz.model.publishing import BinaryPackagePublishingHistory
38 SourcePackagePublishingHistory, BinaryPackagePublishingHistory)
39from lp.soyuz.interfaces.archive import ArchivePurpose, IArchiveSet37from lp.soyuz.interfaces.archive import ArchivePurpose, IArchiveSet
40from lp.soyuz.interfaces.archivearch import IArchiveArchSet38from lp.soyuz.interfaces.archivearch import IArchiveArchSet
41from lp.soyuz.interfaces.binarypackagename import IBinaryPackageNameSet
42from lp.soyuz.interfaces.binarypackagerelease import BinaryPackageFormat39from lp.soyuz.interfaces.binarypackagerelease import BinaryPackageFormat
43from lp.soyuz.interfaces.component import IComponentSet40from lp.soyuz.interfaces.component import IComponentSet
44from lp.soyuz.interfaces.section import ISectionSet
45from lp.soyuz.interfaces.publishing import (41from lp.soyuz.interfaces.publishing import (
46 IPublishingSet, PackagePublishingPriority, PackagePublishingStatus)42 IPublishingSet, PackagePublishingPriority, PackagePublishingStatus)
47from lp.soyuz.interfaces.queue import PackageUploadStatus43from lp.soyuz.interfaces.queue import PackageUploadStatus
48from canonical.launchpad.scripts import FakeLogger44from canonical.launchpad.scripts import FakeLogger
49from lp.testing import TestCaseWithFactory45from lp.testing import TestCaseWithFactory
50from lp.testing.factory import (46from lp.testing.factory import LaunchpadObjectFactory
51 LaunchpadObjectFactory, remove_security_proxy_and_shout_at_engineer)47from lp.testing.sampledata import UBUNTU_DEVELOPER_ADMIN_NAME
52from lp.testing.fakemethod import FakeMethod48from lp.testing.fakemethod import FakeMethod
5349
5450
@@ -77,7 +73,8 @@
77 distroseries = self.factory.makeDistroRelease()73 distroseries = self.factory.makeDistroRelease()
78 self.distroseries = distroseries74 self.distroseries = distroseries
79 # Set up a person that has a GPG key.75 # Set up a person that has a GPG key.
80 self.person = getUtility(IPersonSet).getByName('name16')76 self.person = getUtility(IPersonSet).getByName(
77 UBUNTU_DEVELOPER_ADMIN_NAME)
81 # Make sure the name exists in the database, to make it easier78 # Make sure the name exists in the database, to make it easier
82 # to get packages from distributions and distro series.79 # to get packages from distributions and distro series.
83 name_set = getUtility(ISourcePackageNameSet)80 name_set = getUtility(ISourcePackageNameSet)
@@ -126,35 +123,28 @@
126 self.breezy_autotest_i386 = self.breezy_autotest['i386']123 self.breezy_autotest_i386 = self.breezy_autotest['i386']
127 self.breezy_autotest_hppa = self.breezy_autotest['hppa']124 self.breezy_autotest_hppa = self.breezy_autotest['hppa']
128125
129 def addMockFile(self, filename, filecontent='nothing', restricted=False):126 def addMockFile(self, filename, filecontent='nothing', restricted=False,
127 expires=None):
130 """Add a mock file in Librarian.128 """Add a mock file in Librarian.
131129
132 Returns a ILibraryFileAlias corresponding to the file uploaded.130 Returns a ILibraryFileAlias corresponding to the file uploaded.
133 """131 """
134 library_file = getUtility(ILibraryFileAliasSet).create(132 return self.factory.makeLibraryFileAlias(
135 filename, len(filecontent), StringIO(filecontent),133 filename=filename, content=filecontent, restricted=restricted,
136 'application/text', restricted=restricted)134 content_type='application/text', expires=expires)
137 return library_file
138135
139 def addPackageUpload(self, archive, distroseries,136 def addPackageUpload(self, archive, distroseries,
140 pocket=PackagePublishingPocket.RELEASE,137 pocket=PackagePublishingPocket.RELEASE,
141 changes_file_name="foo_666_source.changes",138 changes_file_name="foo_666_source.changes",
142 changes_file_content="fake changes file content",139 changes_file_content="fake changes file content",
143 upload_status=PackageUploadStatus.DONE):140 upload_status=PackageUploadStatus.DONE):
144 signing_key = self.person.gpg_keys[0]141 person = self.factory.makePerson()
145 package_upload = distroseries.createQueueEntry(142 signing_key = self.factory.makeGPGKey(person)
146 pocket, changes_file_name, changes_file_content, archive,143 package_upload = self.factory.makePackageUpload(
147 signing_key)144 archive=archive, distroseries=distroseries, pocket=pocket,
148145 changes_filename=changes_file_name,
149 status_to_method = {146 changes_file_content=changes_file_content,
150 PackageUploadStatus.DONE: 'setDone',147 signing_key=signing_key, status=upload_status)
151 PackageUploadStatus.ACCEPTED: 'setAccepted',
152 }
153 naked_package_upload = removeSecurityProxy(package_upload)
154 method = getattr(
155 naked_package_upload, status_to_method[upload_status])
156 method()
157
158 return package_upload148 return package_upload
159149
160 def getPubSource(self, sourcename=None, version='666', component='main',150 def getPubSource(self, sourcename=None, version='666', component='main',
@@ -172,7 +162,8 @@
172 build_conflicts_indep=None,162 build_conflicts_indep=None,
173 dsc_maintainer_rfc822='Foo Bar <foo@bar.com>',163 dsc_maintainer_rfc822='Foo Bar <foo@bar.com>',
174 maintainer=None, creator=None, date_uploaded=UTC_NOW,164 maintainer=None, creator=None, date_uploaded=UTC_NOW,
175 spr_only=False):165 spr_only=False, files_expire=None,
166 changelog_entry=None):
176 """Return a mock source publishing record.167 """Return a mock source publishing record.
177168
178 if spr_only is specified, the source is not published and the169 if spr_only is specified, the source is not published and the
@@ -180,26 +171,35 @@
180 """171 """
181 if sourcename is None:172 if sourcename is None:
182 sourcename = self.default_package_name173 sourcename = self.default_package_name
183 spn = getUtility(ISourcePackageNameSet).getOrCreateByName(sourcename)174 spn = self.factory.getOrMakeSourcePackageName(name=sourcename)
184175 component = self.factory.makeComponent(name=component)
185 component = getUtility(IComponentSet)[component]
186 section = getUtility(ISectionSet)[section]
187176
188 if distroseries is None:177 if distroseries is None:
189 distroseries = self.distroseries178 distroseries = self.distroseries
190 if archive is None:179 if archive is None:
191 archive = distroseries.main_archive180 archive = distroseries.main_archive
192 if maintainer is None:
193 maintainer = self.person
194 if creator is None:181 if creator is None:
195 creator = self.person182 creator = self.factory.makePerson()
196183 self.factory.makeGPGKey(creator)
197 spr = distroseries.createUploadedSourcePackageRelease(184
185 changes_file_name = "%s_%s_source.changes" % (sourcename, version)
186 if spr_only:
187 upload_status = PackageUploadStatus.ACCEPTED
188 else:
189 upload_status = PackageUploadStatus.DONE
190 package_upload = self.addPackageUpload(
191 archive, distroseries, pocket,
192 changes_file_name=changes_file_name,
193 changes_file_content=changes_file_content,
194 upload_status=upload_status)
195
196 spr = self.factory.makeSourcePackageRelease(
197 distroseries=distroseries,
198 sourcepackagename=spn,198 sourcepackagename=spn,
199 maintainer=maintainer,199 maintainer=maintainer,
200 creator=creator,200 creator=creator,
201 component=component,201 component=component,
202 section=section,202 section_name=section,
203 urgency=urgency,203 urgency=urgency,
204 version=version,204 version=version,
205 builddepends=builddepends,205 builddepends=builddepends,
@@ -207,58 +207,39 @@
207 build_conflicts=build_conflicts,207 build_conflicts=build_conflicts,
208 build_conflicts_indep=build_conflicts_indep,208 build_conflicts_indep=build_conflicts_indep,
209 architecturehintlist=architecturehintlist,209 architecturehintlist=architecturehintlist,
210 changelog=None,210 dscsigningkey=creator.gpg_keys[0],
211 changelog_entry=None,
212 dsc=None,
213 copyright='placeholder ...',
214 dscsigningkey=self.person.gpg_keys[0],
215 dsc_maintainer_rfc822=dsc_maintainer_rfc822,211 dsc_maintainer_rfc822=dsc_maintainer_rfc822,
216 dsc_standards_version=dsc_standards_version,212 dsc_standards_version=dsc_standards_version,
217 dsc_format=dsc_format,213 dsc_format=dsc_format,
218 dsc_binaries=dsc_binaries,214 dsc_binaries=dsc_binaries,
219 archive=archive, dateuploaded=date_uploaded)215 archive=archive,
220216 date_uploaded=date_uploaded,
221 changes_file_name = "%s_%s_source.changes" % (sourcename, version)217 changelog_entry=changelog_entry,
222 if spr_only:218 )
223 upload_status = PackageUploadStatus.ACCEPTED219 removeSecurityProxy(package_upload).addSource(spr)
224 else:
225 upload_status = PackageUploadStatus.DONE
226 package_upload = self.addPackageUpload(
227 archive, distroseries, pocket,
228 changes_file_name=changes_file_name,
229 changes_file_content=changes_file_content,
230 upload_status=upload_status)
231 naked_package_upload = removeSecurityProxy(
232 package_upload)
233 naked_package_upload.addSource(spr)
234220
235 if filename is None:221 if filename is None:
236 filename = "%s_%s.dsc" % (sourcename, version)222 filename = "%s_%s.dsc" % (sourcename, version)
237 alias = self.addMockFile(223 alias = self.addMockFile(
238 filename, filecontent, restricted=archive.private)224 filename, filecontent, restricted=archive.private,
225 expires=files_expire)
239 spr.addFile(alias)226 spr.addFile(alias)
240227
241 if spr_only:228 if spr_only:
242 return spr229 return spr
243230
244 if status == PackagePublishingStatus.PUBLISHED:231 spph = self.factory.makeSourcePackagePublishingHistory(
245 datepublished = UTC_NOW
246 else:
247 datepublished = None
248
249 spph = SourcePackagePublishingHistory(
250 distroseries=distroseries,232 distroseries=distroseries,
251 sourcepackagerelease=spr,233 sourcepackagerelease=spr,
252 component=spr.component,234 component=spr.component,
253 section=spr.section,235 section_name=spr.section.name,
254 status=status,236 status=status,
255 datecreated=date_uploaded,237 date_uploaded=date_uploaded,
256 dateremoved=dateremoved,238 dateremoved=dateremoved,
257 datepublished=datepublished,
258 scheduleddeletiondate=scheduleddeletiondate,239 scheduleddeletiondate=scheduleddeletiondate,
259 pocket=pocket,240 pocket=pocket,
260 archive=archive)241 archive=archive,
261242 )
262 return spph243 return spph
263244
264 def getPubBinaries(self, binaryname='foo-bin', summary='Foo app is great',245 def getPubBinaries(self, binaryname='foo-bin', summary='Foo app is great',
@@ -279,7 +260,11 @@
279 architecturespecific=False,260 architecturespecific=False,
280 builder=None,261 builder=None,
281 component='main',262 component='main',
282 with_debug=False):263 section='base',
264 priority=PackagePublishingPriority.STANDARD,
265 installed_size=100, files_expire=None,
266 with_debug=False,
267 ):
283 """Return a list of binary publishing records."""268 """Return a list of binary publishing records."""
284 if distroseries is None:269 if distroseries is None:
285 distroseries = self.distroseries270 distroseries = self.distroseries
@@ -298,7 +283,7 @@
298 sourcename=sourcename, status=status, pocket=pocket,283 sourcename=sourcename, status=status, pocket=pocket,
299 archive=archive, distroseries=distroseries,284 archive=archive, distroseries=distroseries,
300 version=version, architecturehintlist=architecturehintlist,285 version=version, architecturehintlist=architecturehintlist,
301 component=component)286 component=component, files_expire=files_expire)
302 else:287 else:
303 archive = pub_source.archive288 archive = pub_source.archive
304289
@@ -323,10 +308,12 @@
323 build, binaryname, filecontent, summary, description,308 build, binaryname, filecontent, summary, description,
324 shlibdep, depends, recommends, suggests, conflicts, replaces,309 shlibdep, depends, recommends, suggests, conflicts, replaces,
325 provides, pre_depends, enhances, breaks, format,310 provides, pre_depends, enhances, breaks, format,
326 binarypackagerelease_ddeb)311 installed_size=installed_size, component=component,
312 files_expire=files_expire,
313 debug_package=binarypackagerelease_ddeb)
327 pub_binaries += self.publishBinaryInArchive(314 pub_binaries += self.publishBinaryInArchive(
328 binarypackagerelease, archive, status, pocket,315 binarypackagerelease, archive, status, pocket,
329 scheduleddeletiondate, dateremoved)316 scheduleddeletiondate, dateremoved, section, priority)
330 published_binaries.extend(pub_binaries)317 published_binaries.extend(pub_binaries)
331 package_upload = self.addPackageUpload(318 package_upload = self.addPackageUpload(
332 archive, distroseries, pocket,319 archive, distroseries, pocket,
@@ -344,20 +331,21 @@
344 summary="summary", description="description", shlibdep=None,331 summary="summary", description="description", shlibdep=None,
345 depends=None, recommends=None, suggests=None, conflicts=None,332 depends=None, recommends=None, suggests=None, conflicts=None,
346 replaces=None, provides=None, pre_depends=None, enhances=None,333 replaces=None, provides=None, pre_depends=None, enhances=None,
347 breaks=None, format=BinaryPackageFormat.DEB, debug_package=None):334 breaks=None, format=BinaryPackageFormat.DEB, installed_size=None,
335 component=None, version=None, files_expire=None, debug_package=None):
348 """Return the corresponding `BinaryPackageRelease`."""336 """Return the corresponding `BinaryPackageRelease`."""
349 sourcepackagerelease = build.source_package_release337 sourcepackagerelease = build.source_package_release
350 distroarchseries = build.distro_arch_series338 distroarchseries = build.distro_arch_series
351 architecturespecific = (339 architecturespecific = (
352 not sourcepackagerelease.architecturehintlist == 'all')340 not sourcepackagerelease.architecturehintlist == 'all')
353341 if component is not None:
354 binarypackagename = getUtility(342 component = self.factory.makeComponent(name=component)
355 IBinaryPackageNameSet).getOrCreateByName(binaryname)343
356344 binarypackagename = self.factory.getOrMakeBinaryPackageName(
357 binarypackagerelease = build.createBinaryPackageRelease(345 name=binaryname)
358 version=sourcepackagerelease.version,346
359 component=sourcepackagerelease.component,347 binarypackagerelease = self.factory.makeBinaryPackageRelease(
360 section=sourcepackagerelease.section,348 build=build,
361 binarypackagename=binarypackagename,349 binarypackagename=binarypackagename,
362 summary=summary,350 summary=summary,
363 description=description,351 description=description,
@@ -372,11 +360,14 @@
372 enhances=enhances,360 enhances=enhances,
373 breaks=breaks,361 breaks=breaks,
374 essential=False,362 essential=False,
375 installedsize=100,
376 architecturespecific=architecturespecific,363 architecturespecific=architecturespecific,
377 binpackageformat=format,364 binpackageformat=format,
378 priority=PackagePublishingPriority.STANDARD,365 priority=PackagePublishingPriority.STANDARD,
379 debug_package=debug_package)366 installed_size=installed_size,
367 component=component,
368 version=version,
369 debug_package=debug_package,
370 )
380371
381 # Create the corresponding binary file.372 # Create the corresponding binary file.
382 if architecturespecific:373 if architecturespecific:
@@ -387,7 +378,7 @@
387 filearchtag, format.name.lower())378 filearchtag, format.name.lower())
388 alias = self.addMockFile(379 alias = self.addMockFile(
389 filename, filecontent=filecontent,380 filename, filecontent=filecontent,
390 restricted=build.archive.private)381 restricted=build.archive.private, expires=files_expire)
391 binarypackagerelease.addFile(alias)382 binarypackagerelease.addFile(alias)
392383
393 # Adjust the build record in way it looks complete.384 # Adjust the build record in way it looks complete.
@@ -414,7 +405,8 @@
414 self, binarypackagerelease, archive,405 self, binarypackagerelease, archive,
415 status=PackagePublishingStatus.PENDING,406 status=PackagePublishingStatus.PENDING,
416 pocket=PackagePublishingPocket.RELEASE,407 pocket=PackagePublishingPocket.RELEASE,
417 scheduleddeletiondate=None, dateremoved=None):408 scheduleddeletiondate=None, dateremoved=None, section=None,
409 priority=None, component=None):
418 """Return the corresponding BinaryPackagePublishingHistory."""410 """Return the corresponding BinaryPackagePublishingHistory."""
419 distroarchseries = binarypackagerelease.build.distro_arch_series411 distroarchseries = binarypackagerelease.build.distro_arch_series
420412
@@ -426,20 +418,17 @@
426418
427 pub_binaries = []419 pub_binaries = []
428 for arch in archs:420 for arch in archs:
429 pub = BinaryPackagePublishingHistory(421 pub = self.factory.makeBinaryPackagePublishingHistory(
430 distroarchseries=arch,422 distroarchseries=arch,
431 binarypackagerelease=binarypackagerelease,423 binarypackagerelease=binarypackagerelease,
432 component=binarypackagerelease.component,
433 section=binarypackagerelease.section,
434 priority=binarypackagerelease.priority,
435 status=status,424 status=status,
436 scheduleddeletiondate=scheduleddeletiondate,425 scheduleddeletiondate=scheduleddeletiondate,
437 dateremoved=dateremoved,426 dateremoved=dateremoved,
438 datecreated=UTC_NOW,
439 pocket=pocket,427 pocket=pocket,
440 archive=archive)428 archive=archive,
441 if status == PackagePublishingStatus.PUBLISHED:429 section_name=section,
442 pub.datepublished = UTC_NOW430 priority=priority,
431 )
443 pub_binaries.append(pub)432 pub_binaries.append(pub)
444433
445 return pub_binaries434 return pub_binaries
@@ -455,7 +444,7 @@
455444
456 def createSource(445 def createSource(
457 self, archive, sourcename, version, distroseries=None,446 self, archive, sourcename, version, distroseries=None,
458 new_version=None):447 new_version=None, component='main'):
459 """Create source with meaningful '.changes' file."""448 """Create source with meaningful '.changes' file."""
460 top = 'lib/lp/archiveuploader/tests/data/suite'449 top = 'lib/lp/archiveuploader/tests/data/suite'
461 name_fragment = '%s_%s' % (sourcename, version)450 name_fragment = '%s_%s' % (sourcename, version)
@@ -476,7 +465,7 @@
476 source = self.getPubSource(465 source = self.getPubSource(
477 sourcename=sourcename, archive=archive, version=new_version,466 sourcename=sourcename, archive=archive, version=new_version,
478 changes_file_content=changesfile_content,467 changes_file_content=changesfile_content,
479 distroseries=distroseries)468 distroseries=distroseries, component=component)
480469
481 return source470 return source
482471
@@ -691,7 +680,6 @@
691 self.layer.commit()680 self.layer.commit()
692681
693 foo_name = "%s/main/f/foo/foo_666.dsc" % self.pool_dir682 foo_name = "%s/main/f/foo/foo_666.dsc" % self.pool_dir
694 pub_source.sync()
695 self.assertEqual(683 self.assertEqual(
696 pub_source.status, PackagePublishingStatus.PUBLISHED)684 pub_source.status, PackagePublishingStatus.PUBLISHED)
697 self.assertEqual(open(foo_name).read().strip(), 'foo is happy')685 self.assertEqual(open(foo_name).read().strip(), 'foo is happy')
@@ -703,7 +691,6 @@
703 pub_source2.publish(self.disk_pool, self.logger)691 pub_source2.publish(self.disk_pool, self.logger)
704 self.layer.commit()692 self.layer.commit()
705693
706 pub_source2.sync()
707 self.assertEqual(694 self.assertEqual(
708 pub_source2.status, PackagePublishingStatus.PENDING)695 pub_source2.status, PackagePublishingStatus.PENDING)
709 self.assertEqual(open(foo_name).read().strip(), 'foo is happy')696 self.assertEqual(open(foo_name).read().strip(), 'foo is happy')
@@ -720,7 +707,6 @@
720 self.layer.commit()707 self.layer.commit()
721 bar_name = "%s/main/b/bar/bar_666.dsc" % self.pool_dir708 bar_name = "%s/main/b/bar/bar_666.dsc" % self.pool_dir
722 self.assertEqual(open(bar_name).read().strip(), 'bar is good')709 self.assertEqual(open(bar_name).read().strip(), 'bar is good')
723 pub_source.sync()
724 self.assertEqual(710 self.assertEqual(
725 pub_source.status, PackagePublishingStatus.PUBLISHED)711 pub_source.status, PackagePublishingStatus.PUBLISHED)
726712
@@ -728,7 +714,6 @@
728 sourcename='bar', filecontent='bar is good')714 sourcename='bar', filecontent='bar is good')
729 pub_source2.publish(self.disk_pool, self.logger)715 pub_source2.publish(self.disk_pool, self.logger)
730 self.layer.commit()716 self.layer.commit()
731 pub_source2.sync()
732 self.assertEqual(717 self.assertEqual(
733 pub_source2.status, PackagePublishingStatus.PUBLISHED)718 pub_source2.status, PackagePublishingStatus.PUBLISHED)
734719
@@ -748,8 +733,6 @@
748 pub_source2.publish(self.disk_pool, self.logger)733 pub_source2.publish(self.disk_pool, self.logger)
749 self.layer.commit()734 self.layer.commit()
750735
751 pub_source.sync()
752 pub_source2.sync()
753 self.assertEqual(736 self.assertEqual(
754 pub_source.status, PackagePublishingStatus.PUBLISHED)737 pub_source.status, PackagePublishingStatus.PUBLISHED)
755 self.assertEqual(738 self.assertEqual(
@@ -768,7 +751,6 @@
768 pub_source3.publish(self.disk_pool, self.logger)751 pub_source3.publish(self.disk_pool, self.logger)
769 self.layer.commit()752 self.layer.commit()
770753
771 pub_source3.sync()
772 self.assertEqual(754 self.assertEqual(
773 pub_source3.status, PackagePublishingStatus.PENDING)755 pub_source3.status, PackagePublishingStatus.PENDING)
774756
@@ -789,7 +771,6 @@
789 pub_source.publish(test_disk_pool, self.logger)771 pub_source.publish(test_disk_pool, self.logger)
790 self.layer.commit()772 self.layer.commit()
791773
792 pub_source.sync()
793 self.assertEqual(pub_source.status, PackagePublishingStatus.PUBLISHED)774 self.assertEqual(pub_source.status, PackagePublishingStatus.PUBLISHED)
794 self.assertEqual(pub_source.sourcepackagerelease.upload_archive,775 self.assertEqual(pub_source.sourcepackagerelease.upload_archive,
795 cprov.archive)776 cprov.archive)
@@ -833,17 +814,21 @@
833 'Cannot override published records.',814 'Cannot override published records.',
834 source.overrideFromAncestry)815 source.overrideFromAncestry)
835816
836 def makeSource(self):817 def makeSource(self, source_component='main', binary_component='main'):
837 """Return a 'source' publication.818 """Return a 'source' publication.
838819
839 It's pending publication with binaries in a brand new PPA820 It's pending publication with binaries in a brand new PPA
840 and in 'main' component.821 and in 'main' component, unless otherwise specified. The binaries
822 can be placed in a different component to the source by
823 passing binary_component different to source_component.
841 """824 """
842 test_archive = self.factory.makeArchive(825 test_archive = self.factory.makeArchive(
843 distribution=self.test_publisher.ubuntutest,826 distribution=self.test_publisher.ubuntutest,
844 purpose = ArchivePurpose.PPA)827 purpose = ArchivePurpose.PPA)
845 source = self.test_publisher.getPubSource(archive=test_archive)828 source = self.test_publisher.getPubSource(
846 self.test_publisher.getPubBinaries(pub_source=source)829 archive=test_archive, component=source_component)
830 self.test_publisher.getPubBinaries(
831 pub_source=source, component=binary_component)
847 return source832 return source
848833
849 def copyAndCheck(self, pub_record, series, component_name):834 def copyAndCheck(self, pub_record, series, component_name):
@@ -871,23 +856,14 @@
871 def test_overrideFromAncestry_fallback_to_source_component(self):856 def test_overrideFromAncestry_fallback_to_source_component(self):
872 # overrideFromancestry on the lack of ancestry, falls back to the857 # overrideFromancestry on the lack of ancestry, falls back to the
873 # component the source was originally uploaded to.858 # component the source was originally uploaded to.
874 source = self.makeSource()859 source = self.makeSource(source_component='universe')
875
876 # Adjust the source package release original component.
877 universe = getUtility(IComponentSet)['universe']
878 source.sourcepackagerelease.component = universe
879
880 self.copyAndCheck(source, source.distroseries, 'universe')860 self.copyAndCheck(source, source.distroseries, 'universe')
881861
882 def test_overrideFromAncestry_fallback_to_binary_component(self):862 def test_overrideFromAncestry_fallback_to_binary_component(self):
883 # overrideFromAncestry on the lack of ancestry, falls back to the863 # overrideFromAncestry on the lack of ancestry, falls back to the
884 # component the binary was originally uploaded to.864 # component the binary was originally uploaded to.
885 binary = self.makeSource().getPublishedBinaries()[0]865 binary = self.makeSource(
886866 binary_component='universe').getPublishedBinaries()[0]
887 # Adjust the binary package release original component.
888 universe = getUtility(IComponentSet)['universe']
889 removeSecurityProxy(binary.binarypackagerelease).component = universe
890
891 self.copyAndCheck(867 self.copyAndCheck(
892 binary, binary.distroarchseries.distroseries, 'universe')868 binary, binary.distroarchseries.distroseries, 'universe')
893869
@@ -985,8 +961,9 @@
985 """961 """
986 available_archs = [self.sparc_distroarch, self.avr_distroarch]962 available_archs = [self.sparc_distroarch, self.avr_distroarch]
987 pubrec = self.getPubSource(architecturehintlist='any')963 pubrec = self.getPubSource(architecturehintlist='any')
964 naked_pubrec = removeSecurityProxy(pubrec)
988 self.assertEquals([self.sparc_distroarch],965 self.assertEquals([self.sparc_distroarch],
989 pubrec._getAllowedArchitectures(available_archs))966 naked_pubrec._getAllowedArchitectures(available_archs))
990967
991 def test__getAllowedArchitectures_restricted_override(self):968 def test__getAllowedArchitectures_restricted_override(self):
992 """Test _getAllowedArchitectures honors overrides of restricted archs.969 """Test _getAllowedArchitectures honors overrides of restricted archs.
@@ -997,8 +974,9 @@
997 available_archs = [self.sparc_distroarch, self.avr_distroarch]974 available_archs = [self.sparc_distroarch, self.avr_distroarch]
998 getUtility(IArchiveArchSet).new(self.archive, self.avr_family)975 getUtility(IArchiveArchSet).new(self.archive, self.avr_family)
999 pubrec = self.getPubSource(architecturehintlist='any')976 pubrec = self.getPubSource(architecturehintlist='any')
977 naked_pubrec = removeSecurityProxy(pubrec)
1000 self.assertEquals([self.sparc_distroarch, self.avr_distroarch],978 self.assertEquals([self.sparc_distroarch, self.avr_distroarch],
1001 pubrec._getAllowedArchitectures(available_archs))979 naked_pubrec._getAllowedArchitectures(available_archs))
1002980
1003 def test_createMissingBuilds_restricts_any(self):981 def test_createMissingBuilds_restricts_any(self):
1004 """createMissingBuilds() should limit builds targeted at 'any'982 """createMissingBuilds() should limit builds targeted at 'any'
1005983
=== modified file 'lib/lp/soyuz/tests/test_publishing_top_level_api.py'
--- lib/lp/soyuz/tests/test_publishing_top_level_api.py 2010-07-20 12:06:36 +0000
+++ lib/lp/soyuz/tests/test_publishing_top_level_api.py 2010-08-16 22:07:55 +0000
@@ -109,8 +109,6 @@
109 self._publish(pocket=pocket)109 self._publish(pocket=pocket)
110110
111 # source and binary PUBLISHED in database.111 # source and binary PUBLISHED in database.
112 pub_source.sync()
113 pub_bin.sync()
114 self.assertEqual(pub_source.status, PackagePublishingStatus.PUBLISHED)112 self.assertEqual(pub_source.status, PackagePublishingStatus.PUBLISHED)
115 self.assertEqual(pub_bin.status, PackagePublishingStatus.PUBLISHED)113 self.assertEqual(pub_bin.status, PackagePublishingStatus.PUBLISHED)
116114
117115
=== modified file 'lib/lp/testing/factory.py'
--- lib/lp/testing/factory.py 2010-08-16 22:07:51 +0000
+++ lib/lp/testing/factory.py 2010-08-16 22:07:55 +0000
@@ -2319,7 +2319,8 @@
2319 dsc_format='1.0', dsc_binaries='foo-bin',2319 dsc_format='1.0', dsc_binaries='foo-bin',
2320 date_uploaded=UTC_NOW,2320 date_uploaded=UTC_NOW,
2321 source_package_recipe_build=None,2321 source_package_recipe_build=None,
2322 dscsigningkey=None):2322 dscsigningkey=None,
2323 changelog_entry=None):
2323 """Make a `SourcePackageRelease`."""2324 """Make a `SourcePackageRelease`."""
2324 if distroseries is None:2325 if distroseries is None:
2325 if source_package_recipe_build is not None:2326 if source_package_recipe_build is not None:
@@ -2376,7 +2377,7 @@
2376 build_conflicts_indep=build_conflicts_indep,2377 build_conflicts_indep=build_conflicts_indep,
2377 architecturehintlist=architecturehintlist,2378 architecturehintlist=architecturehintlist,
2378 changelog=None,2379 changelog=None,
2379 changelog_entry=None,2380 changelog_entry=changelog_entry,
2380 dsc=None,2381 dsc=None,
2381 copyright=self.getUniqueString(),2382 copyright=self.getUniqueString(),
2382 dscsigningkey=dscsigningkey,2383 dscsigningkey=dscsigningkey,
@@ -2636,16 +2637,12 @@
2636 if installed_size is None:2637 if installed_size is None:
2637 installed_size = self.getUniqueInteger()2638 installed_size = self.getUniqueInteger()
2638 bpr = build.createBinaryPackageRelease(2639 bpr = build.createBinaryPackageRelease(
2639 binarypackagename=binarypackagename, version=version,2640 binarypackagename, version, summary, description,
2640 binpackageformat=binpackageformat,2641 binpackageformat, component, section, priority,
2641 component=component, section=section, priority=priority,2642 shlibdeps, depends, recommends, suggests, conflicts,
2642 summary=summary, description=description,2643 replaces, provides, pre_depends, enhances, breaks,
2643 architecturespecific=architecturespecific,2644 essential, installed_size, architecturespecific,
2644 shlibdeps=shlibdeps, depends=depends, recommends=recommends,2645 debug_package)
2645 suggests=suggests, conflicts=conflicts, replaces=replaces,
2646 provides=provides, pre_depends=pre_depends,
2647 enhances=enhances, breaks=breaks, essential=essential,
2648 installedsize=installed_size, debug_package=debug_package)
2649 if date_created is not None:2646 if date_created is not None:
2650 removeSecurityProxy(bpr).datecreated = date_created2647 removeSecurityProxy(bpr).datecreated = date_created
2651 return bpr2648 return bpr
26522649
=== modified file 'lib/lp/testing/tests/test_factory.py'
--- lib/lp/testing/tests/test_factory.py 2010-08-16 22:07:51 +0000
+++ lib/lp/testing/tests/test_factory.py 2010-08-16 22:07:55 +0000
@@ -458,6 +458,17 @@
458 dsc_maintainer_rfc822=maintainer)458 dsc_maintainer_rfc822=maintainer)
459 self.assertEqual(maintainer, spr.dsc_maintainer_rfc822)459 self.assertEqual(maintainer, spr.dsc_maintainer_rfc822)
460460
461 def test_makeSourcePackageRelease_allows_None_changelog_entry(self):
462 spr = self.factory.makeSourcePackageRelease(
463 changelog_entry=None)
464 self.assertEqual(None, spr.changelog_entry)
465
466 def test_makeSourcePackageRelease_uses_changelog_entry(self):
467 changelog_entry = "Best release evar!!1!1!"
468 spr = self.factory.makeSourcePackageRelease(
469 changelog_entry=changelog_entry)
470 self.assertEqual(changelog_entry, spr.changelog_entry)
471
461 # makeSuiteSourcePackage472 # makeSuiteSourcePackage
462 def test_makeSuiteSourcePackage_returns_ISuiteSourcePackage(self):473 def test_makeSuiteSourcePackage_returns_ISuiteSourcePackage(self):
463 ssp = self.factory.makeSuiteSourcePackage()474 ssp = self.factory.makeSuiteSourcePackage()