← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:fix-bpph-ci-builds into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:fix-bpph-ci-builds into launchpad:master.

Commit message:
Fix BPPH webservice for published CI builds

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/429697

Binaries from published CI builds don't have a priority.  Fix `BinaryPackagePublishingHistory.priority_name` not to crash in that case.

Similar to c9e1aaded1610212eaf32a3b2573d9eb3955510c, but I missed this because priorities are specific to binary packages rather than being shared between source and binary packages.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:fix-bpph-ci-builds into launchpad:master.
diff --git a/lib/lp/soyuz/browser/tests/test_publishing_webservice.py b/lib/lp/soyuz/browser/tests/test_publishing_webservice.py
index 674711d..008ce4a 100644
--- a/lib/lp/soyuz/browser/tests/test_publishing_webservice.py
+++ b/lib/lp/soyuz/browser/tests/test_publishing_webservice.py
@@ -6,13 +6,16 @@
 from functools import partial
 
 from testtools.matchers import ContainsDict, Equals, Is
+from zope.component import getUtility
 from zope.security.proxy import removeSecurityProxy
 
+from lp.registry.interfaces.pocket import PackagePublishingPocket
 from lp.registry.interfaces.sourcepackage import SourcePackageType
 from lp.services.librarian.browser import ProxiedLibraryFileAlias
 from lp.services.webapp.interfaces import OAuthPermission
 from lp.soyuz.adapters.proxiedsourcefiles import ProxiedSourceLibraryFileAlias
 from lp.soyuz.enums import BinaryPackageFormat
+from lp.soyuz.interfaces.publishing import IPublishingSet
 from lp.testing import (
     TestCaseWithFactory,
     api_url,
@@ -244,6 +247,10 @@ class BinaryPackagePublishingHistoryWebserviceTests(TestCaseWithFactory):
             person, permission=OAuthPermission.READ_PUBLIC
         )
         with person_logged_in(person):
+            das = self.factory.makeDistroArchSeries()
+            archive = self.factory.makeArchive(
+                distribution=das.distroseries.distribution
+            )
             build = self.factory.makeCIBuild()
             bpn = self.factory.makeBinaryPackageName()
             bpr = build.createBinaryPackageRelease(
@@ -254,9 +261,11 @@ class BinaryPackagePublishingHistoryWebserviceTests(TestCaseWithFactory):
                 BinaryPackageFormat.WHL,
                 False,
             )
-            bpph = self.factory.makeBinaryPackagePublishingHistory(
-                binarypackagerelease=bpr,
-                binpackageformat=BinaryPackageFormat.WHL,
+            [bpph] = getUtility(IPublishingSet).publishBinaries(
+                archive,
+                das.distroseries,
+                PackagePublishingPocket.RELEASE,
+                {bpr: (None, None, None, None)},
             )
             url = api_url(bpph)
 
diff --git a/lib/lp/soyuz/model/publishing.py b/lib/lp/soyuz/model/publishing.py
index 76356e8..faec822 100644
--- a/lib/lp/soyuz/model/publishing.py
+++ b/lib/lp/soyuz/model/publishing.py
@@ -898,7 +898,7 @@ class BinaryPackagePublishingHistory(SQLBase, ArchivePublisherBase):
     @property
     def priority_name(self):
         """See `IBinaryPackagePublishingHistory`"""
-        return self.priority.name
+        return self.priority.name if self.priority is not None else None
 
     @property
     def displayname(self):