Merge lp:~cjwatson/launchpad/publish-proposed into lp:launchpad

Proposed by Colin Watson
Status: Merged
Approved by: Richard Harding
Approved revision: no longer in the source branch.
Merged at revision: 15068
Proposed branch: lp:~cjwatson/launchpad/publish-proposed
Merge into: lp:launchpad
Diff against target: 86 lines (+45/-3)
2 files modified
lib/lp/registry/model/distroseries.py (+5/-2)
lib/lp/registry/tests/test_distroseries.py (+40/-1)
To merge this branch: bzr merge lp:~cjwatson/launchpad/publish-proposed
Reviewer Review Type Date Requested Status
j.c.sackett (community) Approve
Richard Harding (community) code* Approve
Review via email: mp+100985@code.launchpad.net

Commit message

Fix publishing of pre-release uploads to the PROPOSED pocket.

Description of the change

== Summary ==

As reported in bug 974328, pre-release uploads to Ubuntu precise-proposed are accepted and built but cannot be published.

== Proposed fix ==

I basically just missed a case in my previous fix to allow using -proposed as a staging pocket, and need to permit it in checkLegalPocket as well for publishing.

== Implementation details ==

I'm +37 on LoC for this branch. I need to get this fixed fairly promptly if possible, so perhaps I could use some of the -531 credit from r15032 against this?

== Tests ==

bin/test -vvct checkLegalPocket

(I didn't see any more sensible place to test this, so it seemed best to just add unit tests at the finest possible granularity.)

== Demo and Q/A ==

I think we need an end-to-end test now to make sure there's nothing else, so:

 * Upload a test package (say, hello) to oneiric-proposed on dogfood. (oneiric is DEVELOPMENT there.)
 * Process the upload and wait for it to build everywhere.
 * Do a full publisher run. Ensure that it is actually published.
 * Copy the package to oneiric.
 * Do another full publisher run. Ensure that the copy is actually published.

(Unfortunately this will take a while, dogfood being what it is.)

== lint ==

None.

To post a comment you must log in.
Revision history for this message
Richard Harding (rharding) wrote :

Thanks for the update. Per the test style guide, please add docstrings to the tests.
https://dev.launchpad.net/TestsStyleGuide#line-416

I'm also tempted to ask that the test conditions match the name. It seems backwards that the test "forbids" and yet the assertion is assertTrue as in the tests that "allows".

The change itself looks fine though. Approving the MP with these suggestions.

review: Approve (code*)
Revision history for this message
Colin Watson (cjwatson) wrote :

Thanks, will do. And for the conditions: oh, err, the assertions ought to be assertFalse, which raises the question of why it's passing ... I'll look into that.

Revision history for this message
j.c.sackett (jcsackett) wrote :

This looks good to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/model/distroseries.py'
2--- lib/lp/registry/model/distroseries.py 2012-03-28 13:14:22 +0000
3+++ lib/lp/registry/model/distroseries.py 2012-04-05 15:54:19 +0000
4@@ -1646,8 +1646,11 @@
5 # we're not publishing packages into the wrong pocket.
6 # Unfortunately for careful mode that can't hold true
7 # because we indeed need to republish everything.
8- if (self.isUnstable() and
9- publication.pocket != PackagePublishingPocket.RELEASE):
10+ pre_release_pockets = (
11+ PackagePublishingPocket.RELEASE,
12+ PackagePublishingPocket.PROPOSED,
13+ )
14+ if self.isUnstable() and publication.pocket not in pre_release_pockets:
15 log.error("Tried to publish %s (%s) into a non-release "
16 "pocket on unstable series %s, skipping"
17 % (publication.displayname, publication.id,
18
19=== modified file 'lib/lp/registry/tests/test_distroseries.py'
20--- lib/lp/registry/tests/test_distroseries.py 2012-02-07 08:09:36 +0000
21+++ lib/lp/registry/tests/test_distroseries.py 2012-04-05 15:54:19 +0000
22@@ -1,4 +1,4 @@
23-# Copyright 2009-2011 Canonical Ltd. This software is licensed under the
24+# Copyright 2009-2012 Canonical Ltd. This software is licensed under the
25 # GNU Affero General Public License version 3 (see the file LICENSE).
26
27 """Tests for distroseries."""
28@@ -6,6 +6,7 @@
29 __metaclass__ = type
30
31 from datetime import timedelta
32+from logging import getLogger
33
34 import transaction
35 from zope.component import getUtility
36@@ -14,6 +15,7 @@
37 from lp.registry.errors import NoSuchDistroSeries
38 from lp.registry.interfaces.distroseries import IDistroSeriesSet
39 from lp.registry.interfaces.pocket import PackagePublishingPocket
40+from lp.registry.interfaces.series import SeriesStatus
41 from lp.services.utils import utc_now
42 from lp.soyuz.enums import (
43 ArchivePurpose,
44@@ -305,6 +307,43 @@
45 self.assertContentEqual(
46 [comment], distroseries.getDifferenceComments())
47
48+ def checkLegalPocket(self, status, pocket):
49+ distroseries = self.factory.makeDistroSeries(status=status)
50+ spph = self.factory.makeSourcePackagePublishingHistory(
51+ distroseries=distroseries, pocket=pocket)
52+ return removeSecurityProxy(distroseries).checkLegalPocket(
53+ spph, False, getLogger())
54+
55+ def test_checkLegalPocket_allows_unstable_release(self):
56+ """Publishing to RELEASE in a DEVELOPMENT series is allowed."""
57+ self.assertTrue(self.checkLegalPocket(
58+ SeriesStatus.DEVELOPMENT, PackagePublishingPocket.RELEASE))
59+
60+ def test_checkLegalPocket_allows_unstable_proposed(self):
61+ """Publishing to PROPOSED in a DEVELOPMENT series is allowed."""
62+ self.assertTrue(self.checkLegalPocket(
63+ SeriesStatus.DEVELOPMENT, PackagePublishingPocket.PROPOSED))
64+
65+ def test_checkLegalPocket_forbids_unstable_updates(self):
66+ """Publishing to UPDATES in a DEVELOPMENT series is forbidden."""
67+ self.assertFalse(self.checkLegalPocket(
68+ SeriesStatus.DEVELOPMENT, PackagePublishingPocket.UPDATES))
69+
70+ def test_checkLegalPocket_forbids_stable_release(self):
71+ """Publishing to RELEASE in a DEVELOPMENT series is forbidden."""
72+ self.assertFalse(self.checkLegalPocket(
73+ SeriesStatus.CURRENT, PackagePublishingPocket.RELEASE))
74+
75+ def test_checkLegalPocket_allows_stable_proposed(self):
76+ """Publishing to PROPOSED in a DEVELOPMENT series is allowed."""
77+ self.assertTrue(self.checkLegalPocket(
78+ SeriesStatus.CURRENT, PackagePublishingPocket.PROPOSED))
79+
80+ def test_checkLegalPocket_allows_stable_updates(self):
81+ """Publishing to UPDATES in a DEVELOPMENT series is allowed."""
82+ self.assertTrue(self.checkLegalPocket(
83+ SeriesStatus.CURRENT, PackagePublishingPocket.UPDATES))
84+
85
86 class TestDistroSeriesPackaging(TestCaseWithFactory):
87