Merge lp:~leonardr/lazr.restful/make-test-class-public into lp:lazr.restful
- make-test-class-public
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Edwin Grubbs |
Approved revision: | 128 |
Merged at revision: | not available |
Proposed branch: | lp:~leonardr/lazr.restful/make-test-class-public |
Merge into: | lp:lazr.restful |
Prerequisite: | lp:~leonardr/lazr.restful/refactor-tag-request-with-version |
Diff against target: |
377 lines (+147/-135) 2 files modified
src/lazr/restful/testing/webservice.py (+138/-3) src/lazr/restful/tests/test_webservice.py (+9/-132) |
To merge this branch: | bzr merge lp:~leonardr/lazr.restful/make-test-class-public |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Edwin Grubbs (community) | code | Approve | |
Review via email: mp+20574@code.launchpad.net |
Commit message
Description of the change
Leonard Richardson (leonardr) wrote : | # |
Edwin Grubbs (edwin-grubbs) wrote : | # |
Hi Leonard,
The changes look good, but I got these errors when running the tests under python2.6. There were even more problems under python2.5.
-Edwin
Running lazr.restful.
Set up lazr.restful.
Set up lazr.restful.
Failure in test /home/egrubbs/
Traceback (most recent call last):
File "/usr/lib/
testMethod()
File "/usr/lib/
raise self.failureExc
AssertionError: Failed doctest test for field.txt
File "/home/
-------
File "/home/
Failed example:
print new_value
Differences (ndiff with -expected +actual):
- "http://
? ^^^^
+ "http:\
? + ^ +++++++
-------
File "/home/
Failed example:
print webservice(
Differences (ndiff with -expected +actual):
HTTP/1.1 209 Content Returned
- ...
+ Status: 209 Content Returned
+ Content-Length: 68
Content-Type: application/json
- ...
+ X-Powered-By: Zope (www.zope.org), Python (www.python.org)
<BLANKLINE>
- "http://
? ^^^
+ "http:\
? + + + ^^^^^^ +
Ran 9 tests with 1 failures and 0 errors in 2.391 seconds.
Running lazr.restful.
Tear down lazr.restful.
Tear down lazr.restful.
Set up lazr.restful.
Set up lazr.restful.
Ran 3 tests with 0 failures and 0 errors in 0.406 seconds.
Running lazr.restful.
Tear down lazr.restful.
Tear down lazr.restful.
Set up lazr.restful.
Leonard Richardson (leonardr) wrote : | # |
I think you're running the tests on an old version of simplejson. Can you run some code to see what version of simplejson you have? Here's what I get:
$ bin/py
>>> import simplejson
>>> simplejson.
'2.0.9'
Also try making this change to setup.py, rerun bin/buildout, and see if the problem goes away.
=== modified file 'setup.py'
--- setup.py 2009-10-07 18:54:39 +0000
+++ setup.py 2010-03-04 14:03:26 +0000
@@ -64,7 +64,7 @@
- 'simplejson',
+ 'simplejson>
'wsgiref',
Edwin Grubbs (edwin-grubbs) wrote : | # |
Hi Leonard,
Updating simplejson fixed it.
merge-approved
-Edwin
Preview Diff
1 | === modified file 'src/lazr/restful/testing/webservice.py' | |||
2 | --- src/lazr/restful/testing/webservice.py 2010-03-03 13:05:13 +0000 | |||
3 | +++ src/lazr/restful/testing/webservice.py 2010-03-03 17:07:18 +0000 | |||
4 | @@ -9,7 +9,11 @@ | |||
5 | 9 | 'ExampleWebServicePublication', | 9 | 'ExampleWebServicePublication', |
6 | 10 | 'FakeRequest', | 10 | 'FakeRequest', |
7 | 11 | 'FakeResponse', | 11 | 'FakeResponse', |
8 | 12 | 'IGenericEntry', | ||
9 | 13 | 'IGenericCollection', | ||
10 | 12 | 'pprint_entry', | 14 | 'pprint_entry', |
11 | 15 | 'WebServiceTestCase', | ||
12 | 16 | 'WebServiceTestConfiguration' | ||
13 | 13 | 'WebServiceTestPublication', | 17 | 'WebServiceTestPublication', |
14 | 14 | 'WebServiceTestRequest', | 18 | 'WebServiceTestRequest', |
15 | 15 | 'TestPublication', | 19 | 'TestPublication', |
16 | @@ -19,25 +23,39 @@ | |||
17 | 19 | import os | 23 | import os |
18 | 20 | import traceback | 24 | import traceback |
19 | 21 | import simplejson | 25 | import simplejson |
20 | 26 | import sys | ||
21 | 27 | from types import ModuleType | ||
22 | 22 | import urllib | 28 | import urllib |
23 | 29 | import unittest | ||
24 | 23 | from urlparse import urljoin | 30 | from urlparse import urljoin |
25 | 24 | import wsgi_intercept | 31 | import wsgi_intercept |
26 | 25 | 32 | ||
29 | 26 | from zope.component import adapts, getUtility, queryMultiAdapter | 33 | from zope.component import ( |
30 | 27 | from zope.interface import implements | 34 | adapts, getGlobalSiteManager, getUtility, queryMultiAdapter) |
31 | 35 | from zope.configuration import xmlconfig | ||
32 | 36 | from zope.interface import alsoProvides, implements, Interface | ||
33 | 28 | from zope.publisher.browser import BrowserRequest | 37 | from zope.publisher.browser import BrowserRequest |
34 | 29 | from zope.publisher.interfaces.http import IHTTPApplicationRequest | 38 | from zope.publisher.interfaces.http import IHTTPApplicationRequest |
35 | 30 | from zope.publisher.paste import Application | 39 | from zope.publisher.paste import Application |
36 | 31 | from zope.proxy import ProxyBase | 40 | from zope.proxy import ProxyBase |
37 | 41 | from zope.schema import TextLine | ||
38 | 32 | from zope.security.checker import ProxyFactory | 42 | from zope.security.checker import ProxyFactory |
39 | 43 | from zope.testing.cleanup import CleanUp | ||
40 | 33 | from zope.traversing.browser.interfaces import IAbsoluteURL | 44 | from zope.traversing.browser.interfaces import IAbsoluteURL |
41 | 34 | 45 | ||
42 | 46 | from lazr.restful.declarations import ( | ||
43 | 47 | collection_default_content, exported, | ||
44 | 48 | export_as_webservice_collection, export_as_webservice_entry, | ||
45 | 49 | export_read_operation, operation_parameters) | ||
46 | 35 | from lazr.restful.interfaces import ( | 50 | from lazr.restful.interfaces import ( |
47 | 36 | IServiceRootResource, IWebServiceClientRequest, | 51 | IServiceRootResource, IWebServiceClientRequest, |
48 | 37 | IWebServiceConfiguration, IWebServiceLayer, IWebServiceVersion) | 52 | IWebServiceConfiguration, IWebServiceLayer, IWebServiceVersion) |
49 | 38 | from lazr.restful.publisher import ( | 53 | from lazr.restful.publisher import ( |
50 | 39 | WebServicePublicationMixin, WebServiceRequestTraversal) | 54 | WebServicePublicationMixin, WebServiceRequestTraversal) |
52 | 40 | from lazr.restful.simple import Publication, Request | 55 | from lazr.restful.simple import ( |
53 | 56 | BaseWebServiceConfiguration, Publication, Request, | ||
54 | 57 | RootResourceAbsoluteURL, ServiceRootResource) | ||
55 | 58 | from lazr.restful.utils import tag_request_with_version_name | ||
56 | 41 | 59 | ||
57 | 42 | from lazr.uri import URI | 60 | from lazr.uri import URI |
58 | 43 | 61 | ||
59 | @@ -385,6 +403,121 @@ | |||
60 | 385 | raise ValueError(self.body) | 403 | raise ValueError(self.body) |
61 | 386 | 404 | ||
62 | 387 | 405 | ||
63 | 406 | class WebServiceTestConfiguration(BaseWebServiceConfiguration): | ||
64 | 407 | """A simple configuration for tests that need a running web service.""" | ||
65 | 408 | implements(IWebServiceConfiguration) | ||
66 | 409 | show_tracebacks = False | ||
67 | 410 | active_versions = ['1.0', '2.0'] | ||
68 | 411 | hostname = "webservice_test" | ||
69 | 412 | last_version_with_mutator_named_operations = None | ||
70 | 413 | |||
71 | 414 | def createRequest(self, body_instream, environ): | ||
72 | 415 | request = Request(body_instream, environ) | ||
73 | 416 | request.setPublication( | ||
74 | 417 | WebServiceTestPublication(getUtility(IServiceRootResource))) | ||
75 | 418 | tag_request_with_version_name(request, '2.0') | ||
76 | 419 | return request | ||
77 | 420 | |||
78 | 421 | |||
79 | 422 | class IWebServiceTestRequest10(IWebServiceClientRequest): | ||
80 | 423 | """A marker interface for requests to the '1.0' web service.""" | ||
81 | 424 | |||
82 | 425 | |||
83 | 426 | class IWebServiceTestRequest20(IWebServiceClientRequest): | ||
84 | 427 | """A marker interface for requests to the '2.0' web service.""" | ||
85 | 428 | |||
86 | 429 | |||
87 | 430 | class WebServiceTestCase(CleanUp, unittest.TestCase): | ||
88 | 431 | """A test case for web service operations.""" | ||
89 | 432 | |||
90 | 433 | testmodule_objects = [] | ||
91 | 434 | |||
92 | 435 | def setUp(self): | ||
93 | 436 | """Set the component registry with the given model.""" | ||
94 | 437 | super(WebServiceTestCase, self).setUp() | ||
95 | 438 | |||
96 | 439 | # Register a simple configuration object. | ||
97 | 440 | webservice_configuration = WebServiceTestConfiguration() | ||
98 | 441 | sm = getGlobalSiteManager() | ||
99 | 442 | sm.registerUtility(webservice_configuration) | ||
100 | 443 | |||
101 | 444 | # Register IWebServiceVersions for the | ||
102 | 445 | # '1.0' and '2.0' web service versions. | ||
103 | 446 | alsoProvides(IWebServiceTestRequest10, IWebServiceVersion) | ||
104 | 447 | sm.registerUtility( | ||
105 | 448 | IWebServiceTestRequest10, IWebServiceVersion, name='1.0') | ||
106 | 449 | alsoProvides(IWebServiceTestRequest20, IWebServiceVersion) | ||
107 | 450 | sm.registerUtility( | ||
108 | 451 | IWebServiceTestRequest20, IWebServiceVersion, name='2.0') | ||
109 | 452 | |||
110 | 453 | # Register a service root resource | ||
111 | 454 | service_root = ServiceRootResource() | ||
112 | 455 | sm.registerUtility(service_root, IServiceRootResource) | ||
113 | 456 | |||
114 | 457 | # Register an IAbsoluteURL adapter for the service root resource. | ||
115 | 458 | sm.registerAdapter( | ||
116 | 459 | RootResourceAbsoluteURL, | ||
117 | 460 | [IServiceRootResource, IWebServiceClientRequest], IAbsoluteURL) | ||
118 | 461 | |||
119 | 462 | # Build a test module that exposes the given resource interfaces. | ||
120 | 463 | testmodule = ModuleType('testmodule') | ||
121 | 464 | for interface in self.testmodule_objects: | ||
122 | 465 | setattr(testmodule, interface.__name__, interface) | ||
123 | 466 | sys.modules['lazr.restful.testmodule'] = testmodule | ||
124 | 467 | |||
125 | 468 | # Register the test module in the ZCML configuration: adapter | ||
126 | 469 | # classes will be built automatically. | ||
127 | 470 | xmlconfig.string(""" | ||
128 | 471 | <configure | ||
129 | 472 | xmlns="http://namespaces.zope.org/zope" | ||
130 | 473 | xmlns:webservice="http://namespaces.canonical.com/webservice"> | ||
131 | 474 | <include package="zope.component" file="meta.zcml" /> | ||
132 | 475 | <include package="zope.security" file="meta.zcml"/> | ||
133 | 476 | <include package="lazr.restful" file="meta.zcml" /> | ||
134 | 477 | <include package="lazr.restful" file="configure.zcml" /> | ||
135 | 478 | |||
136 | 479 | <adapter for="*" | ||
137 | 480 | factory="zope.traversing.adapters.DefaultTraversable" | ||
138 | 481 | provides="zope.traversing.interfaces.ITraversable" /> | ||
139 | 482 | |||
140 | 483 | <webservice:register module="lazr.restful.testmodule" /> | ||
141 | 484 | </configure> | ||
142 | 485 | """) | ||
143 | 486 | |||
144 | 487 | |||
145 | 488 | class IGenericEntry(Interface): | ||
146 | 489 | """A simple, reusable entry interface for use in tests. | ||
147 | 490 | |||
148 | 491 | The entry publishes one field and one named operation. | ||
149 | 492 | """ | ||
150 | 493 | export_as_webservice_entry() | ||
151 | 494 | |||
152 | 495 | # pylint: disable-msg=E0213 | ||
153 | 496 | a_field = exported( | ||
154 | 497 | TextLine( | ||
155 | 498 | title=u'A "field"', | ||
156 | 499 | description=u'The only field that can be <> 0 in the entry.')) | ||
157 | 500 | |||
158 | 501 | @operation_parameters( | ||
159 | 502 | message=TextLine(title=u'Message to say')) | ||
160 | 503 | @export_read_operation() | ||
161 | 504 | def greet(message): | ||
162 | 505 | """Print an appropriate greeting based on the message. | ||
163 | 506 | |||
164 | 507 | :param message: This will be included in the greeting. | ||
165 | 508 | """ | ||
166 | 509 | |||
167 | 510 | |||
168 | 511 | class IGenericCollection(Interface): | ||
169 | 512 | """A simple collection containing `IGenericEntry`, for use in tests.""" | ||
170 | 513 | export_as_webservice_collection(IGenericEntry) | ||
171 | 514 | |||
172 | 515 | # pylint: disable-msg=E0211 | ||
173 | 516 | @collection_default_content() | ||
174 | 517 | def getAll(): | ||
175 | 518 | """Returns all the entries.""" | ||
176 | 519 | |||
177 | 520 | |||
178 | 388 | class DummyRootResource: | 521 | class DummyRootResource: |
179 | 389 | """A root resource that does nothing.""" | 522 | """A root resource that does nothing.""" |
180 | 390 | implements(IServiceRootResource) | 523 | implements(IServiceRootResource) |
181 | @@ -403,3 +536,5 @@ | |||
182 | 403 | def __str__(self): | 536 | def __str__(self): |
183 | 404 | return "http://dummy" | 537 | return "http://dummy" |
184 | 405 | __call__ = __str__ | 538 | __call__ = __str__ |
185 | 539 | |||
186 | 540 | |||
187 | 406 | 541 | ||
188 | === modified file 'src/lazr/restful/tests/test_webservice.py' | |||
189 | --- src/lazr/restful/tests/test_webservice.py 2010-03-03 13:05:13 +0000 | |||
190 | +++ src/lazr/restful/tests/test_webservice.py 2010-03-03 17:07:18 +0000 | |||
191 | @@ -6,18 +6,14 @@ | |||
192 | 6 | 6 | ||
193 | 7 | from cStringIO import StringIO | 7 | from cStringIO import StringIO |
194 | 8 | from operator import attrgetter | 8 | from operator import attrgetter |
195 | 9 | import sys | ||
196 | 10 | from types import ModuleType | ||
197 | 11 | import unittest | 9 | import unittest |
198 | 12 | 10 | ||
199 | 13 | from zope.component import getGlobalSiteManager, getUtility | 11 | from zope.component import getGlobalSiteManager, getUtility |
202 | 14 | from zope.configuration import xmlconfig | 12 | from zope.interface import implements, Interface |
201 | 15 | from zope.interface import alsoProvides, implements, Interface | ||
203 | 16 | from zope.publisher.browser import TestRequest | 13 | from zope.publisher.browser import TestRequest |
204 | 17 | from zope.schema import Date, Datetime, TextLine | 14 | from zope.schema import Date, Datetime, TextLine |
205 | 18 | from zope.security.management import ( | 15 | from zope.security.management import ( |
206 | 19 | endInteraction, newInteraction, queryInteraction) | 16 | endInteraction, newInteraction, queryInteraction) |
207 | 20 | from zope.testing.cleanup import CleanUp | ||
208 | 21 | from zope.traversing.browser.interfaces import IAbsoluteURL | 17 | from zope.traversing.browser.interfaces import IAbsoluteURL |
209 | 22 | 18 | ||
210 | 23 | from lazr.restful.fields import Reference | 19 | from lazr.restful.fields import Reference |
211 | @@ -25,15 +21,11 @@ | |||
212 | 25 | ICollection, IEntry, IEntryResource, IResourceGETOperation, | 21 | ICollection, IEntry, IEntryResource, IResourceGETOperation, |
213 | 26 | IServiceRootResource, IWebServiceConfiguration, | 22 | IServiceRootResource, IWebServiceConfiguration, |
214 | 27 | IWebServiceClientRequest, IWebServiceVersion) | 23 | IWebServiceClientRequest, IWebServiceVersion) |
222 | 28 | from lazr.restful import ( | 24 | from lazr.restful import EntryResource, ResourceGETOperation |
223 | 29 | EntryResource, ServiceRootResource, ResourceGETOperation) | 25 | from lazr.restful.declarations import exported, export_as_webservice_entry |
217 | 30 | from lazr.restful.simple import BaseWebServiceConfiguration, Request | ||
218 | 31 | from lazr.restful.declarations import ( | ||
219 | 32 | collection_default_content, exported, export_as_webservice_collection, | ||
220 | 33 | export_as_webservice_entry, export_read_operation, operation_parameters) | ||
221 | 34 | from lazr.restful.simple import RootResourceAbsoluteURL | ||
224 | 35 | from lazr.restful.testing.webservice import ( | 26 | from lazr.restful.testing.webservice import ( |
226 | 36 | create_web_service_request, WebServiceTestPublication) | 27 | create_web_service_request, IGenericCollection, IGenericEntry, |
227 | 28 | WebServiceTestCase, WebServiceTestPublication) | ||
228 | 37 | from lazr.restful.testing.tales import test_tales | 29 | from lazr.restful.testing.tales import test_tales |
229 | 38 | from lazr.restful.utils import ( | 30 | from lazr.restful.utils import ( |
230 | 39 | get_current_browser_request, get_current_web_service_request, | 31 | get_current_browser_request, get_current_web_service_request, |
231 | @@ -69,125 +61,10 @@ | |||
232 | 69 | IResourceGETOperation, name=name) | 61 | IResourceGETOperation, name=name) |
233 | 70 | 62 | ||
234 | 71 | 63 | ||
235 | 72 | class IGenericEntry(Interface): | ||
236 | 73 | """A simple, reusable entry interface. | ||
237 | 74 | |||
238 | 75 | This is the description of the entry. | ||
239 | 76 | """ | ||
240 | 77 | export_as_webservice_entry() | ||
241 | 78 | |||
242 | 79 | # pylint: disable-msg=E0213 | ||
243 | 80 | a_field = exported( | ||
244 | 81 | TextLine( | ||
245 | 82 | title=u'A "field"', | ||
246 | 83 | description=u'The only field that can be <> 0 in the entry.')) | ||
247 | 84 | |||
248 | 85 | @operation_parameters( | ||
249 | 86 | message=TextLine(title=u'Message to say')) | ||
250 | 87 | @export_read_operation() | ||
251 | 88 | def greet(message): | ||
252 | 89 | """Print an appropriate greeting based on the message. | ||
253 | 90 | |||
254 | 91 | :param message: This will be included in the greeting. | ||
255 | 92 | """ | ||
256 | 93 | |||
257 | 94 | |||
258 | 95 | class IGenericCollection(Interface): | ||
259 | 96 | """A simple collection containing `IGenericEntry`.""" | ||
260 | 97 | export_as_webservice_collection(IGenericEntry) | ||
261 | 98 | |||
262 | 99 | # pylint: disable-msg=E0211 | ||
263 | 100 | @collection_default_content() | ||
264 | 101 | def getAll(): | ||
265 | 102 | """Returns all the entries.""" | ||
266 | 103 | |||
267 | 104 | |||
268 | 105 | class IWebServiceRequest10(IWebServiceClientRequest): | ||
269 | 106 | """A marker interface for requests to the '1.0' web service.""" | ||
270 | 107 | |||
271 | 108 | |||
272 | 109 | class IWebServiceRequest20(IWebServiceClientRequest): | ||
273 | 110 | """A marker interface for requests to the '2.0' web service.""" | ||
274 | 111 | |||
275 | 112 | |||
276 | 113 | class SimpleWebServiceConfiguration(BaseWebServiceConfiguration): | ||
277 | 114 | implements(IWebServiceConfiguration) | ||
278 | 115 | show_tracebacks = False | ||
279 | 116 | active_versions = ['1.0', '2.0'] | ||
280 | 117 | hostname = "webservice_test" | ||
281 | 118 | last_version_with_mutator_named_operations = None | ||
282 | 119 | |||
283 | 120 | def createRequest(self, body_instream, environ): | ||
284 | 121 | request = Request(body_instream, environ) | ||
285 | 122 | request.version = '2.0' | ||
286 | 123 | alsoProvides(request, IWebServiceRequest20) | ||
287 | 124 | request.setPublication(WebServiceTestPublication( | ||
288 | 125 | getUtility(IServiceRootResource))) | ||
289 | 126 | request.annotations[request.VERSION_ANNOTATION] = '2.0' | ||
290 | 127 | return request | ||
291 | 128 | |||
292 | 129 | |||
293 | 130 | class WebServiceTestCase(CleanUp, unittest.TestCase): | ||
294 | 131 | """A test case for web service operations.""" | ||
295 | 132 | |||
296 | 133 | testmodule_objects = [] | ||
297 | 134 | |||
298 | 135 | def setUp(self): | ||
299 | 136 | """Set the component registry with the given model.""" | ||
300 | 137 | super(WebServiceTestCase, self).setUp() | ||
301 | 138 | |||
302 | 139 | # Register a simple configuration object. | ||
303 | 140 | webservice_configuration = SimpleWebServiceConfiguration() | ||
304 | 141 | sm = getGlobalSiteManager() | ||
305 | 142 | sm.registerUtility(webservice_configuration) | ||
306 | 143 | |||
307 | 144 | # Register IWebServiceVersions for the | ||
308 | 145 | # '1.0' and '2.0' web service versions. | ||
309 | 146 | alsoProvides(IWebServiceRequest10, IWebServiceVersion) | ||
310 | 147 | sm.registerUtility( | ||
311 | 148 | IWebServiceRequest10, IWebServiceVersion, name='1.0') | ||
312 | 149 | alsoProvides(IWebServiceRequest20, IWebServiceVersion) | ||
313 | 150 | sm.registerUtility( | ||
314 | 151 | IWebServiceRequest20, IWebServiceVersion, name='2.0') | ||
315 | 152 | |||
316 | 153 | # Register a service root resource | ||
317 | 154 | service_root = ServiceRootResource() | ||
318 | 155 | sm.registerUtility(service_root, IServiceRootResource) | ||
319 | 156 | |||
320 | 157 | # Register an IAbsoluteURL adapter for the service root resource. | ||
321 | 158 | sm.registerAdapter( | ||
322 | 159 | RootResourceAbsoluteURL, | ||
323 | 160 | [IServiceRootResource, IWebServiceClientRequest], IAbsoluteURL) | ||
324 | 161 | |||
325 | 162 | # Build a test module that exposes the given resource interfaces. | ||
326 | 163 | testmodule = ModuleType('testmodule') | ||
327 | 164 | for interface in self.testmodule_objects: | ||
328 | 165 | setattr(testmodule, interface.__name__, interface) | ||
329 | 166 | sys.modules['lazr.restful.testmodule'] = testmodule | ||
330 | 167 | |||
331 | 168 | # Register the test module in the ZCML configuration: adapter | ||
332 | 169 | # classes will be built automatically. | ||
333 | 170 | xmlconfig.string(""" | ||
334 | 171 | <configure | ||
335 | 172 | xmlns="http://namespaces.zope.org/zope" | ||
336 | 173 | xmlns:webservice="http://namespaces.canonical.com/webservice"> | ||
337 | 174 | <include package="zope.component" file="meta.zcml" /> | ||
338 | 175 | <include package="zope.security" file="meta.zcml"/> | ||
339 | 176 | <include package="lazr.restful" file="meta.zcml" /> | ||
340 | 177 | <include package="lazr.restful" file="configure.zcml" /> | ||
341 | 178 | |||
342 | 179 | <adapter for="*" | ||
343 | 180 | factory="zope.traversing.adapters.DefaultTraversable" | ||
344 | 181 | provides="zope.traversing.interfaces.ITraversable" /> | ||
345 | 182 | |||
346 | 183 | <webservice:register module="lazr.restful.testmodule" /> | ||
347 | 184 | </configure> | ||
348 | 185 | """) | ||
349 | 186 | |||
350 | 187 | |||
351 | 188 | class IHas_getitem(Interface): | 64 | class IHas_getitem(Interface): |
352 | 189 | pass | 65 | pass |
353 | 190 | 66 | ||
354 | 67 | |||
355 | 191 | class Has_getitem: | 68 | class Has_getitem: |
356 | 192 | implements(IHas_getitem) | 69 | implements(IHas_getitem) |
357 | 193 | def __getitem__(self, item): | 70 | def __getitem__(self, item): |
358 | @@ -320,8 +197,8 @@ | |||
359 | 320 | 'entry/wadl_entry:doc', entry=entry).splitlines() | 197 | 'entry/wadl_entry:doc', entry=entry).splitlines() |
360 | 321 | self.assertEquals([ | 198 | self.assertEquals([ |
361 | 322 | '<wadl:doc xmlns="http://www.w3.org/1999/xhtml">', | 199 | '<wadl:doc xmlns="http://www.w3.org/1999/xhtml">', |
364 | 323 | '<p>A simple, reusable entry interface.</p>', | 200 | '<p>A simple, reusable entry interface for use in tests.</p>', |
365 | 324 | '<p>This is the description of the entry.</p>', | 201 | '<p>The entry publishes one field and one named operation.</p>', |
366 | 325 | '', | 202 | '', |
367 | 326 | '</wadl:doc>'], doclines) | 203 | '</wadl:doc>'], doclines) |
368 | 327 | 204 | ||
369 | @@ -339,7 +216,7 @@ | |||
370 | 339 | ).splitlines() | 216 | ).splitlines() |
371 | 340 | self.assertEquals([ | 217 | self.assertEquals([ |
372 | 341 | '<wadl:doc xmlns="http://www.w3.org/1999/xhtml">', | 218 | '<wadl:doc xmlns="http://www.w3.org/1999/xhtml">', |
374 | 342 | 'A simple collection containing IGenericEntry.', | 219 | 'A simple collection containing IGenericEntry, for use in tests.', |
375 | 343 | '</wadl:doc>'], doclines) | 220 | '</wadl:doc>'], doclines) |
376 | 344 | 221 | ||
377 | 345 | def test_field_wadl_doc (self): | 222 | def test_field_wadl_doc (self): |
lazr.restful's unit test file test_webservice.py used to have a class called WebServiceTestCase that would set up a dummy web service and run some unit tests against it. Over time, the amount of setup work necessary increased, to the point where WSTC was basically setting up a fully functional web service.
When integrating a new lazr.restful version into Launchpad, I noticed that Launchpad also had unit tests that ran against a web service, and that I could save myself a lot of trouble by writing unit tests that subclassed WebServiceTestCase. I did this, but I pledged to come back and move WSTC (and its dependent classes) into lazr.restful. testing. webservice, so that Launchpad wouldn't be importing classes from a lazr.restful unit test module.
This branch does basically that, and nothing else. The one fix I made in passing was to change SimpleWebServic eConfiguration. createRequest to use the utility function tag_request_ with_version_ name(), replacing code that was basically a copy of tag_request_ with_version_ name. I also had to change the WADL unit tests, because I fleshed out the doctest strings of IGenericEntry and IGenericConfigu ration.