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

Proposed by j.c.sackett
Status: Merged
Approved by: Curtis Hovey
Approved revision: no longer in the source branch.
Merge reported by: j.c.sackett
Merged at revision: not available
Proposed branch: lp:~jcsackett/launchpad/bug-tracker-inactive-projects
Merge into: lp:launchpad
Diff against target: 77 lines (+24/-7)
2 files modified
lib/lp/bugs/browser/bugtracker.py (+2/-2)
lib/lp/bugs/browser/tests/test_bugtracker_views.py (+22/-5)
To merge this branch: bzr merge lp:~jcsackett/launchpad/bug-tracker-inactive-projects
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+124526@code.launchpad.net

Description of the change

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.

To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :

Thank you.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/bugs/browser/bugtracker.py'
2--- lib/lp/bugs/browser/bugtracker.py 2011-12-30 06:14:56 +0000
3+++ lib/lp/bugs/browser/bugtracker.py 2012-09-14 21:46:20 +0000
4@@ -227,8 +227,8 @@
5 This property was created for the Related projects portlet in
6 the bug tracker's page.
7 """
8- return shortlist(chain(self.context.projects,
9- self.context.products), 100)
10+ pillars = chain(self.context.projects, self.context.products)
11+ return shortlist([p for p in pillars if p.active], 100)
12
13 @property
14 def related_component_groups(self):
15
16=== modified file 'lib/lp/bugs/browser/tests/test_bugtracker_views.py'
17--- lib/lp/bugs/browser/tests/test_bugtracker_views.py 2012-01-01 02:58:52 +0000
18+++ lib/lp/bugs/browser/tests/test_bugtracker_views.py 2012-09-14 21:46:20 +0000
19@@ -7,8 +7,8 @@
20
21 from zope.component import getUtility
22
23+from lp.app.interfaces.launchpad import ILaunchpadCelebrities
24 from lp.bugs.interfaces.bugtracker import IBugTrackerSet
25-from lp.registry.interfaces.person import IPersonSet
26 from lp.services.webapp import canonical_url
27 from lp.testing import (
28 person_logged_in,
29@@ -16,10 +16,26 @@
30 )
31 from lp.testing.layers import DatabaseFunctionalLayer
32 from lp.testing.matchers import IsConfiguredBatchNavigator
33-from lp.testing.sampledata import ADMIN_EMAIL
34 from lp.testing.views import create_initialized_view
35
36
37+class TestBugTrackerView(TestCaseWithFactory):
38+
39+ layer = DatabaseFunctionalLayer
40+
41+ def test_linked_projects_only_shows_active_projects(self):
42+ tracker = self.factory.makeBugTracker()
43+ active_product = self.factory.makeProduct()
44+ inactive_product = self.factory.makeProduct()
45+ admin = getUtility(ILaunchpadCelebrities).admin.teamowner
46+ with person_logged_in(admin):
47+ active_product.bugtracker = tracker
48+ inactive_product.bugtracker = tracker
49+ inactive_product.active = False
50+ view = create_initialized_view(tracker, name='+index')
51+ self.assertEqual([active_product], view.related_projects)
52+
53+
54 class TestBugTrackerSetView(TestCaseWithFactory):
55
56 layer = DatabaseFunctionalLayer
57@@ -36,7 +52,7 @@
58 active_tracker2 = self.factory.makeBugTracker()
59 inactive_tracker1 = self.factory.makeBugTracker()
60 inactive_tracker2 = self.factory.makeBugTracker()
61- admin = getUtility(IPersonSet).find(ADMIN_EMAIL).any()
62+ admin = getUtility(ILaunchpadCelebrities).admin.teamowner
63 with person_logged_in(admin):
64 inactive_tracker1.active = False
65 inactive_tracker2.active = False
66@@ -45,8 +61,9 @@
67 "/+index?active_batch=1&inactive_batch=1")
68 browser = self.getUserBrowser(url)
69 content = browser.contents
70- # XXX RobertCollns 20100919 bug=642504. The support for multiple batches
71- # isn't complete and the id for the nav links gets duplicated.
72+ # XXX RobertCollns 20100919 bug=642504.
73+ # The support for multiple batches isn't complete and the id for the
74+ # nav links gets duplicated.
75 #self.assertEqual('next',
76 # find_tag_by_id(content, 'upper-batch-nav-batchnav-next')['class'])
77 #self.assertEqual('next',