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
=== modified file 'lib/canonical/launchpad/doc/webservice-error.txt'
--- lib/canonical/launchpad/doc/webservice-error.txt 2009-04-01 20:25:39 +0000
+++ lib/canonical/launchpad/doc/webservice-error.txt 2010-03-24 16:08:27 +0000
@@ -6,7 +6,8 @@
66
7 >>> import threading7 >>> import threading
8 >>> from canonical.launchpad.webapp.servers import LaunchpadTestRequest8 >>> from canonical.launchpad.webapp.servers import LaunchpadTestRequest
9 >>> from canonical.launchpad.webapp.adapter import set_request_started9 >>> from canonical.launchpad.webapp.adapter import (
10 ... set_request_started, clear_request_started)
10 >>> from zope.component import getMultiAdapter11 >>> from zope.component import getMultiAdapter
1112
12 >>> def render_using_default_view(error):13 >>> def render_using_default_view(error):
@@ -32,3 +33,7 @@
32 >>> response, result = render_using_default_view(RequestExpired())33 >>> response, result = render_using_default_view(RequestExpired())
33 >>> response.getStatus()34 >>> response.getStatus()
34 50335 503
36
37Cleanup.
38
39 >>> clear_request_started()
3540
=== modified file 'lib/canonical/launchpad/doc/webservice-marshallers.txt'
--- lib/canonical/launchpad/doc/webservice-marshallers.txt 2009-04-01 19:43:59 +0000
+++ lib/canonical/launchpad/doc/webservice-marshallers.txt 2010-03-24 16:08:27 +0000
@@ -7,9 +7,11 @@
7To test the various marshallers we create a dummy request and7To test the various marshallers we create a dummy request and
8application root.8application root.
99
10 >>> from canonical.launchpad.webapp.adapter import set_request_started
10 >>> from canonical.launchpad.webapp.servers import WebServiceTestRequest11 >>> from canonical.launchpad.webapp.servers import WebServiceTestRequest
11 >>> from canonical.launchpad.webapp.servers import WebServicePublication12 >>> from canonical.launchpad.webapp.servers import WebServicePublication
12 >>> request = WebServiceTestRequest(method='GET')13 >>> request = WebServiceTestRequest(method='GET')
14 >>> set_request_started()
13 >>> request.setPublication(WebServicePublication(None))15 >>> request.setPublication(WebServicePublication(None))
14 >>> login(ANONYMOUS, request)16 >>> login(ANONYMOUS, request)
15 >>> request.processInputs()17 >>> request.processInputs()