Merge lp:~wgrant/launchpad/archive-debug-archive into lp:launchpad

Proposed by William Grant
Status: Merged
Merged at revision: not available
Proposed branch: lp:~wgrant/launchpad/archive-debug-archive
Merge into: lp:launchpad
Diff against target: 151 lines
4 files modified
lib/lp/soyuz/interfaces/archive.py (+3/-0)
lib/lp/soyuz/model/archive.py (+9/-0)
lib/lp/soyuz/model/queue.py (+6/-10)
lib/lp/soyuz/tests/test_archive.py (+53/-1)
To merge this branch: bzr merge lp:~wgrant/launchpad/archive-debug-archive
Reviewer Review Type Date Requested Status
Eleanor Berger (community) Approve
Review via email: mp+13949@code.launchpad.net
To post a comment you must log in.
Revision history for this message
William Grant (wgrant) wrote :

= Summary =

For my ddebs-in-soyuz work, I need to be able to identify an archive's corresponding debug archive in many places. This is currently only done in lp.soyuz.model.queue.

== Proposed fix ==

Factor the calculation out into a property: IArchive.debug_archive.

== Pre-implementation notes ==

None.

== Implementation details ==

Nothing special.

== Tests ==

Added new tests in lp.soyuz.tests.test_archive.TestCorrespondingDebugArchive, for each possible situation.

bin/test -vvt TestCorrespondingDebugArchive

== Demo and Q/A ==

This is purely a refactor; there is no functional change.

= Launchpad lint =

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  lib/lp/soyuz/interfaces/archive.py
  lib/lp/soyuz/model/archive.py
  lib/lp/soyuz/model/queue.py
  lib/lp/soyuz/tests/test_archive.py

== Pylint notices ==

lib/lp/soyuz/interfaces/archive.py
    40: [F0401] Unable to import 'lazr.enum' (No module named enum)
    53: [F0401] Unable to import 'lazr.restful.declarations' (No module named restful)
    59: [F0401] Unable to import 'lazr.restful.fields' (No module named restful)

lib/lp/soyuz/model/archive.py
    14: [F0401] Unable to import 'lazr.lifecycle.event' (No module named lifecycle)

lib/lp/soyuz/model/queue.py
    547: [C0301] Line too long (93/78)
    562: [C0301] Line too long (80/78)

Revision history for this message
Eleanor Berger (intellectronica) wrote :

All good. Thanks for working on this.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/soyuz/interfaces/archive.py'
--- lib/lp/soyuz/interfaces/archive.py 2009-10-12 17:10:54 +0000
+++ lib/lp/soyuz/interfaces/archive.py 2009-10-26 12:00:37 +0000
@@ -196,6 +196,9 @@
196 "The expanded list of archive dependencies. It includes the implicit "196 "The expanded list of archive dependencies. It includes the implicit "
197 "PRIMARY archive dependency for PPAs.")197 "PRIMARY archive dependency for PPAs.")
198198
199 debug_archive = Attribute(
200 "The archive into which debug binaries should be uploaded.")
201
199 archive_url = Attribute("External archive URL.")202 archive_url = Attribute("External archive URL.")
200203
201 is_ppa = Attribute("True if this archive is a PPA.")204 is_ppa = Attribute("True if this archive is a PPA.")
202205
=== modified file 'lib/lp/soyuz/model/archive.py'
--- lib/lp/soyuz/model/archive.py 2009-10-13 16:50:00 +0000
+++ lib/lp/soyuz/model/archive.py 2009-10-26 12:00:37 +0000
@@ -254,6 +254,15 @@
254 return archives254 return archives
255255
256 @property256 @property
257 def debug_archive(self):
258 """See `IArchive`."""
259 if self.purpose == ArchivePurpose.PRIMARY:
260 return getUtility(IArchiveSet).getByDistroPurpose(
261 self.distribution, ArchivePurpose.DEBUG)
262 else:
263 return self
264
265 @property
257 def archive_url(self):266 def archive_url(self):
258 """See `IArchive`."""267 """See `IArchive`."""
259 archive_postfixes = {268 archive_postfixes = {
260269
=== modified file 'lib/lp/soyuz/model/queue.py'
--- lib/lp/soyuz/model/queue.py 2009-10-15 13:17:49 +0000
+++ lib/lp/soyuz/model/queue.py 2009-10-26 12:00:37 +0000
@@ -45,8 +45,6 @@
45from canonical.database.sqlbase import SQLBase, sqlvalues45from canonical.database.sqlbase import SQLBase, sqlvalues
46from canonical.encoding import guess as guess_encoding, ascii_smash46from canonical.encoding import guess as guess_encoding, ascii_smash
47from canonical.launchpad.helpers import get_email_template47from canonical.launchpad.helpers import get_email_template
48from lp.soyuz.interfaces.archive import (
49 ArchivePurpose, IArchiveSet)
50from lp.soyuz.interfaces.binarypackagerelease import (48from lp.soyuz.interfaces.binarypackagerelease import (
51 BinaryPackageFormat)49 BinaryPackageFormat)
52from canonical.launchpad.interfaces.launchpad import ILaunchpadCelebrities50from canonical.launchpad.interfaces.launchpad import ILaunchpadCelebrities
@@ -56,7 +54,7 @@
56from lp.registry.interfaces.pocket import (54from lp.registry.interfaces.pocket import (
57 PackagePublishingPocket, pocketsuffix)55 PackagePublishingPocket, pocketsuffix)
58from lp.soyuz.interfaces.publishing import (56from lp.soyuz.interfaces.publishing import (
59 IPublishingSet, ISourcePackagePublishingHistory, PackagePublishingStatus)57 IPublishingSet, ISourcePackagePublishingHistory)
60from lp.soyuz.interfaces.queue import (58from lp.soyuz.interfaces.queue import (
61 IPackageUpload, IPackageUploadBuild, IPackageUploadCustom,59 IPackageUpload, IPackageUploadBuild, IPackageUploadCustom,
62 IPackageUploadQueue, IPackageUploadSource, IPackageUploadSet,60 IPackageUploadQueue, IPackageUploadSource, IPackageUploadSet,
@@ -1371,15 +1369,13 @@
1371 archive = self.packageupload.archive1369 archive = self.packageupload.archive
1372 # DDEBs targeted to the PRIMARY archive are published in the1370 # DDEBs targeted to the PRIMARY archive are published in the
1373 # corresponding DEBUG archive.1371 # corresponding DEBUG archive.
1374 if (archive.purpose == ArchivePurpose.PRIMARY and1372 if binary.binpackageformat == BinaryPackageFormat.DDEB:
1375 binary.binpackageformat == BinaryPackageFormat.DDEB):1373 debug_archive = archive.debug_archive
1376 distribution = self.packageupload.distroseries.distribution1374 if debug_archive is None:
1377 archive = getUtility(IArchiveSet).getByDistroPurpose(
1378 distribution, ArchivePurpose.DEBUG)
1379 if archive is None:
1380 raise QueueInconsistentStateError(1375 raise QueueInconsistentStateError(
1381 "Could not find the corresponding DEBUG archive "1376 "Could not find the corresponding DEBUG archive "
1382 "for %s" % (distribution.title))1377 "for %s" % (archive.displayname))
1378 archive = debug_archive
13831379
1384 for each_target_dar in target_dars:1380 for each_target_dar in target_dars:
1385 bpph = getUtility(IPublishingSet).newBinaryPublication(1381 bpph = getUtility(IPublishingSet).newBinaryPublication(
13861382
=== modified file 'lib/lp/soyuz/tests/test_archive.py'
--- lib/lp/soyuz/tests/test_archive.py 2009-09-30 15:04:46 +0000
+++ lib/lp/soyuz/tests/test_archive.py 2009-10-26 12:00:37 +0000
@@ -8,11 +8,13 @@
8import unittest8import unittest
99
10from zope.component import getUtility10from zope.component import getUtility
11from zope.security.proxy import removeSecurityProxy
1112
12from canonical.testing import LaunchpadZopelessLayer13from canonical.testing import LaunchpadZopelessLayer
1314
14from lp.registry.interfaces.distribution import IDistributionSet15from lp.registry.interfaces.distribution import IDistributionSet
15from lp.soyuz.interfaces.archive import IArchiveSet16from lp.registry.interfaces.person import IPersonSet
17from lp.soyuz.interfaces.archive import IArchiveSet, ArchivePurpose
16from lp.soyuz.interfaces.binarypackagerelease import BinaryPackageFormat18from lp.soyuz.interfaces.binarypackagerelease import BinaryPackageFormat
17from lp.soyuz.interfaces.build import BuildStatus19from lp.soyuz.interfaces.build import BuildStatus
18from lp.soyuz.interfaces.publishing import PackagePublishingStatus20from lp.soyuz.interfaces.publishing import PackagePublishingStatus
@@ -330,5 +332,55 @@
330 self.failUnlessEqual(332 self.failUnlessEqual(
331 self.sourcepackagereleases[0], result[0])333 self.sourcepackagereleases[0], result[0])
332334
335class TestCorrespondingDebugArchive(TestCaseWithFactory):
336
337 layer = LaunchpadZopelessLayer
338
339 def setUp(self):
340 super(TestCorrespondingDebugArchive, self).setUp()
341
342 self.ubuntutest = getUtility(IDistributionSet)['ubuntutest']
343
344 # Create a debug archive, as there isn't one in the sample data.
345 self.debug_archive = getUtility(IArchiveSet).new(
346 purpose=ArchivePurpose.DEBUG,
347 distribution=self.ubuntutest,
348 owner=self.ubuntutest.owner)
349
350 # Retrieve sample data archives of each type.
351 self.primary_archive = getUtility(IArchiveSet).getByDistroPurpose(
352 self.ubuntutest, ArchivePurpose.PRIMARY)
353 self.partner_archive = getUtility(IArchiveSet).getByDistroPurpose(
354 self.ubuntutest, ArchivePurpose.PARTNER)
355 self.copy_archive = getUtility(IArchiveSet).getByDistroPurpose(
356 self.ubuntutest, ArchivePurpose.PARTNER)
357 self.ppa = getUtility(IPersonSet).getByName('cprov').archive
358
359 def testPrimaryDebugArchiveIsDebug(self):
360 self.assertEquals(
361 self.primary_archive.debug_archive, self.debug_archive)
362
363 def testPartnerDebugArchiveIsSelf(self):
364 self.assertEquals(
365 self.partner_archive.debug_archive, self.partner_archive)
366
367 def testCopyDebugArchiveIsSelf(self):
368 self.assertEquals(
369 self.copy_archive.debug_archive, self.copy_archive)
370
371 def testDebugDebugArchiveIsSelf(self):
372 self.assertEquals(
373 self.debug_archive.debug_archive, self.debug_archive)
374
375 def testPPADebugArchiveIsSelf(self):
376 self.assertEquals(self.ppa.debug_archive, self.ppa)
377
378 def testMissingPrimaryDebugArchiveIsNone(self):
379 # Turn the DEBUG archive into a COPY archive to hide it.
380 removeSecurityProxy(self.debug_archive).purpose = ArchivePurpose.COPY
381
382 self.assertIs(
383 self.primary_archive.debug_archive, None)
384
333def test_suite():385def test_suite():
334 return unittest.TestLoader().loadTestsFromName(__name__)386 return unittest.TestLoader().loadTestsFromName(__name__)