← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~rvb/launchpad/dsd-api-bug-833080 into lp:launchpad

 

Raphaël Victor Badin has proposed merging lp:~rvb/launchpad/dsd-api-bug-833080 into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #833080 in Launchpad itself: "distro_series_difference API objects don't have package names"
  https://bugs.launchpad.net/launchpad/+bug/833080

For more details, see:
https://code.launchpad.net/~rvb/launchpad/dsd-api-bug-833080/+merge/73532

This branch exposes sourcepackagename, status, parent_source_version, source_version and base_version on DistroSeriesDifferences api objects.

The only trick is that a new method sourcepackagename had to be added. This is because it's not possible to expose directly IDistroSeriesDifference.source_package_name which is of type ISourcePackageName (not exposed by the api).

= Tests =

./bin/test -vvc test_distroseriesdifference_webservice test_exported_sourcepackagename
./bin/test -vvc test_distroseriesdifference_webservice test_exported_status
./bin/test -vvc test_distroseriesdifference_webservice test_exported_parent_source_version
./bin/test -vvc test_distroseriesdifference_webservice test_exported_source_version
./bin/test -vvc test_distroseriesdifference_webservice test_exported_base_version

= Q/A =

# Remplace dogfood by, for instance, qastaging to test it on another instance.
from launchpadlib.launchpad import Launchpad
launchpad = Launchpad.login_with('Launchpad', 'dogfood', version='devel')
oneiric = launchpad.distributions['ubuntu'].getSeries(name_or_version='oneiric')
sid = launchpad.distributions['debian'].getSeries(name_or_version='sid')
dsd = oneiric.getDifferencesTo(parent_series=sid)[0]
# Check newly exposed attributes
print dsd.sourcepackagename
print dsd.status
print dsd.parent_source_version
print dsd.source_version
print dsd.base_version
-- 
https://code.launchpad.net/~rvb/launchpad/dsd-api-bug-833080/+merge/73532
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/launchpad/dsd-api-bug-833080 into lp:launchpad.
=== modified file 'lib/lp/registry/browser/tests/test_distroseriesdifference_webservice.py'
--- lib/lp/registry/browser/tests/test_distroseriesdifference_webservice.py	2011-05-23 16:50:14 +0000
+++ lib/lp/registry/browser/tests/test_distroseriesdifference_webservice.py	2011-08-31 13:42:25 +0000
@@ -44,7 +44,7 @@
         ws_diff = ws_object(self.factory.makeLaunchpadService(
             archive_admin), ds_diff)
 
-        result = ws_diff.blacklist()
+        ws_diff.blacklist()
         transaction.commit()
 
         utility = getUtility(IDistroSeriesDifferenceSource)
@@ -64,7 +64,7 @@
         ws_diff = ws_object(self.factory.makeLaunchpadService(
             archive_admin), ds_diff)
 
-        result = ws_diff.unblacklist()
+        ws_diff.unblacklist()
         transaction.commit()
 
         utility = getUtility(IDistroSeriesDifferenceSource)
@@ -94,7 +94,7 @@
             versions=['1.0', '1.2'])
         parent_changelog = self.factory.makeChangelog(
             versions=['1.0', '1.3'])
-        transaction.commit() # Yay, librarian.
+        transaction.commit()  # Yay, librarian.
         ds_diff = self.factory.makeDistroSeriesDifference(
             source_package_name_str='foo', versions={
                 'derived': '1.2',
@@ -107,7 +107,7 @@
         ws_diff = ws_object(self.factory.makeLaunchpadService(
             self.factory.makePerson()), ds_diff)
 
-        result = ws_diff.requestPackageDiffs()
+        ws_diff.requestPackageDiffs()
         transaction.commit()
 
         # Reload and check that the package diffs are there.
@@ -173,3 +173,48 @@
 
         self.assertIs(None, ws_diff.package_diff_url)
         self.assertIsNot(None, ws_diff.parent_package_diff_url)
+
+    def test_exported_status(self):
+        # The difference's status is exposed.
+        ds_diff = self.factory.makeDistroSeriesDifference(
+            status=DistroSeriesDifferenceStatus.BLACKLISTED_ALWAYS)
+        ws_diff = ws_object(self.factory.makeLaunchpadService(
+            self.factory.makePerson()), ds_diff)
+
+        self.assertEqual(u'Blacklisted always', ws_diff.status)
+
+    def test_exported_sourcepackagename(self):
+        # The difference's sourcepackagename is exposed.
+        ds_diff = self.factory.makeDistroSeriesDifference(
+            source_package_name_str=u'package')
+        ws_diff = ws_object(self.factory.makeLaunchpadService(
+            self.factory.makePerson()), ds_diff)
+
+        self.assertEqual(u'package', ws_diff.sourcepackagename)
+
+    def test_exported_parent_source_version(self):
+        # The difference's parent_source_version is exposed.
+        ds_diff = self.factory.makeDistroSeriesDifference(
+            versions={'parent': u'1.1'})
+        ws_diff = ws_object(self.factory.makeLaunchpadService(
+            self.factory.makePerson()), ds_diff)
+
+        self.assertEqual(u'1.1', ws_diff.parent_source_version)
+
+    def test_exported_source_version(self):
+        # The difference's source_version is exposed.
+        ds_diff = self.factory.makeDistroSeriesDifference(
+            versions={'derived': u'1.3'})
+        ws_diff = ws_object(self.factory.makeLaunchpadService(
+            self.factory.makePerson()), ds_diff)
+
+        self.assertEqual(u'1.3', ws_diff.source_version)
+
+    def test_exported_base_version(self):
+        # The difference's base_version is exposed.
+        ds_diff = self.factory.makeDistroSeriesDifference(
+            versions={'base': u'0.5'}, set_base_version=True)
+        ws_diff = ws_object(self.factory.makeLaunchpadService(
+            self.factory.makePerson()), ds_diff)
+
+        self.assertEqual(u'0.5', ws_diff.base_version)

=== modified file 'lib/lp/registry/interfaces/distroseriesdifference.py'
--- lib/lp/registry/interfaces/distroseriesdifference.py	2011-08-02 15:26:48 +0000
+++ lib/lp/registry/interfaces/distroseriesdifference.py	2011-08-31 13:42:25 +0000
@@ -77,6 +77,11 @@
             "The package with a difference between the derived series "
             "and its parent."))
 
+    sourcepackagename = exported(
+        TextLine(
+            title=_("Source Package Name"),
+            required=False, readonly=True))
+
     package_diff = Reference(
         IPackageDiff, title=_("Package diff"), required=False,
         readonly=True, description=_(
@@ -117,11 +122,11 @@
             "The status of the diff between the base version and the "
             "parent version.")))
 
-    status = Choice(
+    status = exported(Choice(
         title=_('Distro series difference status.'),
         description=_('The current status of this difference.'),
         vocabulary=DistroSeriesDifferenceStatus,
-        required=True, readonly=True)
+        required=True, readonly=True))
 
     difference_type = Choice(
         title=_('Difference type'),
@@ -149,11 +154,11 @@
         description=_(
             "The most recent published version in the derived series."))
 
-    source_version = TextLine(
+    source_version = exported(TextLine(
         title=_("Source version"), readonly=True,
         description=_(
             "The version of the most recent source publishing in the "
-            "derived series."))
+            "derived series.")))
 
     parent_source_pub = Reference(
         ISourcePackagePublishingHistory,
@@ -161,17 +166,17 @@
         description=_(
             "The most recent published version in the parent series."))
 
-    parent_source_version = TextLine(
+    parent_source_version = exported(TextLine(
         title=_("Parent source version"), readonly=True,
         description=_(
             "The version of the most recent source publishing in the "
-            "parent series."))
+            "parent series.")))
 
-    base_version = TextLine(
+    base_version = exported(TextLine(
         title=_("Base version"), readonly=True,
         description=_(
             "The common base version of the package for differences "
-            "with different versions in the parent and derived series."))
+            "with different versions in the parent and derived series.")))
 
     base_source_pub = Reference(
         ISourcePackagePublishingHistory,

=== modified file 'lib/lp/registry/model/distroseriesdifference.py'
--- lib/lp/registry/model/distroseriesdifference.py	2011-08-16 15:12:42 +0000
+++ lib/lp/registry/model/distroseriesdifference.py	2011-08-31 13:42:25 +0000
@@ -562,6 +562,11 @@
                 DistroSeriesDifference.source_package_name_id)
         return DecoratedResultSet(differences, itemgetter(0))
 
+    @property
+    def sourcepackagename(self):
+        """See `IDistroSeriesDifference`"""
+        return self.source_package_name.name
+
     @cachedproperty
     def source_pub(self):
         """See `IDistroSeriesDifference`."""