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
=== modified file 'lib/lp/bugs/model/bugtracker.py'
--- lib/lp/bugs/model/bugtracker.py 2011-12-30 06:14:56 +0000
+++ lib/lp/bugs/model/bugtracker.py 2012-06-22 18:44:21 +0000
@@ -845,9 +845,11 @@
845 from lp.registry.model.projectgroup import ProjectGroup845 from lp.registry.model.projectgroup import ProjectGroup
846 ids = [str(b.id) for b in bugtrackers]846 ids = [str(b.id) for b in bugtrackers]
847 products = Product.select(847 products = Product.select(
848 "bugtracker in (%s)" % ",".join(ids), orderBy="name")848 "bugtracker in (%s) AND active IS True" %
849 ",".join(ids), orderBy="name")
849 projects = ProjectGroup.select(850 projects = ProjectGroup.select(
850 "bugtracker in (%s)" % ",".join(ids), orderBy="name")851 "bugtracker in (%s) AND active IS True" %
852 ",".join(ids), orderBy="name")
851 ret = {}853 ret = {}
852 for product in products:854 for product in products:
853 ret.setdefault(product.bugtracker, []).append(product)855 ret.setdefault(product.bugtracker, []).append(product)
854856
=== modified file 'lib/lp/bugs/tests/test_bugtracker.py'
--- lib/lp/bugs/tests/test_bugtracker.py 2012-01-01 02:58:52 +0000
+++ lib/lp/bugs/tests/test_bugtracker.py 2012-06-22 18:44:21 +0000
@@ -45,6 +45,7 @@
45from lp.testing import (45from lp.testing import (
46 login,46 login,
47 login_person,47 login_person,
48 login_celebrity,
48 TestCase,49 TestCase,
49 TestCaseWithFactory,50 TestCaseWithFactory,
50 )51 )
@@ -77,6 +78,29 @@
77 # but not in active.78 # but not in active.
78 self.assertFalse(tracker in trackers.trackers(active=True))79 self.assertFalse(tracker in trackers.trackers(active=True))
7980
81 def test_inactive_products_in_pillars(self):
82 # the list of pillars should only contain active
83 # products and projects
84 tracker = self.factory.makeBugTracker()
85 trackers = BugTrackerSet()
86 product1 = self.factory.makeProduct()
87 product2 = self.factory.makeProduct()
88 project1 = self.factory.makeProject()
89 project2 = self.factory.makeProject()
90 login_celebrity('admin')
91 product1.bugtracker = tracker
92 product2.bugtracker = tracker
93 project1.bugtracker = tracker
94 project2.bugtracker = tracker
95 pillars = trackers.getPillarsForBugtrackers(trackers)
96 self.assertContentEqual(
97 [product1, product2, project1, project2], pillars[tracker])
98 product1.active = False
99 project2.active = False
100 pillars = trackers.getPillarsForBugtrackers(trackers)
101 self.assertContentEqual(
102 [product2, project1], pillars[tracker])
103
80104
81class BugTrackerTestCase(TestCaseWithFactory):105class BugTrackerTestCase(TestCaseWithFactory):
82 """Unit tests for the `BugTracker` class."""106 """Unit tests for the `BugTracker` class."""