Merge lp:~cjwatson/launchpad/queue-api-fix-non-component-overrides into lp:launchpad

Proposed by Colin Watson
Status: Merged
Approved by: Steve Kowalik
Approved revision: no longer in the source branch.
Merged at revision: 15608
Proposed branch: lp:~cjwatson/launchpad/queue-api-fix-non-component-overrides
Merge into: lp:launchpad
Diff against target: 38 lines (+15/-2)
2 files modified
lib/lp/soyuz/model/queue.py (+4/-2)
lib/lp/soyuz/tests/test_packageupload.py (+11/-0)
To merge this branch: bzr merge lp:~cjwatson/launchpad/queue-api-fix-non-component-overrides
Reviewer Review Type Date Requested Status
Steve Kowalik (community) code Approve
Review via email: mp+114236@code.launchpad.net

Commit message

Fix PackageUpload.overrideSource to accept component=None.

Description of the change

== Summary ==

PackageUpload.overrideSource OOPSes when passed component=None.

== Proposed fix ==

This is a simple glitch in the handling of changing the archive when the source component changes, and just needs an if guard. There was already a test for this in the PCJ case, but not in the case of an ordinary upload; I cloned-and-hacked the PCJ test.

== LOC Rationale ==

+13. This is part of removing the queue tool, which will get me ~1000 lines of net credit.

== Tests ==

bin/test -vvct PackageUploadTestCase.test_overrideSource_ignores_None_component_change

== Demo and Q/A ==

Using lp:ubuntu-archive-tools, run something like 'queue -l dogfood -x some-section override some-source-package'.

To post a comment you must log in.
Revision history for this message
Steve Kowalik (stevenk) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/soyuz/model/queue.py'
2--- lib/lp/soyuz/model/queue.py 2012-07-06 16:17:57 +0000
3+++ lib/lp/soyuz/model/queue.py 2012-07-10 17:42:25 +0000
4@@ -1065,8 +1065,10 @@
5
6 # We override our own archive too, as it is used to create
7 # the SPPH during publish().
8- self.archive = self.distroseries.distribution.getArchiveByComponent(
9- new_component.name)
10+ if new_component is not None:
11+ distribution = self.distroseries.distribution
12+ self.archive = distribution.getArchiveByComponent(
13+ new_component.name)
14
15 return made_changes
16
17
18=== modified file 'lib/lp/soyuz/tests/test_packageupload.py'
19--- lib/lp/soyuz/tests/test_packageupload.py 2012-07-09 17:15:52 +0000
20+++ lib/lp/soyuz/tests/test_packageupload.py 2012-07-10 17:42:25 +0000
21@@ -395,6 +395,17 @@
22 [spph] = upload.realiseUpload()
23 self.assertEqual(spph.packageupload, upload)
24
25+ def test_overrideSource_ignores_None_component_change(self):
26+ # overrideSource accepts None as a component; it will not object
27+ # based on permissions for the new component.
28+ upload = self.factory.makeSourcePackageUpload()
29+ spr = upload.sourcepackagerelease
30+ current_component = spr.component
31+ new_section = self.factory.makeSection()
32+ upload.overrideSource(None, new_section, [current_component])
33+ self.assertEqual(current_component, spr.component)
34+ self.assertEqual(new_section, spr.section)
35+
36
37 class TestPackageUploadPrivacy(TestCaseWithFactory):
38 """Test PackageUpload security."""