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
1=== modified file 'lib/canonical/launchpad/database/structuralsubscription.py'
2--- lib/canonical/launchpad/database/structuralsubscription.py 2009-10-08 12:50:25 +0000
3+++ lib/canonical/launchpad/database/structuralsubscription.py 2009-10-23 14:00:31 +0000
4@@ -146,7 +146,7 @@
5 return True
6
7 admins = getUtility(ILaunchpadCelebrities).admin
8- return (subscriber is subscribed_by or
9+ return (subscriber == subscribed_by or
10 subscriber in subscribed_by.getAdministratedTeams() or
11 subscribed_by.inTeam(admins))
12
13
14=== modified file 'lib/lp/registry/tests/test_product.py'
15--- lib/lp/registry/tests/test_product.py 2009-08-13 19:03:36 +0000
16+++ lib/lp/registry/tests/test_product.py 2009-10-23 14:00:31 +0000
17@@ -9,17 +9,22 @@
18 import transaction
19 from cStringIO import StringIO
20
21-from canonical.testing import LaunchpadFunctionalLayer
22+from zope.component import getUtility
23+
24+from canonical.launchpad.ftests import login
25 from canonical.launchpad.testing.pages import (
26 find_main_content, get_feedback_messages, setupBrowser)
27+from canonical.testing import LaunchpadFunctionalLayer
28
29 from canonical.launchpad.ftests import syncUpdate
30
31+from lp.registry.interfaces.person import IPersonSet
32 from lp.registry.interfaces.product import License
33 from lp.registry.model.product import Product
34 from lp.registry.model.productlicense import ProductLicense
35 from lp.registry.model.commercialsubscription import (
36 CommercialSubscription)
37+from lp.testing import TestCaseWithFactory
38
39 class TestProductFiles(unittest.TestCase):
40 """Tests for downloadable product files."""
41@@ -145,5 +150,31 @@
42 'new')
43
44
45+class BugSupervisorTestCase(TestCaseWithFactory):
46+ """A TestCase for bug supervisor management."""
47+
48+ layer = LaunchpadFunctionalLayer
49+
50+ def setUp(self):
51+ super(BugSupervisorTestCase, self).setUp()
52+ self.person = self.factory.makePerson()
53+ self.product = self.factory.makeProduct(owner=self.person)
54+ login(self.person.preferredemail.email)
55+
56+ def testPersonCanSetSelfAsSupervisor(self):
57+ # A person can set themselves as bug supervisor for a product.
58+ # This is a regression test for bug 438985.
59+ user = getUtility(IPersonSet).getByName(self.person.name)
60+ self.product.setBugSupervisor(
61+ bug_supervisor=self.person, user=user)
62+
63+ self.assertEqual(
64+ self.product.bug_supervisor, self.person,
65+ "%s should be bug supervisor for %s. "
66+ "Instead, bug supervisor for firefox is %s" % (
67+ self.person.name, self.product.name,
68+ self.product.bug_supervisor.name))
69+
70+
71 def test_suite():
72 return unittest.TestLoader().loadTestsFromName(__name__)
73
74=== modified file 'lib/lp/testing/factory.py'
75--- lib/lp/testing/factory.py 2009-10-14 07:59:33 +0000
76+++ lib/lp/testing/factory.py 2009-10-23 14:00:31 +0000
77@@ -530,7 +530,7 @@
78 description="test file")
79
80 def makeProduct(self, *args, **kwargs):
81- """As makeProductNoCommit with an implicit transaction commit.
82+ """As makeProductNoCommit with an explicit transaction commit.
83
84 This ensures that generated owners and registrants are fully
85 flushed and available from all Stores.