Merge lp:~bac/launchpad/bug-987499 into lp:launchpad

Proposed by Brad Crittenden
Status: Merged
Approved by: j.c.sackett
Approved revision: no longer in the source branch.
Merged at revision: 15199
Proposed branch: lp:~bac/launchpad/bug-987499
Merge into: lp:launchpad
Diff against target: 53 lines (+9/-7)
2 files modified
lib/lp/app/browser/tests/test_stringformatter.py (+6/-7)
lib/lp/testing/_login.py (+3/-0)
To merge this branch: bzr merge lp:~bac/launchpad/bug-987499
Reviewer Review Type Date Requested Status
j.c.sackett (community) Approve
Gary Poster (community) Approve
Review via email: mp+104607@code.launchpad.net

Commit message

Set LaunchBag.developer to False in lp.testing.logout().

Description of the change

= Summary =

LaunchBag.developer is being assumed to be unset when it can be left
on by previous tests. Clear it explicitly.

== Proposed fix ==

In the test, explicitly turn off the flag.

Alternatively, a tearDown method can be added to TestCase to ensure it
is always reset to False at the end of a run.

Similarly, a ILoggedOutEvent could be sent.

This flag is rarely used so I chose to not muddy the test
infrastructure to deal with it.

== Pre-implementation notes ==

None

== Implementation details ==

== Tests ==

Set tests.txt to:
lp.registry.browser.tests.test_subscription_links.DistroMilestoneView.test_subscribe_link_admin
lp.app.browser.tests.test_stringformatter.TestOOPSFormatter.test_doesnt_linkify_for_non_developers

bin/test -vv --load-list tests.txt

== Demo and Q/A ==

None

= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/app/browser/tests/test_stringformatter.py

To post a comment you must log in.
Revision history for this message
Gary Poster (gary) wrote :

Cool, thank you.

I verified in IRC that the test_stringformatter change is just for test clarity: it does not change behavior. The behavior change is in _login.

Thank you!

review: Approve
Revision history for this message
j.c.sackett (jcsackett) wrote :

Looks good. Thanks, Brad.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/app/browser/tests/test_stringformatter.py'
2--- lib/lp/app/browser/tests/test_stringformatter.py 2012-04-02 05:42:19 +0000
3+++ lib/lp/app/browser/tests/test_stringformatter.py 2012-05-03 20:32:18 +0000
4@@ -373,6 +373,11 @@
5
6 layer = DatabaseFunctionalLayer
7
8+ def _setDeveloper(self, value):
9+ """Override ILaunchBag.developer for testing purposes."""
10+ launch_bag = getUtility(ILaunchBag)
11+ launch_bag.setDeveloper(value)
12+
13 def test_doesnt_linkify_for_non_developers(self):
14 # OOPS IDs won't be linkified for non-developers.
15 oops_id = 'OOPS-12345TEST'
16@@ -384,17 +389,11 @@
17 "Formatted string should be '%s', was '%s'" % (
18 oops_id, formatted_string))
19
20- def _setDeveloper(self):
21- """Override ILaunchBag.developer for testing purposes."""
22- launch_bag = getUtility(ILaunchBag)
23- launch_bag.setDeveloper(True)
24-
25 def test_linkifies_for_developers(self):
26 # OOPS IDs will be linkified for Launchpad developers.
27 oops_id = 'OOPS-12345TEST'
28 formatter = FormattersAPI(oops_id)
29-
30- self._setDeveloper()
31+ self._setDeveloper(True)
32 formatted_string = formatter.oops_id()
33
34 expected_string = '<a href="%s">%s</a>' % (
35
36=== modified file 'lib/lp/testing/_login.py'
37--- lib/lp/testing/_login.py 2012-04-03 15:09:11 +0000
38+++ lib/lp/testing/_login.py 2012-05-03 20:32:18 +0000
39@@ -37,6 +37,7 @@
40 setupInteractionByEmail,
41 setupInteractionForPerson,
42 )
43+from lp.services.webapp.interfaces import ILaunchBag
44 from lp.services.webapp.servers import LaunchpadTestRequest
45 from lp.services.webapp.vhosts import allvhosts
46 from lp.testing.sampledata import ADMIN_EMAIL
47@@ -135,6 +136,8 @@
48 LaunchpadFunctionalTestCase's tearDown method so
49 you generally won't need to call this.
50 """
51+ # Ensure the launchbag developer flag is off when logging out.
52+ getUtility(ILaunchBag).setDeveloper(False)
53 endInteraction()
54
55