Merge lp:~gmb/launchpad/make-me-super-bug-438985 into lp:launchpad

Proposed by Graham Binns
Status: Merged
Approved by: Graham Binns
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~gmb/launchpad/make-me-super-bug-438985
Merge into: lp:launchpad
Diff against target: 85 lines
3 files modified
lib/canonical/launchpad/database/structuralsubscription.py (+1/-1)
lib/lp/registry/tests/test_product.py (+32/-1)
lib/lp/testing/factory.py (+1/-1)
To merge this branch: bzr merge lp:~gmb/launchpad/make-me-super-bug-438985
Reviewer Review Type Date Requested Status
Abel Deuring (community) Approve
Review via email: mp+13840@code.launchpad.net

Commit message

Setting yourself as bug supervisor for a project will no longer OOPS.

To post a comment you must log in.
Revision history for this message
Graham Binns (gmb) wrote :

This branch resolves bug 438985 by changing the comparison used in StructuralSubscriptionTargetMixin._userCanAlterSubscription() to use '==' instead of 'is' when comparing DB objects.

I've also add a regression test to cover the bug and corrected the docstring of LaunchpadObjectFactory.makePerson().

Revision history for this message
Abel Deuring (adeuring) wrote :

Looks good.

> - """As makeProductNoCommit with an implicit transaction commit.
> + """As makeProductNoCommit with an explicit transaction commit.

"explicit is better than implicit" ;)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/canonical/launchpad/database/structuralsubscription.py'
--- lib/canonical/launchpad/database/structuralsubscription.py 2009-10-08 12:50:25 +0000
+++ lib/canonical/launchpad/database/structuralsubscription.py 2009-10-23 14:00:31 +0000
@@ -146,7 +146,7 @@
146 return True146 return True
147147
148 admins = getUtility(ILaunchpadCelebrities).admin148 admins = getUtility(ILaunchpadCelebrities).admin
149 return (subscriber is subscribed_by or149 return (subscriber == subscribed_by or
150 subscriber in subscribed_by.getAdministratedTeams() or150 subscriber in subscribed_by.getAdministratedTeams() or
151 subscribed_by.inTeam(admins))151 subscribed_by.inTeam(admins))
152152
153153
=== modified file 'lib/lp/registry/tests/test_product.py'
--- lib/lp/registry/tests/test_product.py 2009-08-13 19:03:36 +0000
+++ lib/lp/registry/tests/test_product.py 2009-10-23 14:00:31 +0000
@@ -9,17 +9,22 @@
9import transaction9import transaction
10from cStringIO import StringIO10from cStringIO import StringIO
1111
12from canonical.testing import LaunchpadFunctionalLayer12from zope.component import getUtility
13
14from canonical.launchpad.ftests import login
13from canonical.launchpad.testing.pages import (15from canonical.launchpad.testing.pages import (
14 find_main_content, get_feedback_messages, setupBrowser)16 find_main_content, get_feedback_messages, setupBrowser)
17from canonical.testing import LaunchpadFunctionalLayer
1518
16from canonical.launchpad.ftests import syncUpdate19from canonical.launchpad.ftests import syncUpdate
1720
21from lp.registry.interfaces.person import IPersonSet
18from lp.registry.interfaces.product import License22from lp.registry.interfaces.product import License
19from lp.registry.model.product import Product23from lp.registry.model.product import Product
20from lp.registry.model.productlicense import ProductLicense24from lp.registry.model.productlicense import ProductLicense
21from lp.registry.model.commercialsubscription import (25from lp.registry.model.commercialsubscription import (
22 CommercialSubscription)26 CommercialSubscription)
27from lp.testing import TestCaseWithFactory
2328
24class TestProductFiles(unittest.TestCase):29class TestProductFiles(unittest.TestCase):
25 """Tests for downloadable product files."""30 """Tests for downloadable product files."""
@@ -145,5 +150,31 @@
145 'new')150 'new')
146151
147152
153class BugSupervisorTestCase(TestCaseWithFactory):
154 """A TestCase for bug supervisor management."""
155
156 layer = LaunchpadFunctionalLayer
157
158 def setUp(self):
159 super(BugSupervisorTestCase, self).setUp()
160 self.person = self.factory.makePerson()
161 self.product = self.factory.makeProduct(owner=self.person)
162 login(self.person.preferredemail.email)
163
164 def testPersonCanSetSelfAsSupervisor(self):
165 # A person can set themselves as bug supervisor for a product.
166 # This is a regression test for bug 438985.
167 user = getUtility(IPersonSet).getByName(self.person.name)
168 self.product.setBugSupervisor(
169 bug_supervisor=self.person, user=user)
170
171 self.assertEqual(
172 self.product.bug_supervisor, self.person,
173 "%s should be bug supervisor for %s. "
174 "Instead, bug supervisor for firefox is %s" % (
175 self.person.name, self.product.name,
176 self.product.bug_supervisor.name))
177
178
148def test_suite():179def test_suite():
149 return unittest.TestLoader().loadTestsFromName(__name__)180 return unittest.TestLoader().loadTestsFromName(__name__)
150181
=== modified file 'lib/lp/testing/factory.py'
--- lib/lp/testing/factory.py 2009-10-14 07:59:33 +0000
+++ lib/lp/testing/factory.py 2009-10-23 14:00:31 +0000
@@ -530,7 +530,7 @@
530 description="test file")530 description="test file")
531531
532 def makeProduct(self, *args, **kwargs):532 def makeProduct(self, *args, **kwargs):
533 """As makeProductNoCommit with an implicit transaction commit.533 """As makeProductNoCommit with an explicit transaction commit.
534534
535 This ensures that generated owners and registrants are fully535 This ensures that generated owners and registrants are fully
536 flushed and available from all Stores.536 flushed and available from all Stores.