launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #18566
[Merge] lp:~cjwatson/launchpad/fix-bpph-binaryfileurls into lp:launchpad
Colin Watson has proposed merging lp:~cjwatson/launchpad/fix-bpph-binaryfileurls into lp:launchpad.
Commit message:
Make BPPH.binaryFileUrls return URLs even for files that have been removed from the published archive.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/fix-bpph-binaryfileurls/+merge/259112
Make BPPH.binaryFileUrls return URLs even for files that have been removed from the published archive.
BPPH.files only returns files that haven't been removed, because it goes through the BinaryPackageFilePublishing view.
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/fix-bpph-binaryfileurls into lp:launchpad.
=== modified file 'lib/lp/soyuz/model/publishing.py'
--- lib/lp/soyuz/model/publishing.py 2015-04-29 13:58:31 +0000
+++ lib/lp/soyuz/model/publishing.py 2015-05-14 13:27:56 +0000
@@ -75,7 +75,6 @@
)
from lp.services.worlddata.model.country import Country
from lp.soyuz.enums import (
- ArchivePurpose,
BinaryPackageFormat,
PackagePublishingPriority,
PackagePublishingStatus,
@@ -101,7 +100,6 @@
OverrideError,
PoolFileOverwriteError,
)
-from lp.soyuz.interfaces.queue import QueueInconsistentStateError
from lp.soyuz.interfaces.section import ISectionSet
from lp.soyuz.model.binarypackagebuild import BinaryPackageBuild
from lp.soyuz.model.binarypackagename import BinaryPackageName
@@ -1059,12 +1057,13 @@
def binaryFileUrls(self, include_meta=False):
"""See `IBinaryPackagePublishingHistory`."""
binary_urls = proxied_urls(
- [f.libraryfilealias for f in self.files], self.archive)
+ [f.libraryfile for f in self.binarypackagerelease.files],
+ self.archive)
if include_meta:
meta = [(
- f.libraryfilealias.content.filesize,
- f.libraryfilealias.content.sha1,
- ) for f in self.files]
+ f.libraryfile.content.filesize,
+ f.libraryfile.content.sha1,
+ ) for f in self.binarypackagerelease.files]
return [dict(url=url, size=size, sha1=sha1)
for url, (size, sha1) in zip(binary_urls, meta)]
return binary_urls
=== modified file 'lib/lp/soyuz/tests/test_publishing_models.py'
--- lib/lp/soyuz/tests/test_publishing_models.py 2015-04-08 10:35:22 +0000
+++ lib/lp/soyuz/tests/test_publishing_models.py 2015-05-14 13:27:56 +0000
@@ -1,12 +1,14 @@
-# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2015 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Test model and set utilities used for publishing."""
from zope.component import getUtility
+from zope.security.proxy import removeSecurityProxy
from lp.app.errors import NotFoundError
from lp.buildmaster.enums import BuildStatus
+from lp.services.database.constants import UTC_NOW
from lp.services.librarian.browser import ProxiedLibraryFileAlias
from lp.services.webapp.publisher import canonical_url
from lp.soyuz.enums import (
@@ -212,6 +214,20 @@
self.assertContentEqual(
self.get_urls_for_bpph(bpph, include_meta=True), urls)
+ def test_binaryFileUrls_removed(self):
+ # binaryFileUrls returns URLs even if the files have been removed
+ # from the published archive.
+ bpph = self.make_bpph(num_binaries=2)
+ expected_urls = self.get_urls_for_bpph(bpph)
+ expected_urls_meta = self.get_urls_for_bpph(bpph, include_meta=True)
+ self.assertContentEqual(expected_urls, bpph.binaryFileUrls())
+ self.assertContentEqual(
+ expected_urls_meta, bpph.binaryFileUrls(include_meta=True))
+ removeSecurityProxy(bpph).dateremoved = UTC_NOW
+ self.assertContentEqual(expected_urls, bpph.binaryFileUrls())
+ self.assertContentEqual(
+ expected_urls_meta, bpph.binaryFileUrls(include_meta=True))
+
def test_is_debug_false_for_deb(self):
bpph = self.factory.makeBinaryPackagePublishingHistory(
binpackageformat=BinaryPackageFormat.DEB)
Follow ups