← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~rvb/launchpad/fix-packagediff-request-link into lp:launchpad

 

Raphaël Victor Badin has proposed merging lp:~rvb/launchpad/fix-packagediff-request-link into lp:launchpad with lp:~rvb/launchpad/fix-package-diff-equal-versions as a prerequisite.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #760881 in Launchpad itself: "The package diff request link should not be there when one package diff is computed and the other has the same version than base_version."
  https://bugs.launchpad.net/launchpad/+bug/760881

For more details, see:
https://code.launchpad.net/~rvb/launchpad/fix-packagediff-request-link/+merge/57727

This branch fixes the display of the link to compute package diffs when one the package diff is already computed and the other is not but makes no sense as it has the same version as base_version.

= Tests =
./bin/test -cvv test_distroseriesdifference_views test_no_package_diff_parent_same_version
./bin/test -cvv test_distroseriesdifference_views test_no_package_diff_derived_same_version

= QA =
In the first row of the page:
https://dogfood.launchpad.net/ubuntu/natty/+localpackagediffs
The header of the package diff widget should not be a link to compute the package diffs.
-- 
https://code.launchpad.net/~rvb/launchpad/fix-packagediff-request-link/+merge/57727
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/launchpad/fix-packagediff-request-link into lp:launchpad.
=== modified file 'lib/lp/registry/browser/distroseriesdifference.py'
--- lib/lp/registry/browser/distroseriesdifference.py	2011-04-14 16:49:14 +0000
+++ lib/lp/registry/browser/distroseriesdifference.py	2011-04-14 16:49:15 +0000
@@ -182,10 +182,14 @@
         This method is used in the template to show the package diff
         request link.
         """
+        derived_diff_computable = (
+            not self.context.package_diff and self.display_child_diff)
+        parent_diff_computable = (
+            not self.context.parent_package_diff and self.display_parent_diff)
         return (check_permission('launchpad.Edit', self.context) and
                 self.context.base_version and
-                (not self.context.package_diff or
-                 not self.context.parent_package_diff))
+                (derived_diff_computable or
+                 parent_diff_computable))
 
 
 class DistroSeriesDifferenceDisplayComment:

=== modified file 'lib/lp/registry/browser/tests/test_distroseriesdifference_views.py'
--- lib/lp/registry/browser/tests/test_distroseriesdifference_views.py	2011-04-14 16:49:14 +0000
+++ lib/lp/registry/browser/tests/test_distroseriesdifference_views.py	2011-04-14 16:49:15 +0000
@@ -229,6 +229,50 @@
         tags = soup.find('ul', 'package-diff-status').findAll('span')
         self.assertEqual(1, len(tags))
 
+    def _assertNoRequestLink(self, ds_diff):
+        view = create_initialized_view(
+            ds_diff, '+listing-distroseries-extra')
+        package_diff_request_matcher = soupmatchers.HTMLContains(
+            soupmatchers.Tag(
+                'Request link', 'a',
+                text=re.compile(
+                    '\s*Compute differences from last common version\s*')))
+
+        self.assertFalse(view.show_package_diffs_request_link)
+        self.assertThat(view(), Not(package_diff_request_matcher))
+
+    def test_no_package_diff_parent_same_version(self):
+        # If the derived package diff is computed and parent_version is
+        # the same as the base version, we don't display the link to
+        # request package diffs.
+        ds_diff = self.factory.makeDistroSeriesDifference(
+            set_base_version=True,
+            versions={
+                'derived': '0.32-1',
+                'parent': '0.30-1',
+                'base': '0.30-1'})
+
+        with person_logged_in(ds_diff.derived_series.owner):
+            ds_diff.package_diff = self.factory.makePackageDiff(
+                status=PackageDiffStatus.COMPLETED)
+            self._assertNoRequestLink(ds_diff)
+
+    def test_no_package_diff_derived_same_version(self):
+        # If the parent package diff is computed and source_version is
+        # the same as the base version, we don't display the link to
+        # request package diffs.
+        ds_diff = self.factory.makeDistroSeriesDifference(
+            set_base_version=True,
+            versions={
+                'derived': '0.30-1',
+                'parent': '0.32-1',
+                'base': '0.30-1'})
+
+        with person_logged_in(ds_diff.derived_series.owner):
+            ds_diff.parent_package_diff = self.factory.makePackageDiff(
+                status=PackageDiffStatus.COMPLETED)
+            self._assertNoRequestLink(ds_diff)
+
     def _makeDistroSeriesDifferenceView(self, difference_type):
         # Helper method to create a view with the specified
         # difference_type.


Follow ups