Merge lp:~james-w/launchpad/fix-webservice-test-isolation into lp:launchpad

Proposed by James Westby
Status: Merged
Approved by: Gary Poster
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~james-w/launchpad/fix-webservice-test-isolation
Merge into: lp:launchpad
Diff against target: 37 lines (+8/-1)
2 files modified
lib/canonical/launchpad/doc/webservice-error.txt (+6/-1)
lib/canonical/launchpad/doc/webservice-marshallers.txt (+2/-0)
To merge this branch: bzr merge lp:~james-w/launchpad/fix-webservice-test-isolation
Reviewer Review Type Date Requested Status
Gary Poster (community) Approve
Review via email: mp+22040@code.launchpad.net

Commit message

Fix an isolation issue in lib/canonical/launchpad/doc/webservice-error.txt

Description of the change

This fixes an issue where webservice-error.txt was leaving a dirty
environment. This meant that webservice-marshallers.txt would pass when
it ran second, as it normally does. It would fail when run on it's own
though, as the request was never started in that test.

This firstly fixes the isolation issue by having the first test clean
up and finish the request, and then fixes the second test to work
in a clean environment by starting the request again.

The second test already cleans the environment, which is where the error
occurs if you run the test alone.

To test run:

  ./bin/test -t lib/canonical/launchpad/ftests/../doc/webservice
  ./bin/test -t lib/canonical/launchpad/ftests/../doc/webservice-marshallers

both with and without the change.

Thanks,

James

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

Thank you, James.

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/doc/webservice-error.txt'
2--- lib/canonical/launchpad/doc/webservice-error.txt 2009-04-01 20:25:39 +0000
3+++ lib/canonical/launchpad/doc/webservice-error.txt 2010-03-24 16:08:27 +0000
4@@ -6,7 +6,8 @@
5
6 >>> import threading
7 >>> from canonical.launchpad.webapp.servers import LaunchpadTestRequest
8- >>> from canonical.launchpad.webapp.adapter import set_request_started
9+ >>> from canonical.launchpad.webapp.adapter import (
10+ ... set_request_started, clear_request_started)
11 >>> from zope.component import getMultiAdapter
12
13 >>> def render_using_default_view(error):
14@@ -32,3 +33,7 @@
15 >>> response, result = render_using_default_view(RequestExpired())
16 >>> response.getStatus()
17 503
18+
19+Cleanup.
20+
21+ >>> clear_request_started()
22
23=== modified file 'lib/canonical/launchpad/doc/webservice-marshallers.txt'
24--- lib/canonical/launchpad/doc/webservice-marshallers.txt 2009-04-01 19:43:59 +0000
25+++ lib/canonical/launchpad/doc/webservice-marshallers.txt 2010-03-24 16:08:27 +0000
26@@ -7,9 +7,11 @@
27 To test the various marshallers we create a dummy request and
28 application root.
29
30+ >>> from canonical.launchpad.webapp.adapter import set_request_started
31 >>> from canonical.launchpad.webapp.servers import WebServiceTestRequest
32 >>> from canonical.launchpad.webapp.servers import WebServicePublication
33 >>> request = WebServiceTestRequest(method='GET')
34+ >>> set_request_started()
35 >>> request.setPublication(WebServicePublication(None))
36 >>> login(ANONYMOUS, request)
37 >>> request.processInputs()