← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~jcsackett/launchpad/bug-tracker-inactive-projects into lp:launchpad

 

j.c.sackett has proposed merging lp:~jcsackett/launchpad/bug-tracker-inactive-projects into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~jcsackett/launchpad/bug-tracker-inactive-projects/+merge/124526

Summary
=======
This branch addresses a failure in the bugtracker index pages to not show
inactive projects, because we were doing nothing to filter them out.

Preimp
======
Spoke with Curtis Hovey.

Implementation
==============
The related_projects method used by the portlet has been updated to filter out
products that inactive.

Tests
=====
bin/test -vvct test_bugtracker_views

QA
==
Ensure that inactive projects are not in the bugtracker related project
portlet listing.

LoC
===
This branch has a followup branch that removes some of a doctest and adds it
to the created testcase here, netting slightly more LoC removed than this
branch adds. (See the branch dependent on this one).

Lint
====

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/bugs/browser/tests/test_bugtracker_views.py
  lib/lp/bugs/browser/bugtracker.py

./lib/lp/bugs/browser/tests/test_bugtracker_views.py
      53: local variable 'active_tracker2' is assigned to but never used
      52: local variable 'active_tracker1' is assigned to but never used

I'm not addressing these as the function call is still necessary, and the
assignment helps the code be self documenting.
-- 
https://code.launchpad.net/~jcsackett/launchpad/bug-tracker-inactive-projects/+merge/124526
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jcsackett/launchpad/bug-tracker-inactive-projects into lp:launchpad.
=== modified file 'lib/lp/bugs/browser/bugtracker.py'
--- lib/lp/bugs/browser/bugtracker.py	2011-12-30 06:14:56 +0000
+++ lib/lp/bugs/browser/bugtracker.py	2012-09-14 21:39:20 +0000
@@ -227,8 +227,8 @@
         This property was created for the Related projects portlet in
         the bug tracker's page.
         """
-        return shortlist(chain(self.context.projects,
-                               self.context.products), 100)
+        pillars = chain(self.context.projects, self.context.products)
+        return shortlist([p for p in pillars if p.active], 100)
 
     @property
     def related_component_groups(self):

=== modified file 'lib/lp/bugs/browser/tests/test_bugtracker_views.py'
--- lib/lp/bugs/browser/tests/test_bugtracker_views.py	2012-01-01 02:58:52 +0000
+++ lib/lp/bugs/browser/tests/test_bugtracker_views.py	2012-09-14 21:39:20 +0000
@@ -7,8 +7,8 @@
 
 from zope.component import getUtility
 
+from lp.app.interfaces.launchpad import ILaunchpadCelebrities
 from lp.bugs.interfaces.bugtracker import IBugTrackerSet
-from lp.registry.interfaces.person import IPersonSet
 from lp.services.webapp import canonical_url
 from lp.testing import (
     person_logged_in,
@@ -20,6 +20,23 @@
 from lp.testing.views import create_initialized_view
 
 
+class TestBugTrackerView(TestCaseWithFactory):
+
+    layer = DatabaseFunctionalLayer
+
+    def test_linked_projects_only_shows_active_projects(self):
+        tracker = self.factory.makeBugTracker()
+        active_product = self.factory.makeProduct()
+        inactive_product = self.factory.makeProduct()
+        admin = getUtility(ILaunchpadCelebrities).admin.teamowner
+        with person_logged_in(admin):
+            active_product.bugtracker = tracker
+            inactive_product.bugtracker = tracker
+            inactive_product.active = False
+        view = create_initialized_view(tracker, name='+index')
+        self.assertEqual([active_product], view.related_projects)
+            
+
 class TestBugTrackerSetView(TestCaseWithFactory):
 
     layer = DatabaseFunctionalLayer
@@ -36,7 +53,7 @@
         active_tracker2 = self.factory.makeBugTracker()
         inactive_tracker1 = self.factory.makeBugTracker()
         inactive_tracker2 = self.factory.makeBugTracker()
-        admin = getUtility(IPersonSet).find(ADMIN_EMAIL).any()
+        admin = getUtility(ILaunchpadCelebrities).admin.teamowner
         with person_logged_in(admin):
             inactive_tracker1.active = False
             inactive_tracker2.active = False


Follow ups