Merge lp:~cjwatson/lazr.restful/test-fixes into lp:lazr.restful

Proposed by Colin Watson on 2018-09-28
Status: Merged
Merged at revision: 222
Proposed branch: lp:~cjwatson/lazr.restful/test-fixes
Merge into: lp:lazr.restful
Diff against target: 481 lines (+87/-62)
23 files modified
buildout.cfg (+1/-1)
src/lazr/restful/NEWS.txt (+6/-0)
src/lazr/restful/_resource.py (+1/-0)
src/lazr/restful/declarations.py (+5/-2)
src/lazr/restful/docs/fields.txt (+1/-1)
src/lazr/restful/docs/webservice-declarations.txt (+13/-6)
src/lazr/restful/docs/webservice-marshallers.txt (+5/-3)
src/lazr/restful/docs/webservice-request.txt (+3/-3)
src/lazr/restful/docs/webservice.txt (+7/-3)
src/lazr/restful/example/base/configure.zcml (+2/-1)
src/lazr/restful/example/base/interfaces.py (+1/-0)
src/lazr/restful/example/base/tests/entry.txt (+1/-1)
src/lazr/restful/example/base/tests/test_integration.py (+5/-4)
src/lazr/restful/example/base/tests/wadl.txt (+2/-2)
src/lazr/restful/example/base_extended/tests/test_integration.py (+5/-4)
src/lazr/restful/example/multiversion/tests/operation.txt (+6/-2)
src/lazr/restful/example/multiversion/tests/test_integration.py (+5/-4)
src/lazr/restful/example/wsgi/tests/test_integration.py (+5/-4)
src/lazr/restful/metazcml.py (+2/-1)
src/lazr/restful/tests/test_docs.py (+4/-6)
src/lazr/restful/tests/test_error.py (+3/-4)
src/lazr/restful/tests/test_navigation.py (+0/-4)
src/lazr/restful/tests/test_webservice.py (+4/-6)
To merge this branch: bzr merge lp:~cjwatson/lazr.restful/test-fixes
Reviewer Review Type Date Requested Status
William Grant code 2018-09-28 Approve on 2018-10-01
Review via email: mp+355851@code.launchpad.net

Commit message

Fix an assortment of test failures.

To post a comment you must log in.
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'buildout.cfg'
2--- buildout.cfg 2015-07-08 04:22:39 +0000
3+++ buildout.cfg 2018-09-28 15:48:10 +0000
4@@ -12,7 +12,7 @@
5 [test]
6 recipe = zc.recipe.testrunner
7 eggs = lazr.restful [xml]
8-defaults = '--tests-pattern ^tests --exit-with-status --suite-name additional_tests'.split()
9+defaults = '--tests-pattern ^tests --exit-with-status'.split()
10
11 [docs]
12 recipe = z3c.recipe.sphinxdoc
13
14=== modified file 'src/lazr/restful/NEWS.txt'
15--- src/lazr/restful/NEWS.txt 2018-02-21 15:18:34 +0000
16+++ src/lazr/restful/NEWS.txt 2018-09-28 15:48:10 +0000
17@@ -2,6 +2,12 @@
18 NEWS for lazr.restful
19 =====================
20
21+0.20.2
22+======
23+
24+Generate IEntry subinterfaces with field ordering matching that in the
25+original interface.
26+
27 0.20.1 (2018-02-21)
28 ===================
29
30
31=== modified file 'src/lazr/restful/_resource.py'
32--- src/lazr/restful/_resource.py 2016-02-17 01:07:21 +0000
33+++ src/lazr/restful/_resource.py 2018-09-28 15:48:10 +0000
34@@ -1225,6 +1225,7 @@
35 try:
36 new_value = getattr(self.entry, field.__name__)
37 except Unauthorized:
38+ new_value = old_value
39 if flag is not Unauthorized:
40 force_clear = True
41 if force_clear or new_value != old_value:
42
43=== modified file 'src/lazr/restful/declarations.py'
44--- src/lazr/restful/declarations.py 2015-04-08 20:11:29 +0000
45+++ src/lazr/restful/declarations.py 2018-09-28 15:48:10 +0000
46@@ -48,7 +48,10 @@
47 from zope.interface.advice import addClassAdvisor
48 from zope.interface.interface import fromFunction, InterfaceClass, TAGGED_DATA
49 from zope.interface.interfaces import IInterface, IMethod
50-from zope.schema import getFields
51+from zope.schema import (
52+ getFields,
53+ getFieldsInOrder,
54+ )
55 from zope.schema.interfaces import (
56 IField,
57 IObject,
58@@ -1047,7 +1050,7 @@
59 # we'll iterate over once for each version.
60 tags_for_published_fields = []
61 for iface in itertools.chain([interface], contributors):
62- for name, field in getFields(iface).items():
63+ for name, field in getFieldsInOrder(iface):
64 tag_stack = field.queryTaggedValue(LAZR_WEBSERVICE_EXPORTED)
65 if tag_stack is None:
66 # This field is not published at all.
67
68=== modified file 'src/lazr/restful/docs/fields.txt'
69--- src/lazr/restful/docs/fields.txt 2009-03-28 14:35:27 +0000
70+++ src/lazr/restful/docs/fields.txt 2018-09-28 15:48:10 +0000
71@@ -79,7 +79,7 @@
72 >>> reference.validate(fake)
73 Traceback (most recent call last):
74 ...
75- SchemaNotProvided
76+ SchemaNotProvided: ...
77
78 >>> directlyProvides(fake, MySchema)
79 >>> reference.validate(fake)
80
81=== modified file 'src/lazr/restful/docs/webservice-declarations.txt'
82--- src/lazr/restful/docs/webservice-declarations.txt 2016-02-17 01:07:21 +0000
83+++ src/lazr/restful/docs/webservice-declarations.txt 2018-09-28 15:48:10 +0000
84@@ -1205,8 +1205,13 @@
85 Since the method is declared as returning a list of objects, the
86 return value is a dictionary containing a batched list.
87
88- >>> print read_method_adapter.call(text='')
89- {"total_size": 0, "start": 0, "entries": []}
90+ >>> import simplejson
91+ >>> for key, value in sorted(
92+ ... simplejson.loads(read_method_adapter.call(text='')).items()):
93+ ... print '%s: %s' % (key, value)
94+ entries: []
95+ start: 0
96+ total_size: 0
97
98 Methods exported as a write operations generates an adapter providing
99 IResourcePOSTOperation.
100@@ -1407,7 +1412,7 @@
101 Traceback (most recent call last):
102 ...
103 TypeError: An entry can only have one destructor method for
104- version (earliest version); destroy and destroy2 make two.
105+ version (earliest version); destroy... and destroy... make two.
106
107 Mutators
108 --------
109@@ -1622,8 +1627,10 @@
110 ... CachedBookSet(['Cool book']), request)
111 >>> print read_method_adapter.call()
112 ['Cool book']
113- >>> print request.response.headers
114- {'Content-Type': 'application/json', 'Cache-control': 'max-age=60'}
115+ >>> for name, value in sorted(request.response.headers.items()):
116+ ... print '%s: %s' % (name, value)
117+ Cache-control: max-age=60
118+ Content-Type: application/json
119
120 Only positive int or long objects should be passed to @cache_for:
121
122@@ -2716,7 +2723,7 @@
123 ...
124 ConfigurationExecutionError: ... Method "method" contains
125 annotations for version "2.0", even though it's not published in
126- that version. The bad annotations are: "params", "as".
127+ that version. The bad annotations are: "as", "params".
128 ...
129
130 Mutators as named operations
131
132=== modified file 'src/lazr/restful/docs/webservice-marshallers.txt'
133--- src/lazr/restful/docs/webservice-marshallers.txt 2016-02-16 13:32:24 +0000
134+++ src/lazr/restful/docs/webservice-marshallers.txt 2018-09-28 15:48:10 +0000
135@@ -609,7 +609,7 @@
136 ... try:
137 ... callable(*args)
138 ... except ValueError as e:
139- ... print 'ValueError:', e.message
140+ ... print 'ValueError:', unicode(e)
141
142
143 Choice of EnumeratedTypes
144@@ -849,8 +849,10 @@
145 (1, 2, 3)
146 >>> marshalled_set = set_marshaller.marshall_from_json_data(
147 ... ['Vegetarian', 'Dessert'])
148- >>> marshalled_set
149- set([<Item Cuisine.DESSERT, ...>, <Item Cuisine.VEGETARIAN, ...>])
150+ >>> type(marshalled_set)
151+ <type 'set'>
152+ >>> sorted(marshalled_set)
153+ [<Item Cuisine.VEGETARIAN, ...>, <Item Cuisine.DESSERT, ...>]
154
155 >>> result = choice_list_marshaller.marshall_from_request(
156 ... [u'Vegetarian', u'General'])
157
158=== modified file 'src/lazr/restful/docs/webservice-request.txt'
159--- src/lazr/restful/docs/webservice-request.txt 2016-02-17 01:07:21 +0000
160+++ src/lazr/restful/docs/webservice-request.txt 2018-09-28 15:48:10 +0000
161@@ -66,7 +66,7 @@
162
163 >>> cache.objects['object1'] = 'foo'
164 >>> cache.objects['object2'] = 'bar'
165- >>> for key in cache.objects:
166+ >>> for key in sorted(cache.objects):
167 ... print "%s: %s" % (key, cache.objects[key])
168 object1: foo
169 object2: bar
170@@ -76,7 +76,7 @@
171
172 >>> cache.links['objectA'] = 'foo'
173 >>> cache.links['objectB'] = 'bar'
174- >>> for key in cache.links:
175+ >>> for key in sorted(cache.links):
176 ... print "%s: %s" % (key, cache.links[key])
177 objectA: foo
178 objectB: bar
179@@ -94,7 +94,7 @@
180
181 >>> cache = test_tales(
182 ... "request/webservicerequest:cache", request=website_request)
183- >>> for key in cache.links:
184+ >>> for key in sorted(cache.links):
185 ... print "%s: %s" % (key, cache.links[key])
186 objectA: foo
187 objectB: bar
188
189=== modified file 'src/lazr/restful/docs/webservice.txt'
190--- src/lazr/restful/docs/webservice.txt 2016-02-17 01:07:21 +0000
191+++ src/lazr/restful/docs/webservice.txt 2018-09-28 15:48:10 +0000
192@@ -1577,8 +1577,12 @@
193
194 >>> recipes = DummyResultSet()
195 >>> request, operation = make_dummy_operation_request(recipes)
196- >>> operation()
197- '{"total_size": 2, ... "entries": [{...}, {...}]}'
198+ >>> response = operation()
199+ >>> for key, value in sorted(simplejson.loads(response).items()):
200+ ... print '%s: %s' % (key, value)
201+ entries: [{...}, {...}]
202+ start: ...
203+ total_size: 2
204
205 When a named operation returns an object that has an ``ICollection``
206 implementation, the result is similar: we return a JSON hash describing one
207@@ -2127,6 +2131,6 @@
208 >>> test_tales("context/webservice:json", context="foobar")
209 '"foobar"'
210 >>> test_tales("context/webservice:json", context=A1)
211- '{"name": ...}'
212+ '{..."name": ...}'
213 >>> test_tales("context/webservice:json", context="<foo&>")
214 '"\\u003cfoo\\u0026\\u003e"'
215
216=== modified file 'src/lazr/restful/example/base/configure.zcml'
217--- src/lazr/restful/example/base/configure.zcml 2011-03-25 12:34:21 +0000
218+++ src/lazr/restful/example/base/configure.zcml 2018-09-28 15:48:10 +0000
219@@ -1,7 +1,8 @@
220 <configure
221 xmlns="http://namespaces.zope.org/zope"
222 xmlns:webservice="http://namespaces.canonical.com/webservice"
223- xmlns:grok="http://namespaces.zope.org/grok">
224+ xmlns:grok="http://namespaces.zope.org/grok"
225+ i18n_domain="lazr">
226
227 <webservice:register module="lazr.restful.example.base.interfaces" />
228 <grok:grok package="lazr.restful.example.base" />
229
230=== modified file 'src/lazr/restful/example/base/interfaces.py'
231--- src/lazr/restful/example/base/interfaces.py 2010-08-26 18:22:19 +0000
232+++ src/lazr/restful/example/base/interfaces.py 2018-09-28 15:48:10 +0000
233@@ -8,6 +8,7 @@
234 'Cuisine',
235 'ICookbook',
236 'ICookbookSet',
237+ 'ICookbookSubclass',
238 'IDish',
239 'IDishSet',
240 'IFileManager',
241
242=== modified file 'src/lazr/restful/example/base/tests/entry.txt'
243--- src/lazr/restful/example/base/tests/entry.txt 2012-09-26 09:32:58 +0000
244+++ src/lazr/restful/example/base/tests/entry.txt 2018-09-28 15:48:10 +0000
245@@ -917,7 +917,7 @@
246 >>> print modify_cookbook('Everyday Greens', {'name' : 'Greens'}, 'PUT')
247 HTTP/1.1 400 Bad Request
248 ...
249- You didn't specify a value for the attribute 'cuisine'.
250+ You didn't specify a value for the attribute 'description'.
251
252 A document that's not a valid JSON document is also unacceptable.
253
254
255=== modified file 'src/lazr/restful/example/base/tests/test_integration.py'
256--- src/lazr/restful/example/base/tests/test_integration.py 2015-04-08 20:11:29 +0000
257+++ src/lazr/restful/example/base/tests/test_integration.py 2018-09-28 15:48:10 +0000
258@@ -39,12 +39,13 @@
259 wsgi_intercept_layer(WSGILayer)
260
261
262-def additional_tests():
263+def load_tests(loader, tests, pattern):
264 """See `zope.testing.testrunner`."""
265- tests = sorted(
266+ doctest_files = sorted(
267 [name
268 for name in os.listdir(os.path.dirname(__file__))
269 if name.endswith('.txt')])
270- suite = doctest.DocFileSuite(optionflags=DOCTEST_FLAGS, *tests)
271+ suite = doctest.DocFileSuite(optionflags=DOCTEST_FLAGS, *doctest_files)
272 suite.layer = WSGILayer
273- return suite
274+ tests.addTest(suite)
275+ return tests
276
277=== modified file 'src/lazr/restful/example/base/tests/wadl.txt'
278--- src/lazr/restful/example/base/tests/wadl.txt 2011-02-02 13:31:21 +0000
279+++ src/lazr/restful/example/base/tests/wadl.txt 2018-09-28 15:48:10 +0000
280@@ -639,8 +639,8 @@
281
282 >>> find_request = find_recipes.find(wadl_tag('request'))
283 >>> find_response = find_recipes.find(wadl_tag('response'))
284- >>> [param.attrib['name'] for param in find_request]
285- ['ws.op', 'vegetarian', 'search']
286+ >>> sorted([param.attrib['name'] for param in find_request])
287+ ['search', 'vegetarian', 'ws.op']
288
289 >>> ws_op = find_request[0]
290 >>> ws_op.attrib['fixed']
291
292=== modified file 'src/lazr/restful/example/base_extended/tests/test_integration.py'
293--- src/lazr/restful/example/base_extended/tests/test_integration.py 2010-08-05 13:12:00 +0000
294+++ src/lazr/restful/example/base_extended/tests/test_integration.py 2018-09-28 15:48:10 +0000
295@@ -30,9 +30,10 @@
296 wsgi_intercept_layer(WSGILayer)
297
298
299-def additional_tests():
300+def load_tests(loader, tests, pattern):
301 """See `zope.testing.testrunner`."""
302- tests = ['../README.txt']
303- suite = doctest.DocFileSuite(optionflags=DOCTEST_FLAGS, *tests)
304+ doctest_files = ['../README.txt']
305+ suite = doctest.DocFileSuite(optionflags=DOCTEST_FLAGS, *doctest_files)
306 suite.layer = WSGILayer
307- return suite
308+ tests.addTest(suite)
309+ return tests
310
311=== modified file 'src/lazr/restful/example/multiversion/tests/operation.txt'
312--- src/lazr/restful/example/multiversion/tests/operation.txt 2010-08-18 15:33:46 +0000
313+++ src/lazr/restful/example/multiversion/tests/operation.txt 2018-09-28 15:48:10 +0000
314@@ -52,8 +52,12 @@
315 >>> print sorted(get_collection('3.0', 'by_value', size=100).keys())
316 [u'entries', u'start', u'total_size']
317
318- >>> print get_collection('3.0', 'by_value', 'no-such-value')
319- {u'total_size': 0, u'start': 0, u'entries': []}
320+ >>> for key, value in sorted(
321+ ... get_collection('3.0', 'by_value', 'no-such-value').items()):
322+ ... print '%s: %s' % (key, value)
323+ entries: []
324+ start: 0
325+ total_size: 0
326
327 Mutators as named operations
328 ----------------------------
329
330=== modified file 'src/lazr/restful/example/multiversion/tests/test_integration.py'
331--- src/lazr/restful/example/multiversion/tests/test_integration.py 2009-11-16 14:25:45 +0000
332+++ src/lazr/restful/example/multiversion/tests/test_integration.py 2018-09-28 15:48:10 +0000
333@@ -42,12 +42,13 @@
334 wsgi_intercept_layer(WSGILayer)
335
336
337-def additional_tests():
338+def load_tests(loader, tests, pattern):
339 """See `zope.testing.testrunner`."""
340- tests = sorted(
341+ doctest_files = sorted(
342 [name
343 for name in os.listdir(os.path.dirname(__file__))
344 if name.endswith('.txt')])
345- suite = doctest.DocFileSuite(optionflags=DOCTEST_FLAGS, *tests)
346+ suite = doctest.DocFileSuite(optionflags=DOCTEST_FLAGS, *doctest_files)
347 suite.layer = WSGILayer
348- return suite
349+ tests.addTest(suite)
350+ return tests
351
352=== modified file 'src/lazr/restful/example/wsgi/tests/test_integration.py'
353--- src/lazr/restful/example/wsgi/tests/test_integration.py 2015-04-08 20:11:29 +0000
354+++ src/lazr/restful/example/wsgi/tests/test_integration.py 2018-09-28 15:48:10 +0000
355@@ -39,12 +39,13 @@
356 wsgi_intercept_layer(WSGILayer)
357
358
359-def additional_tests():
360+def load_tests(loader, tests, pattern):
361 """See `zope.testing.testrunner`."""
362- tests = sorted(
363+ doctest_files = sorted(
364 [name
365 for name in os.listdir(os.path.dirname(__file__))
366 if name.endswith('.txt')])
367- suite = doctest.DocFileSuite(optionflags=DOCTEST_FLAGS, *tests)
368+ suite = doctest.DocFileSuite(optionflags=DOCTEST_FLAGS, *doctest_files)
369 suite.layer = WSGILayer
370- return suite
371+ tests.addTest(suite)
372+ return tests
373
374=== modified file 'src/lazr/restful/metazcml.py'
375--- src/lazr/restful/metazcml.py 2016-11-26 00:54:04 +0000
376+++ src/lazr/restful/metazcml.py 2018-09-28 15:48:10 +0000
377@@ -563,7 +563,8 @@
378 'Method "%s" contains annotations for version "%s", '
379 'even though it\'s not published in that version. '
380 'The bad annotations are: "%s".' % (
381- method.__name__, version, '", "'.join(tag_names)))
382+ method.__name__, version,
383+ '", "'.join(sorted(tag_names))))
384 else:
385 if tag['type'] == 'read_operation':
386 operation_provides = IResourceGETOperation
387
388=== modified file 'src/lazr/restful/tests/test_docs.py'
389--- src/lazr/restful/tests/test_docs.py 2010-10-01 21:31:53 +0000
390+++ src/lazr/restful/tests/test_docs.py 2018-09-28 15:48:10 +0000
391@@ -18,9 +18,7 @@
392 # pylint: disable-msg=E0611,W0142
393
394 __metaclass__ = type
395-__all__ = [
396- 'additional_tests',
397- ]
398+__all__ = []
399
400 import atexit
401 import doctest
402@@ -43,7 +41,7 @@
403 cleanUp()
404
405
406-def additional_tests():
407+def load_tests(loader, tests, pattern):
408 "Run the doc tests (README.txt and docs/*, if any exist)"
409 doctest_files = [
410 os.path.abspath(resource_filename('lazr.restful', 'README.txt'))]
411@@ -56,5 +54,5 @@
412 kwargs = dict(module_relative=False, optionflags=DOCTEST_FLAGS,
413 tearDown=tearDown)
414 atexit.register(cleanup_resources)
415- return unittest.TestSuite((
416- doctest.DocFileSuite(*doctest_files, **kwargs)))
417+ tests.addTest(doctest.DocFileSuite(*doctest_files, **kwargs))
418+ return tests
419
420=== modified file 'src/lazr/restful/tests/test_error.py'
421--- src/lazr/restful/tests/test_error.py 2016-02-16 13:32:24 +0000
422+++ src/lazr/restful/tests/test_error.py 2018-09-28 15:48:10 +0000
423@@ -255,8 +255,7 @@
424 zcml_layer(FunctionalLayer)
425
426
427-def additional_tests():
428+def load_tests(loader, tests, pattern):
429 """See `zope.testing.testrunner`."""
430- suite = unittest.TestLoader().loadTestsFromName(__name__)
431- suite.layer = FunctionalLayer
432- return suite
433+ tests.layer = FunctionalLayer
434+ return tests
435
436=== modified file 'src/lazr/restful/tests/test_navigation.py'
437--- src/lazr/restful/tests/test_navigation.py 2016-02-17 01:07:21 +0000
438+++ src/lazr/restful/tests/test_navigation.py 2018-09-28 15:48:10 +0000
439@@ -136,7 +136,3 @@
440 getMultiAdapter, (entry_obj, request), IEntry)
441 self.assertRaises(
442 NotFound, publication.getResource, request, entry_obj)
443-
444-
445-def additional_tests():
446- return unittest.TestLoader().loadTestsFromName(__name__)
447
448=== modified file 'src/lazr/restful/tests/test_webservice.py'
449--- src/lazr/restful/tests/test_webservice.py 2016-02-17 01:07:21 +0000
450+++ src/lazr/restful/tests/test_webservice.py 2018-09-28 15:48:10 +0000
451@@ -737,7 +737,7 @@
452 '<p>Print an appropriate greeting based on the message.</p>',],
453 doclines[0:2])
454 self.assertEquals('</wadl:doc>', doclines[-1])
455- self.failUnless(len(doclines) > 3,
456+ self.assertTrue(len(doclines) > 3,
457 'Missing the parameter table: %s' % "\n".join(doclines))
458
459
460@@ -805,7 +805,9 @@
461 # The individual entity attributes should be listed in alphabetical
462 # order by class.
463 self.assertEqual(
464- re.findall(r'<wadl:param [^>]* name="(.)_field">', self.wadl)[:9],
465+ re.findall(
466+ r'<wadl:param (?:[^>]* )*name="(.)_field"(?: [^>]*)*>',
467+ self.wadl)[:9],
468 ['r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'])
469
470
471@@ -886,10 +888,6 @@
472 endInteraction()
473
474
475-def additional_tests():
476- return unittest.TestLoader().loadTestsFromName(__name__)
477-
478-
479 class ITestEntry(IEntry):
480 """Interface for a test entry."""
481 export_as_webservice_entry()

Subscribers

People subscribed via source and target branches