Merge lp:~replaceafill/launchpad/bug-210821 into lp:launchpad

Proposed by Douglas Cerna
Status: Merged
Approved by: Curtis Hovey
Approved revision: no longer in the source branch.
Merged at revision: 15479
Proposed branch: lp:~replaceafill/launchpad/bug-210821
Merge into: lp:launchpad
Diff against target: 59 lines (+28/-2)
2 files modified
lib/lp/bugs/model/bugtracker.py (+4/-2)
lib/lp/bugs/tests/test_bugtracker.py (+24/-0)
To merge this branch: bzr merge lp:~replaceafill/launchpad/bug-210821
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+111659@code.launchpad.net

Commit message

Filtered inactive products and projects out of pillars list for bug tracker sets.

Description of the change

Filtered inactive products and projects out of pillars list for bug tracker sets.

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

change
    login(ADMIN_EMAIL)
to
    login_celebrity('admin')
because the first case relies on sample data that is logging in a user that can skew the test results.

review: Needs Fixing (code)
Revision history for this message
Curtis Hovey (sinzui) wrote :

Thank you. I will land this now.

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/model/bugtracker.py'
2--- lib/lp/bugs/model/bugtracker.py 2011-12-30 06:14:56 +0000
3+++ lib/lp/bugs/model/bugtracker.py 2012-06-22 18:44:21 +0000
4@@ -845,9 +845,11 @@
5 from lp.registry.model.projectgroup import ProjectGroup
6 ids = [str(b.id) for b in bugtrackers]
7 products = Product.select(
8- "bugtracker in (%s)" % ",".join(ids), orderBy="name")
9+ "bugtracker in (%s) AND active IS True" %
10+ ",".join(ids), orderBy="name")
11 projects = ProjectGroup.select(
12- "bugtracker in (%s)" % ",".join(ids), orderBy="name")
13+ "bugtracker in (%s) AND active IS True" %
14+ ",".join(ids), orderBy="name")
15 ret = {}
16 for product in products:
17 ret.setdefault(product.bugtracker, []).append(product)
18
19=== modified file 'lib/lp/bugs/tests/test_bugtracker.py'
20--- lib/lp/bugs/tests/test_bugtracker.py 2012-01-01 02:58:52 +0000
21+++ lib/lp/bugs/tests/test_bugtracker.py 2012-06-22 18:44:21 +0000
22@@ -45,6 +45,7 @@
23 from lp.testing import (
24 login,
25 login_person,
26+ login_celebrity,
27 TestCase,
28 TestCaseWithFactory,
29 )
30@@ -77,6 +78,29 @@
31 # but not in active.
32 self.assertFalse(tracker in trackers.trackers(active=True))
33
34+ def test_inactive_products_in_pillars(self):
35+ # the list of pillars should only contain active
36+ # products and projects
37+ tracker = self.factory.makeBugTracker()
38+ trackers = BugTrackerSet()
39+ product1 = self.factory.makeProduct()
40+ product2 = self.factory.makeProduct()
41+ project1 = self.factory.makeProject()
42+ project2 = self.factory.makeProject()
43+ login_celebrity('admin')
44+ product1.bugtracker = tracker
45+ product2.bugtracker = tracker
46+ project1.bugtracker = tracker
47+ project2.bugtracker = tracker
48+ pillars = trackers.getPillarsForBugtrackers(trackers)
49+ self.assertContentEqual(
50+ [product1, product2, project1, project2], pillars[tracker])
51+ product1.active = False
52+ project2.active = False
53+ pillars = trackers.getPillarsForBugtrackers(trackers)
54+ self.assertContentEqual(
55+ [product2, project1], pillars[tracker])
56+
57
58 class BugTrackerTestCase(TestCaseWithFactory):
59 """Unit tests for the `BugTracker` class."""