← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~rvb/launchpad/link-pending-sourcepck-757713 into lp:launchpad

 

Raphaël Victor Badin has proposed merging lp:~rvb/launchpad/link-pending-sourcepck-757713 into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #757713 in Launchpad itself: "The package version is not linked to its source page on +localpackagediffs"
  https://bugs.launchpad.net/launchpad/+bug/757713

For more details, see:
https://code.launchpad.net/~rvb/launchpad/link-pending-sourcepck-757713/+merge/57300

This branch fixes DistroSeriesDifference's source_package_release and parent_source_package_release so that they return package releases with status in (PENDING, PUBLISHED).

= Test =
./bin/test -cvv test_distroseriesdifference test_source_package_release_pending

= QA =
On dogfood:
    https://dogfood.launchpad.net/deribuntu/dangerous/+localpackagediffs
The "Maverick version" of 2.6-1+df1 should be a link to the pending source package page (https://dogfood.launchpad.net/ubuntu/maverick/+source/hello/2.6-1+df1).

-- 
https://code.launchpad.net/~rvb/launchpad/link-pending-sourcepck-757713/+merge/57300
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/launchpad/link-pending-sourcepck-757713 into lp:launchpad.
=== modified file 'lib/lp/registry/model/distroseriesdifference.py'
--- lib/lp/registry/model/distroseriesdifference.py	2011-04-06 22:51:53 +0000
+++ lib/lp/registry/model/distroseriesdifference.py	2011-04-12 10:31:42 +0000
@@ -312,10 +312,13 @@
             self.source_version)
 
     def _package_release(self, distro_series, version):
+        statuses = (
+            PackagePublishingStatus.PUBLISHED,
+            PackagePublishingStatus.PENDING)
         pubs = distro_series.main_archive.getPublishedSources(
             name=self.source_package_name.name,
             version=version,
-            status=PackagePublishingStatus.PUBLISHED,
+            status=statuses,
             distroseries=distro_series,
             exact_match=True)
 

=== modified file 'lib/lp/registry/tests/test_distroseriesdifference.py'
--- lib/lp/registry/tests/test_distroseriesdifference.py	2011-04-06 15:26:34 +0000
+++ lib/lp/registry/tests/test_distroseriesdifference.py	2011-04-12 10:31:42 +0000
@@ -688,6 +688,40 @@
         self.assertEqual(None, ds_diff.package_diff_url)
         self.assertEqual(None, ds_diff.parent_package_diff_url)
 
+    def test_source_package_release_pending(self):
+        # source_package_release returns the package release of version
+        # source_version with status PUBLISHED or PENDING.
+        derived_series = self.factory.makeDistroSeries(
+            parent_series=self.factory.makeDistroSeries())
+        source_package_name = self.factory.getOrMakeSourcePackageName('foo')
+        versions = {'derived': u'1.2', 'parent': u'1.3'}
+
+        ds_diff = self.factory.makeDistroSeriesDifference(
+            derived_series=derived_series,
+            source_package_name_str=source_package_name.name,
+            versions=versions)
+
+        # Create pending source package releases.
+        self.factory.makeSourcePackagePublishingHistory(
+            distroseries=derived_series,
+            version='1.4',
+            sourcepackagename=source_package_name,
+            status=PackagePublishingStatus.PENDING)
+        self.factory.makeSourcePackagePublishingHistory(
+            distroseries=derived_series.parent_series,
+            version='1.5',
+            sourcepackagename=source_package_name,
+            status=PackagePublishingStatus.PENDING)
+
+        # Manually change the diff's source_version and
+        # parent_source_version.
+        naked_ds_diff = removeSecurityProxy(ds_diff)
+        naked_ds_diff.source_version = '1.4'
+        naked_ds_diff.parent_source_version = '1.5'
+
+        self.assertEqual(ds_diff.source_package_release.version, '1.4')
+        self.assertEqual(ds_diff.parent_source_package_release.version, '1.5')
+
 
 class DistroSeriesDifferenceLibrarianTestCase(TestCaseWithFactory):