← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~twom/launchpad:export-source-properties-on-BPPH into launchpad:master

 

Tom Wardill has proposed merging ~twom/launchpad:export-source-properties-on-BPPH into launchpad:master.

Commit message:
Export source package name and version on BPPH

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~twom/launchpad/+git/launchpad/+merge/391538
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~twom/launchpad:export-source-properties-on-BPPH into launchpad:master.
diff --git a/lib/lp/soyuz/interfaces/binarypackagerelease.py b/lib/lp/soyuz/interfaces/binarypackagerelease.py
index 2ee397e..592d515 100644
--- a/lib/lp/soyuz/interfaces/binarypackagerelease.py
+++ b/lib/lp/soyuz/interfaces/binarypackagerelease.py
@@ -90,6 +90,8 @@ class IBinaryPackageRelease(Interface):
     name = Attribute("Binary Package Name")
     sourcepackagename = Attribute(
         "The name of the source package from where this binary was built.")
+    sourcepackageversion = Attribute(
+        "The version of the source package from where this binary was built.")
 
     def addFile(file):
         """Create a BinaryPackageFile record referencing this build
diff --git a/lib/lp/soyuz/interfaces/publishing.py b/lib/lp/soyuz/interfaces/publishing.py
index 4443284..162fb17 100644
--- a/lib/lp/soyuz/interfaces/publishing.py
+++ b/lib/lp/soyuz/interfaces/publishing.py
@@ -604,8 +604,17 @@ class IBinaryPackagePublishingHistoryPublic(IPublishingView):
         required=False, readonly=False)
     binarypackagerelease = Attribute(
         "The binary package release being published")
-    source_package_name = Attribute(
-        'The source package name that built this binary.')
+    source_package_name = exported(
+        TextLine(
+            title=_("Source Package Name"),
+            description=_('The source package name that built this binary.'),
+            required=False, readonly=True))
+    source_package_version = exported(
+        TextLine(
+            title=_("Source Package Version"),
+            description=_(
+                'The source package version that built this binary.'),
+            required=False, readonly=True))
     distroarchseriesID = Int(
         title=_("The DB id for the distroarchseries."),
         required=False, readonly=False)
diff --git a/lib/lp/soyuz/model/binarypackagerelease.py b/lib/lp/soyuz/model/binarypackagerelease.py
index 3458b70..8866723 100644
--- a/lib/lp/soyuz/model/binarypackagerelease.py
+++ b/lib/lp/soyuz/model/binarypackagerelease.py
@@ -125,6 +125,11 @@ class BinaryPackageRelease(SQLBase):
         """See `IBinaryPackageRelease`."""
         return self.build.source_package_release.sourcepackagename.name
 
+    @property
+    def sourcepackageversion(self):
+        """See `IBinaryPackageRelease`."""
+        return self.build.source_package_release.version
+
     @cachedproperty
     def files(self):
         return list(
diff --git a/lib/lp/soyuz/model/publishing.py b/lib/lp/soyuz/model/publishing.py
index 33390b5..86db3c1 100644
--- a/lib/lp/soyuz/model/publishing.py
+++ b/lib/lp/soyuz/model/publishing.py
@@ -704,6 +704,11 @@ class BinaryPackagePublishingHistory(SQLBase, ArchivePublisherBase):
         return self.binarypackagerelease.sourcepackagename
 
     @property
+    def source_package_version(self):
+        """See `IBinaryPackagePublishingHistory`"""
+        return self.binarypackagerelease.sourcepackageversion
+
+    @property
     def architecture_specific(self):
         """See `IBinaryPackagePublishingHistory`"""
         return self.binarypackagerelease.architecturespecific
diff --git a/lib/lp/soyuz/tests/test_publishing_models.py b/lib/lp/soyuz/tests/test_publishing_models.py
index 6ed7adc..d5cb65a 100644
--- a/lib/lp/soyuz/tests/test_publishing_models.py
+++ b/lib/lp/soyuz/tests/test_publishing_models.py
@@ -10,6 +10,7 @@ from zope.security.proxy import removeSecurityProxy
 
 from lp.app.errors import NotFoundError
 from lp.buildmaster.enums import BuildStatus
+from lp.registry.enums import PersonVisibility
 from lp.registry.interfaces.sourcepackage import SourcePackageFileType
 from lp.services.database.constants import UTC_NOW
 from lp.services.librarian.browser import ProxiedLibraryFileAlias
@@ -24,11 +25,15 @@ from lp.soyuz.interfaces.publishing import (
     PackagePublishingStatus,
     )
 from lp.soyuz.tests.test_binarypackagebuild import BaseTestCaseWithThreeBuilds
-from lp.testing import TestCaseWithFactory
+from lp.testing import (
+    person_logged_in,
+    TestCaseWithFactory,
+    )
 from lp.testing.layers import (
     LaunchpadFunctionalLayer,
     LaunchpadZopelessLayer,
     )
+from zope.security.interfaces import Unauthorized
 
 
 class TestPublishingSet(BaseTestCaseWithThreeBuilds):
@@ -297,3 +302,49 @@ class TestBinaryPackagePublishingHistory(TestCaseWithFactory):
         bpph = self.factory.makeBinaryPackagePublishingHistory(
             binpackageformat=BinaryPackageFormat.DDEB)
         self.assertTrue(bpph.is_debug)
+
+    def test_source_package_name(self):
+        bpph = self.factory.makeBinaryPackagePublishingHistory()
+        self.assertEqual(
+            bpph.binarypackagerelease.sourcepackagename,
+            bpph.source_package_name)
+
+    def test_source_package_name_private(self):
+        team_owner = self.factory.makePerson()
+        private_team = self.factory.makeTeam(
+            owner=team_owner, visibility=PersonVisibility.PRIVATE)
+        ppa = self.factory.makeArchive(private=True, owner=private_team)
+        with person_logged_in(team_owner):
+            bpph = self.factory.makeBinaryPackagePublishingHistory(
+                archive=ppa)
+            self.assertEqual(
+                bpph.binarypackagerelease.sourcepackagename,
+                bpph.source_package_name)
+        self.assertRaises(
+            Unauthorized,
+            getattr,
+            bpph,
+            'source_package_name')
+
+    def test_source_package_version(self):
+        bpph = self.factory.makeBinaryPackagePublishingHistory()
+        self.assertEqual(
+            bpph.binarypackagerelease.sourcepackageversion,
+            bpph.source_package_version)
+
+    def test_source_package_version_private(self):
+        team_owner = self.factory.makePerson()
+        private_team = self.factory.makeTeam(
+            owner=team_owner, visibility=PersonVisibility.PRIVATE)
+        ppa = self.factory.makeArchive(private=True, owner=private_team)
+        with person_logged_in(team_owner):
+            bpph = self.factory.makeBinaryPackagePublishingHistory(
+                archive=ppa)
+            self.assertEqual(
+                bpph.binarypackagerelease.sourcepackageversion,
+                bpph.source_package_version)
+        self.assertRaises(
+            Unauthorized,
+            getattr,
+            bpph,
+            'source_package_version')