Merge ~jugmac00/lazr.restful:apply-inclusive-naming into lazr.restful:main
- Git
- lp:~jugmac00/lazr.restful
- apply-inclusive-naming
- Merge into main
Proposed by
Jürgen Gmach
Status: | Merged |
---|---|
Merge reported by: | Jürgen Gmach |
Merged at revision: | c30f79d761297a5cb13c3ca53f4e40d274df6a71 |
Proposed branch: | ~jugmac00/lazr.restful:apply-inclusive-naming |
Merge into: | lazr.restful:main |
Diff against target: |
1181 lines (+357/-113) 19 files modified
.pre-commit-config.yaml (+4/-0) .woke.yaml (+228/-0) NEWS.rst (+11/-1) src/lazr/restful/configure.zcml (+1/-1) src/lazr/restful/docs/absoluteurl.rst (+9/-9) src/lazr/restful/docs/django.rst (+4/-4) src/lazr/restful/docs/webservice-declarations.rst (+5/-5) src/lazr/restful/docs/webservice-marshallers.rst (+1/-1) src/lazr/restful/docs/webservice.rst (+19/-19) src/lazr/restful/example/base/configure.zcml (+2/-2) src/lazr/restful/example/base/tests/collection.txt (+1/-1) src/lazr/restful/example/base/tests/entry.txt (+13/-13) src/lazr/restful/example/base/tests/field.txt (+7/-7) src/lazr/restful/example/base/tests/representation-cache.txt (+1/-1) src/lazr/restful/metazcml.py (+4/-4) src/lazr/restful/testing/helpers.py (+2/-2) src/lazr/restful/testing/webservice.py (+9/-9) src/lazr/restful/tests/test_declarations.py (+23/-21) src/lazr/restful/tests/test_webservice.py (+13/-13) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Colin Watson (community) | Approve | ||
Review via email: mp+411617@code.launchpad.net |
Commit message
Apply inclusive naming via the `woke` pre-commit hook
Description of the change
To post a comment you must log in.
Revision history for this message
Jürgen Gmach (jugmac00) wrote : | # |
Thanks for the review!
When applying the changes, I quickly thought whether this affects public API or not, and looks like I erred on the wrong side :-)
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml |
2 | index 45fd4ba..f72d079 100644 |
3 | --- a/.pre-commit-config.yaml |
4 | +++ b/.pre-commit-config.yaml |
5 | @@ -13,3 +13,7 @@ repos: |
6 | rev: 3.9.2 |
7 | hooks: |
8 | - id: flake8 |
9 | +- repo: https://github.com/get-woke/woke |
10 | + rev: v0.17.0 |
11 | + hooks: |
12 | + - id: woke-from-source |
13 | diff --git a/.woke.yaml b/.woke.yaml |
14 | new file mode 100644 |
15 | index 0000000..424838e |
16 | --- /dev/null |
17 | +++ b/.woke.yaml |
18 | @@ -0,0 +1,228 @@ |
19 | + |
20 | +# Based on Canonical's Guidelines |
21 | +# https://docs.google.com/document/d/1mJUa1VJHOMWa723dmKmNjSKGW-nlBv9xktzGZZwacVo/edit#heading=h.5efudb237qdb |
22 | +rules: |
23 | + - name: whitelist |
24 | + terms: |
25 | + - whitelist |
26 | + - white-list |
27 | + - whitelisted |
28 | + - white-listed |
29 | + alternatives: |
30 | + - allowlist |
31 | + - inclusion list |
32 | + severity: warning |
33 | + note: "The underlying assumption of the whitelist/blacklist metaphor is that white = good and black = bad. Because colors in and of themselves have no predetermined meaning, any meaning we assign to them is cultural: for example, the color red in many Southeast Asian countries is lucky, and is often associated with events like marriages, whereas the color white carries the same connotations in many European countries. In the case of whitelist/blacklist, the terms originate in the publishing industry – one dominated by the USA and England, two countries which participated in slavery and which grapple with their racist legacies to this day." |
34 | + |
35 | + - name: blacklist |
36 | + terms: |
37 | + - blacklist |
38 | + - black-list |
39 | + - blacklisted |
40 | + - black-listed |
41 | + alternatives: |
42 | + - denylist |
43 | + - blocklist |
44 | + - exclusion list |
45 | + severity: warning |
46 | + note: "The underlying assumption of the whitelist/blacklist metaphor is that white = good and black = bad. Because colors in and of themselves have no predetermined meaning, any meaning we assign to them is cultural: for example, the color red in many Southeast Asian countries is lucky, and is often associated with events like marriages, whereas the color white carries the same connotations in many European countries. In the case of whitelist/blacklist, the terms originate in the publishing industry – one dominated by the USA and England, two countries which participated in slavery and which grapple with their racist legacies to this day." |
47 | + |
48 | + - name: master-slave |
49 | + terms: |
50 | + - master-slave |
51 | + - master/slave |
52 | + alternatives: |
53 | + - leader/follower |
54 | + - main/replica |
55 | + - primary/replica |
56 | + - primary/standby |
57 | + - primary/secondary |
58 | + |
59 | + - name: slave |
60 | + terms: |
61 | + - slave |
62 | + alternatives: |
63 | + - follower |
64 | + - replica |
65 | + - standby |
66 | + |
67 | + - name: grandfathered |
68 | + terms: |
69 | + - grandfathered |
70 | + alternatives: |
71 | + - legacy status |
72 | + - legacied |
73 | + - exempted |
74 | + - carried |
75 | + - brought forward |
76 | + - rolled over |
77 | + |
78 | + - name: man-hours |
79 | + terms: |
80 | + - man hours |
81 | + - man-hours |
82 | + alternatives: |
83 | + - person hours |
84 | + - engineer hours |
85 | + |
86 | + - name: sanity |
87 | + terms: |
88 | + - sanity |
89 | + alternatives: |
90 | + - confidence |
91 | + - quick check |
92 | + - coherence check |
93 | + |
94 | + - name: dummy |
95 | + terms: |
96 | + - dummy |
97 | + alternatives: |
98 | + - placeholder |
99 | + - sample |
100 | + |
101 | + - name: guys |
102 | + terms: |
103 | + - guys |
104 | + alternatives: |
105 | + - folks |
106 | + - people |
107 | + - you all |
108 | + - y'all |
109 | + - yinz |
110 | + |
111 | + - name: whitebox |
112 | + terms: |
113 | + - white-box |
114 | + - whitebox |
115 | + - white box |
116 | + alternatives: |
117 | + - open-box |
118 | + |
119 | + - name: blackbox |
120 | + terms: |
121 | + - black-box |
122 | + - blackbox |
123 | + - black box |
124 | + alternatives: |
125 | + - closed-box |
126 | + |
127 | + - name: blackhat |
128 | + terms: |
129 | + - blackhat |
130 | + - black-hat |
131 | + - black hat |
132 | + alternatives: |
133 | + - attacker |
134 | + - malicious actor |
135 | + |
136 | + - name: whitehat |
137 | + terms: |
138 | + - whitehat |
139 | + - white-hat |
140 | + - white hat |
141 | + alternatives: |
142 | + - researcher |
143 | + - security specialist |
144 | + |
145 | + - name: illegal characters |
146 | + terms: |
147 | + - illegal characters |
148 | + alternatives: |
149 | + - invalid characters |
150 | + - unsupported characters |
151 | + - special characters |
152 | + |
153 | + - name: native feature |
154 | + terms: |
155 | + - native feature |
156 | + alternatives: |
157 | + - core feature |
158 | + - built-in feature |
159 | + |
160 | + - name: native feature |
161 | + terms: |
162 | + - native feature |
163 | + alternatives: |
164 | + - core feature |
165 | + - built-in feature |
166 | + |
167 | + - name: chairman/foreman |
168 | + terms: |
169 | + - chairman |
170 | + - foreman |
171 | + alternatives: |
172 | + - chair |
173 | + - foreperson |
174 | + |
175 | + - name: man in the middle |
176 | + terms: |
177 | + - man in the middle |
178 | + - man-in-the-middle |
179 | + alternatives: |
180 | + - machine-in-the-middle |
181 | + - person-in-the-middle |
182 | + - system-in-the-middle |
183 | + - intermediary attack |
184 | + |
185 | + - name: middleman |
186 | + terms: |
187 | + - middleman |
188 | + alternatives: |
189 | + - middleperson |
190 | + - intermediary |
191 | + |
192 | + - name: manned |
193 | + terms: |
194 | + - manned |
195 | + alternatives: |
196 | + - crewed |
197 | + - staffed |
198 | + - monitored |
199 | + - human operated |
200 | + |
201 | + - name: mom test / girlfriend test |
202 | + terms: |
203 | + - mom test |
204 | + - girlfriend test |
205 | + alternatives: |
206 | + - user test |
207 | + - user friendly |
208 | + |
209 | + - name: crazy |
210 | + terms: |
211 | + - crazy |
212 | + alternatives: |
213 | + - baffling |
214 | + - unexplained |
215 | + - errant |
216 | + |
217 | + - name: cripples |
218 | + terms: |
219 | + - cripples |
220 | + alternatives: |
221 | + - slows down |
222 | + - hinders |
223 | + - obstructs |
224 | + |
225 | + - name: crippling |
226 | + terms: |
227 | + - crippling |
228 | + alternatives: |
229 | + - attenuating |
230 | + - incapacitating |
231 | + |
232 | + - name: stonith/stomith |
233 | + terms: |
234 | + - stonith |
235 | + - stomith |
236 | + alternatives: |
237 | + - fence failed nodes |
238 | + - machines |
239 | + |
240 | + - name: demilitarized zone |
241 | + terms: |
242 | + - demilitarized zone |
243 | + - dmz |
244 | + alternatives: |
245 | + - perimeter network |
246 | + - passthrough network |
247 | \ No newline at end of file |
248 | diff --git a/NEWS.rst b/NEWS.rst |
249 | index 8a73089..3b8f8f3 100644 |
250 | --- a/NEWS.rst |
251 | +++ b/NEWS.rst |
252 | @@ -2,12 +2,22 @@ |
253 | NEWS for lazr.restful |
254 | ===================== |
255 | |
256 | -1.1.1 |
257 | +1.2.0 |
258 | ===== |
259 | |
260 | - Add support for Python 3.9 and 3.10. |
261 | - Add basic pre-commit configuration. |
262 | - Publish docs on Read the Docs. |
263 | +- Apply inclusive naming via the woke pre-commit hook. The following API |
264 | + changes were performed: |
265 | + ``lazr.restful.metazcml.webservice_sanity_checks`` |
266 | + => ``lazr.restful.metazcml.webservice_coherence_checks``, |
267 | + ``lazr.restful.testing.webservice.DummyURL`` |
268 | + => ``lazr.restful.testing.webservice.StubAbsoluteURL``, |
269 | + ``lazr.restful.testing.webservice.DummyAbsoluteURL`` |
270 | + => ``lazr.restful.testing.webservice.StubAbsoluteURL``, |
271 | + ``lazr.restful.testing.webservice.DummyRootResourceURL`` |
272 | + => ``lazr.restful.testing.webservice.StubRootResourceURL`` |
273 | |
274 | 1.1.0 (2021-10-07) |
275 | ================== |
276 | diff --git a/src/lazr/restful/configure.zcml b/src/lazr/restful/configure.zcml |
277 | index 107c0fe..d6e0416 100644 |
278 | --- a/src/lazr/restful/configure.zcml |
279 | +++ b/src/lazr/restful/configure.zcml |
280 | @@ -20,7 +20,7 @@ |
281 | </class> |
282 | |
283 | <subscriber for="zope.processlifetime.IProcessStarting" |
284 | - handler="lazr.restful.metazcml.webservice_sanity_checks" /> |
285 | + handler="lazr.restful.metazcml.webservice_coherence_checks" /> |
286 | |
287 | <!-- |
288 | XXX flacoste 2008/05/09 bug=185958: |
289 | diff --git a/src/lazr/restful/docs/absoluteurl.rst b/src/lazr/restful/docs/absoluteurl.rst |
290 | index 76de5db..3c6fe25 100644 |
291 | --- a/src/lazr/restful/docs/absoluteurl.rst |
292 | +++ b/src/lazr/restful/docs/absoluteurl.rst |
293 | @@ -128,14 +128,14 @@ http://top-level/child-part1/child-part2/grandchild |
294 | AbsoluteURL won't work, but lazr.restful's MultiplePathPartAbsoluteURL |
295 | will. |
296 | |
297 | -To test this, we'll start with a DummyRootResource and its absolute |
298 | -URL generator, DummyRootResourceURL. |
299 | +To test this, we'll start with a StubRootResource and its absolute |
300 | +URL generator, StubRootResourceURL. |
301 | |
302 | >>> from lazr.restful.testing.webservice import ( |
303 | - ... DummyRootResource, DummyRootResourceURL) |
304 | + ... StubRootResource, StubRootResourceURL) |
305 | >>> from zope.component import getSiteManager |
306 | >>> sm = getSiteManager() |
307 | - >>> sm.registerAdapter(DummyRootResourceURL) |
308 | + >>> sm.registerAdapter(StubRootResourceURL) |
309 | |
310 | We'll load the basic lazr.restful site configuration. |
311 | |
312 | @@ -154,14 +154,14 @@ We'll load the basic lazr.restful site configuration. |
313 | ... """) |
314 | >>> load_config() |
315 | |
316 | -Here's a child of DummyRootResource that implements |
317 | +Here's a child of StubRootResource that implements |
318 | IMultiplePathPartLocation. |
319 | |
320 | >>> from zope.interface import implementer |
321 | >>> from lazr.restful.simple import IMultiplePathPartLocation |
322 | >>> @implementer(IMultiplePathPartLocation) |
323 | ... class ChildResource: |
324 | - ... __parent__ = DummyRootResource() |
325 | + ... __parent__ = StubRootResource() |
326 | ... __path_parts__ = ["child-part1", "child-part2"] |
327 | |
328 | The ChildResource's URL includes one URL part from the root resource, |
329 | @@ -169,7 +169,7 @@ followed by two from the ChildResource itself. |
330 | |
331 | >>> resource = ChildResource() |
332 | >>> print(str(getMultiAdapter((resource, request), IAbsoluteURL))) |
333 | - http://dummyurl/child-part1/child-part2 |
334 | + http://exampleurl/child-part1/child-part2 |
335 | |
336 | Now let's put an object underneath the child resource that implements |
337 | ILocation, as most resources will. |
338 | @@ -186,7 +186,7 @@ GrandchildResource itself. |
339 | |
340 | >>> print(str(getMultiAdapter( |
341 | ... (GrandchildResource(), request), IAbsoluteURL))) |
342 | - http://dummyurl/child-part1/child-part2/grandchild |
343 | + http://exampleurl/child-part1/child-part2/grandchild |
344 | |
345 | Edge cases and error handling |
346 | ============================= |
347 | @@ -196,7 +196,7 @@ It even escapes slashes, if a slash shows up inside a path part. |
348 | |
349 | >>> resource.__path_parts__ = ["!foo!", "bar/baz"] |
350 | >>> print(str(getMultiAdapter((resource, request), IAbsoluteURL))) |
351 | - http://dummyurl/%21foo%21/bar%2Fbaz |
352 | + http://exampleurl/%21foo%21/bar%2Fbaz |
353 | |
354 | If the __path_parts__ is not iterable, an attempt to get the URL |
355 | raises an exception: |
356 | diff --git a/src/lazr/restful/docs/django.rst b/src/lazr/restful/docs/django.rst |
357 | index 2c6d52e..2ad1df2 100644 |
358 | --- a/src/lazr/restful/docs/django.rst |
359 | +++ b/src/lazr/restful/docs/django.rst |
360 | @@ -138,10 +138,10 @@ Here's some setup; a root resource that has its own AbsoluteURL |
361 | implementation. |
362 | |
363 | >>> from lazr.restful.testing.webservice import ( |
364 | - ... DummyRootResource, DummyRootResourceURL) |
365 | + ... StubRootResource, StubRootResourceURL) |
366 | >>> from zope.component import getSiteManager |
367 | >>> sm = getSiteManager() |
368 | - >>> sm.registerAdapter(DummyRootResourceURL) |
369 | + >>> sm.registerAdapter(StubRootResourceURL) |
370 | |
371 | Now here's a subordinate resource that just implements IDjangoLocatino. |
372 | |
373 | @@ -152,7 +152,7 @@ Now here's a subordinate resource that just implements IDjangoLocatino. |
374 | ... |
375 | ... @property |
376 | ... def __parent_object__(self): |
377 | - ... return DummyRootResource() |
378 | + ... return StubRootResource() |
379 | ... |
380 | ... @property |
381 | ... def __url_path__(self): |
382 | @@ -177,7 +177,7 @@ get its full URL. |
383 | >>> from lazr.restful.simple import Request |
384 | >>> request = Request("", {}) |
385 | >>> print(str(getMultiAdapter((resource, request), IAbsoluteURL))) |
386 | - http://dummyurl/myname |
387 | + http://exampleurl/myname |
388 | |
389 | |
390 | ObjectDoesNotExist |
391 | diff --git a/src/lazr/restful/docs/webservice-declarations.rst b/src/lazr/restful/docs/webservice-declarations.rst |
392 | index f9d932a..2db2286 100644 |
393 | --- a/src/lazr/restful/docs/webservice-declarations.rst |
394 | +++ b/src/lazr/restful/docs/webservice-declarations.rst |
395 | @@ -240,10 +240,10 @@ interface: |
396 | It's an error to try to export a collection without marking a method as |
397 | exporting the default content. |
398 | |
399 | - >>> class IDummyInterface(Interface): |
400 | + >>> class ISampleInterface(Interface): |
401 | ... pass |
402 | |
403 | - >>> @exported_as_webservice_collection(IDummyInterface) |
404 | + >>> @exported_as_webservice_collection(ISampleInterface) |
405 | ... class MissingDefaultContent(Interface): |
406 | ... pass |
407 | Traceback (most recent call last): |
408 | @@ -253,7 +253,7 @@ exporting the default content. |
409 | |
410 | As it is an error, to mark more than one method: |
411 | |
412 | - >>> @exported_as_webservice_collection(IDummyInterface) |
413 | + >>> @exported_as_webservice_collection(ISampleInterface) |
414 | ... class TwoDefaultContent(Interface): |
415 | ... @collection_default_content() |
416 | ... def getAll1(): |
417 | @@ -268,7 +268,7 @@ As it is an error, to mark more than one method: |
418 | |
419 | exported_as_webservice_collection() can only be used on Interface. |
420 | |
421 | - >>> @exported_as_webservice_collection(IDummyInterface) |
422 | + >>> @exported_as_webservice_collection(ISampleInterface) |
423 | ... class NotAnInterface(object): |
424 | ... pass |
425 | Traceback (most recent call last): |
426 | @@ -834,7 +834,7 @@ Setup |
427 | Before we can continue, we must define a web service configuration |
428 | object. Each web service needs to have one of these registered |
429 | utilities providing basic information about the web service. This one |
430 | -is just a dummy. |
431 | +is just a sample. |
432 | |
433 | >>> from zope.component import provideUtility |
434 | >>> from zope.security.interfaces import Unauthorized |
435 | diff --git a/src/lazr/restful/docs/webservice-marshallers.rst b/src/lazr/restful/docs/webservice-marshallers.rst |
436 | index 71ea4e2..20028f3 100644 |
437 | --- a/src/lazr/restful/docs/webservice-marshallers.rst |
438 | +++ b/src/lazr/restful/docs/webservice-marshallers.rst |
439 | @@ -5,7 +5,7 @@ LAZR defines an interface for converting between the values that |
440 | come in on an HTTP request, and the object values appropriate for schema |
441 | fields. This is similar to Zope's widget interface, but much smaller. |
442 | |
443 | -To test the various marshallers we create a dummy request and |
444 | +To test the various marshallers we create a stub request and |
445 | application root. |
446 | |
447 | >>> from lazr.restful.testing.webservice import WebServiceTestPublication |
448 | diff --git a/src/lazr/restful/docs/webservice.rst b/src/lazr/restful/docs/webservice.rst |
449 | index ba97e44..6397038 100644 |
450 | --- a/src/lazr/restful/docs/webservice.rst |
451 | +++ b/src/lazr/restful/docs/webservice.rst |
452 | @@ -1502,7 +1502,7 @@ structure, and the response's Content-Type header is set to |
453 | application/json. These examples show how different return values are |
454 | serialized. |
455 | |
456 | - >>> class DummyOperation(ResourceGETOperation): |
457 | + >>> class SampleOperation(ResourceGETOperation): |
458 | ... |
459 | ... params = () |
460 | ... result = None |
461 | @@ -1511,17 +1511,17 @@ serialized. |
462 | ... def call(self): |
463 | ... return self.result |
464 | |
465 | - >>> def make_dummy_operation_request(result): |
466 | + >>> def make_sample_operation_request(result): |
467 | ... request = create_web_service_request('/beta/') |
468 | ... ignore = request.traverse(app) |
469 | - ... operation = DummyOperation(None, request) |
470 | + ... operation = SampleOperation(None, request) |
471 | ... operation.result = result |
472 | ... return request, operation |
473 | |
474 | Scalar Python values like strings and booleans are serialized as you'd |
475 | expect. |
476 | |
477 | - >>> request, operation = make_dummy_operation_request("A string.") |
478 | + >>> request, operation = make_sample_operation_request("A string.") |
479 | >>> print(operation()) |
480 | "A string." |
481 | >>> request.response.getStatus() |
482 | @@ -1529,26 +1529,26 @@ expect. |
483 | >>> print(request.response.getHeader('Content-Type')) |
484 | application/json |
485 | |
486 | - >>> request, operation = make_dummy_operation_request(True) |
487 | + >>> request, operation = make_sample_operation_request(True) |
488 | >>> operation() |
489 | 'true' |
490 | |
491 | - >>> request, operation = make_dummy_operation_request(10) |
492 | + >>> request, operation = make_sample_operation_request(10) |
493 | >>> operation() |
494 | '10' |
495 | |
496 | - >>> request, operation = make_dummy_operation_request(None) |
497 | + >>> request, operation = make_sample_operation_request(None) |
498 | >>> operation() |
499 | 'null' |
500 | |
501 | - >>> request, operation = make_dummy_operation_request(1.3) |
502 | + >>> request, operation = make_sample_operation_request(1.3) |
503 | >>> operation() |
504 | '1.3' |
505 | |
506 | When a named operation returns an object that has an ``IEntry`` |
507 | implementation, the object is serialized to a JSON hash. |
508 | |
509 | - >>> request, operation = make_dummy_operation_request(D2) |
510 | + >>> request, operation = make_sample_operation_request(D2) |
511 | >>> operation() |
512 | '{...}' |
513 | |
514 | @@ -1557,18 +1557,18 @@ objects with ``IEntry`` implementations. Here's a dictionary that contains |
515 | a ``Dish`` object. The ``Dish`` object is serialized as a JSON dictionary |
516 | within the larger dictionary. |
517 | |
518 | - >>> request, operation = make_dummy_operation_request({'dish': D2}) |
519 | + >>> request, operation = make_sample_operation_request({'dish': D2}) |
520 | >>> operation() |
521 | '{"dish": {...}}' |
522 | |
523 | When a named operation returns a list or tuple of objects, we serve |
524 | the whole thing as a JSON list. |
525 | |
526 | - >>> request, operation = make_dummy_operation_request([1,2,3]) |
527 | + >>> request, operation = make_sample_operation_request([1,2,3]) |
528 | >>> operation() |
529 | '[1, 2, 3]' |
530 | |
531 | - >>> request, operation = make_dummy_operation_request((C1_D1, C2_D1)) |
532 | + >>> request, operation = make_sample_operation_request((C1_D1, C2_D1)) |
533 | >>> operation() |
534 | '[{...}, {...}]' |
535 | |
536 | @@ -1579,7 +1579,7 @@ results. In this case we do the same thing we do when serving a |
537 | collection resource. We fetch one batch of results and represent it as |
538 | a JSON hash containing a list of entries. |
539 | |
540 | - >>> class DummyResultSet(object): |
541 | + >>> class StubResultSet(object): |
542 | ... results = [C1_D1, C2_D1] |
543 | ... |
544 | ... def __iter__(self): |
545 | @@ -1591,8 +1591,8 @@ a JSON hash containing a list of entries. |
546 | ... def __getitem__(self, index): |
547 | ... return self.results[index] |
548 | |
549 | - >>> recipes = DummyResultSet() |
550 | - >>> request, operation = make_dummy_operation_request(recipes) |
551 | + >>> recipes = StubResultSet() |
552 | + >>> request, operation = make_sample_operation_request(recipes) |
553 | >>> response = operation() |
554 | >>> pprint_collection(simplejson.loads(response)) |
555 | start: ... |
556 | @@ -1607,7 +1607,7 @@ When a named operation returns an object that has an ``ICollection`` |
557 | implementation, the result is similar: we return a JSON hash describing one |
558 | batch from the collection. |
559 | |
560 | - >>> request, operation = make_dummy_operation_request(DishSet()) |
561 | + >>> request, operation = make_sample_operation_request(DishSet()) |
562 | >>> response = operation() |
563 | >>> pprint_collection(simplejson.loads(response)) |
564 | resource_type_link: 'http://api.cookbooks.dev/beta/#dishes' |
565 | @@ -1624,20 +1624,20 @@ batch from the collection. |
566 | If the return value can't be converted into JSON, you'll get an |
567 | exception. |
568 | |
569 | - >>> request, operation = make_dummy_operation_request(object()) |
570 | + >>> request, operation = make_sample_operation_request(object()) |
571 | >>> operation() |
572 | Traceback (most recent call last): |
573 | ... |
574 | TypeError: Could not serialize object <object...> to JSON. |
575 | |
576 | - >>> request, operation = make_dummy_operation_request( |
577 | + >>> request, operation = make_sample_operation_request( |
578 | ... {'anobject' : object()}) |
579 | >>> operation() |
580 | Traceback (most recent call last): |
581 | ... |
582 | TypeError: Could not serialize object {'anobject': <object...>} to JSON. |
583 | |
584 | - >>> request, operation = make_dummy_operation_request([object()]) |
585 | + >>> request, operation = make_sample_operation_request([object()]) |
586 | >>> operation() |
587 | Traceback (most recent call last): |
588 | ... |
589 | diff --git a/src/lazr/restful/example/base/configure.zcml b/src/lazr/restful/example/base/configure.zcml |
590 | index bb5b7a4..4891ee2 100644 |
591 | --- a/src/lazr/restful/example/base/configure.zcml |
592 | +++ b/src/lazr/restful/example/base/configure.zcml |
593 | @@ -8,7 +8,7 @@ |
594 | <grok:grok package="lazr.restful.example.base" /> |
595 | |
596 | <subscriber for="zope.processlifetime.IProcessStarting" |
597 | - handler="lazr.restful.metazcml.webservice_sanity_checks" /> |
598 | + handler="lazr.restful.metazcml.webservice_coherence_checks" /> |
599 | |
600 | <!--Registering these two adapters will cause web_link to show up in |
601 | representations.--> |
602 | @@ -23,7 +23,7 @@ |
603 | for="zope.location.interfaces.ILocation |
604 | lazr.restful.interfaces.IWebBrowserOriginatingRequest" |
605 | provides="zope.traversing.browser.interfaces.IAbsoluteURL" |
606 | - factory="lazr.restful.testing.webservice.DummyAbsoluteURL" /> |
607 | + factory="lazr.restful.testing.webservice.StubAbsoluteURL" /> |
608 | |
609 | |
610 | <!--Security configuration--> |
611 | diff --git a/src/lazr/restful/example/base/tests/collection.txt b/src/lazr/restful/example/base/tests/collection.txt |
612 | index 2c5c335..08009ad 100644 |
613 | --- a/src/lazr/restful/example/base/tests/collection.txt |
614 | +++ b/src/lazr/restful/example/base/tests/collection.txt |
615 | @@ -137,7 +137,7 @@ The elements of a collection can be looked up by unique identifier: |
616 | resource_type_link: 'http://...#cookbook' |
617 | revision_number: 0 |
618 | self_link: 'http://.../cookbooks/The%20Joy%20of%20Cooking' |
619 | - web_link: 'http://dummyurl/' |
620 | + web_link: 'http://exampleurl/' |
621 | |
622 | A collection may be scoped to an element: |
623 | |
624 | diff --git a/src/lazr/restful/example/base/tests/entry.txt b/src/lazr/restful/example/base/tests/entry.txt |
625 | index 5b72ba6..ba48787 100644 |
626 | --- a/src/lazr/restful/example/base/tests/entry.txt |
627 | +++ b/src/lazr/restful/example/base/tests/entry.txt |
628 | @@ -135,7 +135,7 @@ have non-ascii values. |
629 | But it's possible to define a custom HTML view for a particular object |
630 | type. Here's a simple view that serves some hard-coded HTML. |
631 | |
632 | - >>> class DummyView: |
633 | + >>> class StubView: |
634 | ... |
635 | ... def __init__(*args): |
636 | ... pass |
637 | @@ -153,12 +153,12 @@ ICookbook entry... |
638 | >>> from zope.component import getGlobalSiteManager |
639 | >>> manager = getGlobalSiteManager() |
640 | >>> manager.registerAdapter( |
641 | - ... factory=DummyView, |
642 | + ... factory=StubView, |
643 | ... required=[ICookbook, IWebServiceClientRequest], |
644 | ... provided=IInterface, name=view_name) |
645 | |
646 | ...and the XHTML representation of an ICookbook will be the result of |
647 | -calling a DummyView object. |
648 | +calling a StubView object. |
649 | |
650 | >>> print(webservice.get(greens_url, 'application/xhtml+xml')) |
651 | HTTP/1.1 200 Ok |
652 | @@ -170,7 +170,7 @@ we just defined. |
653 | |
654 | >>> from zope.component import getGlobalSiteManager |
655 | >>> ignored = getGlobalSiteManager().unregisterAdapter( |
656 | - ... factory=DummyView, |
657 | + ... factory=StubView, |
658 | ... required=[ICookbook, IWebServiceClientRequest], |
659 | ... provided=IInterface, name=view_name) |
660 | |
661 | @@ -572,7 +572,7 @@ designed for Ajax. |
662 | |
663 | >>> from lazr.restful.testing.webservice import WebServiceAjaxCaller |
664 | >>> ajax = WebServiceAjaxCaller(domain='cookbooks.dev') |
665 | - >>> etag = 'dummy-etag' |
666 | + >>> etag = 'sample-etag' |
667 | >>> response = ajax.get(greens_url, headers={'If-None-Match' : etag}) |
668 | >>> etag = response.getheader("Etag") |
669 | >>> print(ajax.get(greens_url, headers={'If-None-Match' : etag})) |
670 | @@ -863,7 +863,7 @@ about an attempt to modify a read-only attribute. |
671 | The two 400 error codes below are caused by a failure to understand |
672 | the assertion. The string used in the assertion might not be a date. |
673 | |
674 | - >>> print(patch_greens_copyright_date('dummy')) |
675 | + >>> print(patch_greens_copyright_date('sample')) |
676 | HTTP/1.1 400 Bad Request |
677 | ... |
678 | copyright_date: Value doesn't look like a date. |
679 | @@ -959,7 +959,7 @@ attribute, but it has to be the same as the current value. |
680 | You can't change the link to an entry's associated collection. |
681 | |
682 | >>> print(modify_cookbook('Everyday Greens', |
683 | - ... {'recipes_collection_link' : 'dummy'}, |
684 | + ... {'recipes_collection_link' : 'placeholder'}, |
685 | ... 'PATCH')) |
686 | HTTP/1.1 400 Bad Request |
687 | ... |
688 | @@ -978,7 +978,7 @@ collection link; you just can't _change_ the value. |
689 | You can't directly change an entry's URL address. |
690 | |
691 | >>> print(modify_cookbook('Everyday Greens', |
692 | - ... {'self_link' : 'dummy'}, 'PATCH')) |
693 | + ... {'self_link' : 'placeholder'}, 'PATCH')) |
694 | HTTP/1.1 400 Bad Request |
695 | ... |
696 | self_link: You tried to modify a read-only attribute. |
697 | @@ -986,7 +986,7 @@ You can't directly change an entry's URL address. |
698 | You can't directly change an entry's ETag. |
699 | |
700 | >>> print(modify_cookbook('Everyday Greens', |
701 | - ... {'http_etag' : 'dummy'}, 'PATCH')) |
702 | + ... {'http_etag' : 'placeholder'}, 'PATCH')) |
703 | HTTP/1.1 400 Bad Request |
704 | ... |
705 | http_etag: You tried to modify a read-only attribute. |
706 | @@ -994,7 +994,7 @@ You can't directly change an entry's ETag. |
707 | You can't change an entry's resource type. |
708 | |
709 | >>> print(modify_cookbook('Everyday Greens', |
710 | - ... {'resource_type_link' : 'dummy'}, 'PATCH')) |
711 | + ... {'resource_type_link' : 'placeholder'}, 'PATCH')) |
712 | HTTP/1.1 400 Bad Request |
713 | ... |
714 | resource_type_link: You tried to modify a read-only attribute. |
715 | @@ -1004,7 +1004,7 @@ though it were the actual object. A cookbook has a |
716 | 'recipes_collection_link', but it doesn't have 'recipes' directly. |
717 | |
718 | >>> print(modify_cookbook( |
719 | - ... 'Everyday Greens', {'recipes' : 'dummy'}, 'PATCH')) |
720 | + ... 'Everyday Greens', {'recipes' : 'placeholder'}, 'PATCH')) |
721 | HTTP/1.1 400 Bad Request |
722 | ... |
723 | recipes: You tried to modify a nonexistent attribute. |
724 | @@ -1013,7 +1013,7 @@ A recipe has a 'dish_link', but it doesn't have a 'dish' directly. |
725 | |
726 | >>> url = quote('/cookbooks/The Joy of Cooking/Roast chicken') |
727 | >>> print(webservice.patch(url, 'application/json', |
728 | - ... simplejson.dumps({'dish' : 'dummy'}))) |
729 | + ... simplejson.dumps({'dish' : 'placeholder'}))) |
730 | HTTP/1.1 400 Bad Request |
731 | ... |
732 | dish: You tried to modify a nonexistent attribute. |
733 | @@ -1030,7 +1030,7 @@ you can't set a required value to None. |
734 | And of course you can't modify attributes that don't exist. |
735 | |
736 | >>> print(modify_cookbook( |
737 | - ... 'Everyday Greens', {'nonesuch' : 'dummy'}, 'PATCH')) |
738 | + ... 'Everyday Greens', {'nonesuch' : 'placeholder'}, 'PATCH')) |
739 | HTTP/1.1 400 Bad Request |
740 | ... |
741 | nonesuch: You tried to modify a nonexistent attribute. |
742 | diff --git a/src/lazr/restful/example/base/tests/field.txt b/src/lazr/restful/example/base/tests/field.txt |
743 | index 267b255..aa09231 100644 |
744 | --- a/src/lazr/restful/example/base/tests/field.txt |
745 | +++ b/src/lazr/restful/example/base/tests/field.txt |
746 | @@ -284,7 +284,7 @@ value it's given. |
747 | >>> from lazr.restful.testing.webservice import simple_renderer |
748 | >>> @component.adapter(ICookbook, ITextLine, IWebServiceClientRequest) |
749 | ... @implementer(IFieldHTMLRenderer) |
750 | - ... def dummy_renderer(context, field, request): |
751 | + ... def fake_renderer(context, field, request): |
752 | ... """Bold the original string and add a snowman.""" |
753 | ... return simple_renderer |
754 | |
755 | @@ -298,10 +298,10 @@ ITextLine field of an IPerson entry... |
756 | |
757 | >>> from zope.component import getGlobalSiteManager |
758 | >>> manager = getGlobalSiteManager() |
759 | - >>> manager.registerAdapter(dummy_renderer) |
760 | + >>> manager.registerAdapter(fake_renderer) |
761 | |
762 | ...and the XHTML representation of an ICookbook's description will be the |
763 | -result of calling a dummy_renderer object. |
764 | +result of calling a fake_renderer object. |
765 | |
766 | >>> from lazr.restful.testing.helpers import encode_response |
767 | >>> response = webservice.get(field_url, 'application/xhtml+xml') |
768 | @@ -377,7 +377,7 @@ Cleanup |
769 | Before we continue, here's some cleanup code to remove the custom |
770 | renderer we just defined. |
771 | |
772 | - >>> ignored = getGlobalSiteManager().unregisterAdapter(dummy_renderer) |
773 | + >>> ignored = getGlobalSiteManager().unregisterAdapter(fake_renderer) |
774 | |
775 | Compare the HTML generated by the custom renderer, to the XHTML |
776 | generated now that the default adapter is back in place. |
777 | @@ -407,12 +407,12 @@ a view on ICookbook called "description". |
778 | |
779 | >>> @component.adapter(ICookbook, ITextLine, IWebServiceClientRequest) |
780 | ... @implementer(IFieldHTMLRenderer) |
781 | - ... def dummy_renderer(context, field, request): |
782 | + ... def fake_renderer(context, field, request): |
783 | ... """Bold the original string, add a snowman, and encode UTF-8.""" |
784 | ... def render(value): |
785 | ... return (u"\N{SNOWMAN} <b>%s</b>" % value).encode("utf-8") |
786 | ... return render |
787 | - >>> manager.registerAdapter(dummy_renderer, name='description') |
788 | + >>> manager.registerAdapter(fake_renderer, name='description') |
789 | |
790 | This renderer is identical to the one shown earlier, except that it |
791 | returns UTF-8 instead of Unicode. |
792 | @@ -446,7 +446,7 @@ representations of that entry's fields. |
793 | Before we continue, here's some code to unregister the view. |
794 | |
795 | >>> ignored = getGlobalSiteManager().unregisterAdapter( |
796 | - ... dummy_renderer, name='description') |
797 | + ... fake_renderer, name='description') |
798 | |
799 | >>> print(webservice.get(field_url, 'application/xhtml+xml')) |
800 | HTTP/1.1 200 Ok |
801 | diff --git a/src/lazr/restful/example/base/tests/representation-cache.txt b/src/lazr/restful/example/base/tests/representation-cache.txt |
802 | index 89d35f6..7870eac 100644 |
803 | --- a/src/lazr/restful/example/base/tests/representation-cache.txt |
804 | +++ b/src/lazr/restful/example/base/tests/representation-cache.txt |
805 | @@ -207,7 +207,7 @@ POST did. |
806 | >>> from lazr.restful.example.base.root import COOKBOOKS |
807 | >>> cookbook = [cookbook for cookbook in COOKBOOKS |
808 | ... if cookbook.name == "Everyday Greens"][0] |
809 | - >>> cache.set(cookbook, json, 'devel', "Dummy value.") |
810 | + >>> cache.set(cookbook, json, 'devel', "Sample value.") |
811 | >>> print(list(dictionary.keys())[0]) |
812 | http://.../devel/cookbooks/Everyday%20Greens,application/json |
813 | |
814 | diff --git a/src/lazr/restful/metazcml.py b/src/lazr/restful/metazcml.py |
815 | index 95d5e4c..a61ab91 100644 |
816 | --- a/src/lazr/restful/metazcml.py |
817 | +++ b/src/lazr/restful/metazcml.py |
818 | @@ -53,7 +53,7 @@ from lazr.restful.utils import VersionedObject |
819 | |
820 | |
821 | # Keep track of entry and operation registrations so we can |
822 | -# sanity-check them later. |
823 | +# coherence-check them later. |
824 | REGISTERED_ENTRIES = [] |
825 | REGISTERED_OPERATIONS = [] |
826 | |
827 | @@ -332,7 +332,7 @@ def register_webservice(context, module): |
828 | |
829 | |
830 | @adapter(IProcessStarting) |
831 | -def webservice_sanity_checks(registration): |
832 | +def webservice_coherence_checks(registration): |
833 | """Ensure the web service contains no references to unpublished objects. |
834 | |
835 | We are worried about fields that link to unpublished objects, and |
836 | @@ -408,7 +408,7 @@ def webservice_sanity_checks(registration): |
837 | def _extract_reference_type(field): |
838 | """Determine what kind of object the given field is a reference to. |
839 | |
840 | - This is a helper method used by the sanity checker. |
841 | + This is a helper method used by the coherence checker. |
842 | |
843 | :return: A 2-tuple (reference_type, human_readable): If |
844 | `field` is a reference to a scalar entry, human_readable is |
845 | @@ -429,7 +429,7 @@ def _extract_reference_type(field): |
846 | |
847 | def _assert_interface_registered_for_version( |
848 | version, interface, available_registrations, error_message_insert): |
849 | - """A helper method for the sanity checker. |
850 | + """A helper method for the coherence checker. |
851 | |
852 | See if the given entry interface is published in the given version |
853 | (as determined by the contents of `available_registrations`), and |
854 | diff --git a/src/lazr/restful/testing/helpers.py b/src/lazr/restful/testing/helpers.py |
855 | index 546693a..e8656f6 100644 |
856 | --- a/src/lazr/restful/testing/helpers.py |
857 | +++ b/src/lazr/restful/testing/helpers.py |
858 | @@ -8,7 +8,7 @@ from zope.configuration import xmlconfig |
859 | from zope.interface import implementer |
860 | |
861 | from lazr.restful.interfaces import IWebServiceConfiguration |
862 | -from lazr.restful.metazcml import webservice_sanity_checks |
863 | +from lazr.restful.metazcml import webservice_coherence_checks |
864 | from lazr.restful.simple import ( |
865 | Request, |
866 | RootResource, |
867 | @@ -36,7 +36,7 @@ def register_test_module(name, *contents): |
868 | <webservice:register module="lazr.restful.%s" /> |
869 | </configure> |
870 | """ % name) |
871 | - webservice_sanity_checks(None) |
872 | + webservice_coherence_checks(None) |
873 | except Exception as e: |
874 | del sys.modules['lazr.restful.' + name] |
875 | raise e |
876 | diff --git a/src/lazr/restful/testing/webservice.py b/src/lazr/restful/testing/webservice.py |
877 | index be79781..c834bfb 100644 |
878 | --- a/src/lazr/restful/testing/webservice.py |
879 | +++ b/src/lazr/restful/testing/webservice.py |
880 | @@ -7,8 +7,8 @@ from __future__ import absolute_import, print_function |
881 | __metaclass__ = type |
882 | __all__ = [ |
883 | 'create_web_service_request', |
884 | - 'DummyAbsoluteURL', |
885 | - 'DummyRootResourceURL', |
886 | + 'StubAbsoluteURL', |
887 | + 'StubRootResourceURL', |
888 | 'FakeRequest', |
889 | 'FakeResponse', |
890 | 'IGenericEntry', |
891 | @@ -733,7 +733,7 @@ class IGenericCollection(Interface): |
892 | |
893 | |
894 | @implementer(IServiceRootResource) |
895 | -class DummyRootResource: |
896 | +class StubRootResource: |
897 | """A root resource that does nothing.""" |
898 | |
899 | def getTopLevelPublications(self, request): |
900 | @@ -741,9 +741,9 @@ class DummyRootResource: |
901 | |
902 | |
903 | @implementer(IAbsoluteURL) |
904 | -class DummyAbsoluteURL: |
905 | +class StubAbsoluteURL: |
906 | """Implements IAbsoluteURL for when you don't care what the URL is.""" |
907 | - URL = 'http://dummyurl/' |
908 | + URL = 'http://exampleurl/' |
909 | |
910 | def __init__(self, *args): |
911 | pass |
912 | @@ -754,11 +754,11 @@ class DummyAbsoluteURL: |
913 | __call__ = __str__ |
914 | |
915 | |
916 | -@adapter(DummyRootResource, IWebServiceClientRequest) |
917 | -class DummyRootResourceURL(DummyAbsoluteURL): |
918 | - """A dummy IAbsoluteURL implementation for a DummyRootResource.""" |
919 | +@adapter(StubRootResource, IWebServiceClientRequest) |
920 | +class StubRootResourceURL(StubAbsoluteURL): |
921 | + """A stub IAbsoluteURL implementation for a StubRootResource.""" |
922 | |
923 | - URL = 'http://dummyurl' |
924 | + URL = 'http://exampleurl' |
925 | |
926 | |
927 | def simple_renderer(value): |
928 | diff --git a/src/lazr/restful/tests/test_declarations.py b/src/lazr/restful/tests/test_declarations.py |
929 | index 12d380c..37547d1 100644 |
930 | --- a/src/lazr/restful/tests/test_declarations.py |
931 | +++ b/src/lazr/restful/tests/test_declarations.py |
932 | @@ -90,7 +90,7 @@ class ContributingInterfacesTestCase(TestCaseWithWebServiceFixtures): |
933 | sm.registerAdapter(ProductToHasBugsAdapter) |
934 | sm.registerAdapter(ProjectToHasBugsAdapter) |
935 | sm.registerAdapter(ProductToHasBranchesAdapter) |
936 | - sm.registerAdapter(DummyFieldMarshaller) |
937 | + sm.registerAdapter(StubFieldMarshaller) |
938 | self.one_zero_request = self.fake_request('1.0') |
939 | self.two_zero_request = self.fake_request('2.0') |
940 | self.product = Product() |
941 | @@ -304,13 +304,13 @@ class ContributingInterfacesTestCase(TestCaseWithWebServiceFixtures): |
942 | # Contributing interfaces are not exported by themselves -- they only |
943 | # contribute their exported fields/operations to other entries. |
944 | @implementer(IHasBranches) |
945 | - class DummyHasBranches: |
946 | + class StubHasBranches: |
947 | pass |
948 | - dummy = DummyHasBranches() |
949 | + stub = StubHasBranches() |
950 | register_test_module('testmod', IBranch, IProduct, IHasBranches) |
951 | self.assertRaises( |
952 | ComponentLookupError, |
953 | - getMultiAdapter, (dummy, self.one_zero_request), IEntry) |
954 | + getMultiAdapter, (stub, self.one_zero_request), IEntry) |
955 | |
956 | def test_cannot_contribute_to_non_exported_interface(self): |
957 | # A contributing interface can only contribute to exported interfaces. |
958 | @@ -760,7 +760,7 @@ class ProductToHasBranchesAdapter(object): |
959 | # marshaller so that the adapter lookup doesn't fail and cause an error on the |
960 | # test. |
961 | @adapter(Interface, IHTTPRequest) |
962 | -class DummyFieldMarshaller(SimpleFieldMarshaller): |
963 | +class StubFieldMarshaller(SimpleFieldMarshaller): |
964 | pass |
965 | |
966 | |
967 | @@ -1110,7 +1110,7 @@ class TestRequireExplicitVersions(TestCaseWithWebServiceFixtures): |
968 | 'GET_IFieldExplicitOperationDefinition_explicitly_in_10_1_0') |
969 | |
970 | |
971 | -# Classes for TestSanityChecking |
972 | +# Classes for TestCoherenceChecking |
973 | |
974 | class INotPublished(Interface): |
975 | pass |
976 | @@ -1192,23 +1192,25 @@ class IReferencesPublishedAndThenRemoved(Interface): |
977 | field = exported(Reference(schema=IPublishedAndThenRemoved)) |
978 | |
979 | |
980 | -class TestSanityChecking(TestCaseWithWebServiceFixtures): |
981 | - """Test lazr.restful's sanity checking upon web service registration.""" |
982 | +class TestCoherenceChecking(TestCaseWithWebServiceFixtures): |
983 | + """ |
984 | + Test lazr.restful's coherence checking upon web service registration. |
985 | + """ |
986 | |
987 | - def _test_fails_sanity_check( |
988 | + def _test_fails_coherence_check( |
989 | self, expect_failure_in_version, expect_failure_for_reason, |
990 | expect_failure_due_to_interface, *classes): |
991 | """Verify that the given interfaces can't become a web service. |
992 | |
993 | - The given set of interfaces are expected to fail the sanity |
994 | + The given set of interfaces are expected to fail the coherence |
995 | check because they include an annotation that makes some |
996 | version of the web service reference an entry not defined in |
997 | that version (or at all). |
998 | |
999 | :param expect_failure_in_version: Which version of the web |
1000 | - service will fail the sanity check. |
1001 | + service will fail the coherence check. |
1002 | :param expect_failure_for_reason: The reason that will be given |
1003 | - for failing the sanity check. |
1004 | + for failing the coherence check. |
1005 | :param expect_failure_due_to_interface: The interface that will |
1006 | cause the failure due to not being published in |
1007 | `expect_failure_in_version`. |
1008 | @@ -1229,13 +1231,13 @@ class TestSanityChecking(TestCaseWithWebServiceFixtures): |
1009 | self.assertEqual(str(exception), expected_message) |
1010 | |
1011 | def test_reference_to_unpublished_object_fails(self): |
1012 | - self._test_fails_sanity_check( |
1013 | + self._test_fails_coherence_check( |
1014 | '1.0', |
1015 | ("IReferencesNotPublishedEntry_1_0.field is INotPublished"), |
1016 | INotPublished, IReferencesNotPublished) |
1017 | |
1018 | def test_reference_to_object_published_later_fails(self): |
1019 | - self._test_fails_sanity_check( |
1020 | + self._test_fails_coherence_check( |
1021 | '1.0', |
1022 | ("IReferencesPublishedTooLateEntry_1_0.field is " |
1023 | "IPublishedTooLate"), |
1024 | @@ -1245,8 +1247,8 @@ class TestSanityChecking(TestCaseWithWebServiceFixtures): |
1025 | # This setup is acceptable in version 1.0, but in version 2.0 |
1026 | # IPublishedAndThenRemoved is gone. This puts |
1027 | # IReferencesPublishedAndThenRemoved in violation of the |
1028 | - # sanity check in 2.0, even though it hasn't changed since 1.0. |
1029 | - self._test_fails_sanity_check( |
1030 | + # coherence check in 2.0, even though it hasn't changed since 1.0. |
1031 | + self._test_fails_coherence_check( |
1032 | '2.0', |
1033 | ("IReferencesPublishedAndThenRemovedEntry_2_0.field is " |
1034 | "IPublishedAndThenRemoved"), |
1035 | @@ -1272,7 +1274,7 @@ class TestSanityChecking(TestCaseWithWebServiceFixtures): |
1036 | def test_reference_to_collection_of_unpublished_objects_fails(self): |
1037 | # An entry may define a field that's a scoped collection of |
1038 | # unpublished entries. |
1039 | - self._test_fails_sanity_check( |
1040 | + self._test_fails_coherence_check( |
1041 | '1.0', |
1042 | ("IReferencesCollectionOfNotPublishedEntry_1_0.field is a " |
1043 | "collection of INotPublished"), |
1044 | @@ -1280,14 +1282,14 @@ class TestSanityChecking(TestCaseWithWebServiceFixtures): |
1045 | |
1046 | def test_operation_returning_unpublished_object_fails(self): |
1047 | # An operation may return an unpublished entry. |
1048 | - self._test_fails_sanity_check( |
1049 | + self._test_fails_coherence_check( |
1050 | '1.0', |
1051 | ("named operation get_impossible_object returns INotPublished"), |
1052 | INotPublished, IOperationReturnsNotPublished) |
1053 | |
1054 | def test_operation_returning_collection_of_unpublished_object_fails(self): |
1055 | # An operation may return a collection of unpublished entries. |
1056 | - self._test_fails_sanity_check( |
1057 | + self._test_fails_coherence_check( |
1058 | '1.0', |
1059 | ("named operation get_impossible_objects returns a collection " |
1060 | "of INotPublished"), |
1061 | @@ -1295,7 +1297,7 @@ class TestSanityChecking(TestCaseWithWebServiceFixtures): |
1062 | |
1063 | def test_operation_taking_unpublished_argument_fails(self): |
1064 | # An operation may take an unpublished entry as an argument. |
1065 | - self._test_fails_sanity_check( |
1066 | + self._test_fails_coherence_check( |
1067 | '1.0', |
1068 | ("named operation use_impossible_object accepts INotPublished"), |
1069 | INotPublished, IOperationAcceptsNotPublished) |
1070 | @@ -1303,7 +1305,7 @@ class TestSanityChecking(TestCaseWithWebServiceFixtures): |
1071 | def test_operation_taking_unpublished_collection_argument_fails(self): |
1072 | # An operation may take a collection of unpublished entries as |
1073 | # an argument. |
1074 | - self._test_fails_sanity_check( |
1075 | + self._test_fails_coherence_check( |
1076 | '1.0', |
1077 | ("named operation use_impossible_objects accepts a collection " |
1078 | "of INotPublished"), |
1079 | diff --git a/src/lazr/restful/tests/test_webservice.py b/src/lazr/restful/tests/test_webservice.py |
1080 | index 9321eb7..86eb3db 100644 |
1081 | --- a/src/lazr/restful/tests/test_webservice.py |
1082 | +++ b/src/lazr/restful/tests/test_webservice.py |
1083 | @@ -69,7 +69,7 @@ from lazr.restful.declarations import ( |
1084 | ) |
1085 | from lazr.restful.testing.webservice import ( |
1086 | create_web_service_request, |
1087 | - DummyAbsoluteURL, |
1088 | + StubAbsoluteURL, |
1089 | IGenericCollection, |
1090 | IGenericEntry, |
1091 | simple_renderer, |
1092 | @@ -150,11 +150,11 @@ class EntryTestCase(WebServiceTestCase): |
1093 | default_media_type = "application/json" |
1094 | |
1095 | @implementer(IWebBrowserOriginatingRequest) |
1096 | - class DummyWebsiteRequest: |
1097 | + class StubWebsiteRequest: |
1098 | """A request to the website, as opposed to the web service.""" |
1099 | |
1100 | - class DummyWebsiteURL(DummyAbsoluteURL): |
1101 | - """A web-centric implementation of the dummy URL.""" |
1102 | + class StubWebsiteURL(StubAbsoluteURL): |
1103 | + """A web-centric implementation of the stub URL.""" |
1104 | URL = 'http://www.website.url/' |
1105 | |
1106 | @contextmanager |
1107 | @@ -210,7 +210,7 @@ class EntryTestCase(WebServiceTestCase): |
1108 | def _register_url_adapter(self, entry_interface): |
1109 | """Register an IAbsoluteURL implementation for an interface.""" |
1110 | getGlobalSiteManager().registerAdapter( |
1111 | - DummyAbsoluteURL, [entry_interface, IWebServiceClientRequest], |
1112 | + StubAbsoluteURL, [entry_interface, IWebServiceClientRequest], |
1113 | IAbsoluteURL) |
1114 | |
1115 | def _register_website_url_space(self, entry_interface): |
1116 | @@ -221,7 +221,7 @@ class EntryTestCase(WebServiceTestCase): |
1117 | # web page requests. |
1118 | def web_service_request_to_website_request(service_request): |
1119 | """Create a corresponding request to the website.""" |
1120 | - return self.DummyWebsiteRequest() |
1121 | + return self.StubWebsiteRequest() |
1122 | |
1123 | getGlobalSiteManager().registerAdapter( |
1124 | web_service_request_to_website_request, |
1125 | @@ -230,7 +230,7 @@ class EntryTestCase(WebServiceTestCase): |
1126 | # Next, set up a distinctive URL, and register it as the |
1127 | # website URL for the given entry interface. |
1128 | getGlobalSiteManager().registerAdapter( |
1129 | - self.DummyWebsiteURL, |
1130 | + self.StubWebsiteURL, |
1131 | [entry_interface, IWebBrowserOriginatingRequest], |
1132 | IAbsoluteURL) |
1133 | |
1134 | @@ -282,9 +282,9 @@ class TestEntryWebLink(EntryTestCase): |
1135 | # 'web_link'. |
1136 | with self.entry_resource(IHasOneField, HasOneField, "") as resource: |
1137 | representation = resource.toDataForJSON() |
1138 | - self.assertEqual(representation['self_link'], DummyAbsoluteURL.URL) |
1139 | + self.assertEqual(representation['self_link'], StubAbsoluteURL.URL) |
1140 | self.assertEqual( |
1141 | - representation['web_link'], self.DummyWebsiteURL.URL) |
1142 | + representation['web_link'], self.StubWebsiteURL.URL) |
1143 | |
1144 | def test_wadl_includes_web_link_when_available(self): |
1145 | # If an entry includes a web_link, this information will |
1146 | @@ -314,7 +314,7 @@ class TestEntryWebLink(EntryTestCase): |
1147 | with self.entry_resource(IHasOneField, HasOneField, "") as resource: |
1148 | representation = resource.toDataForJSON() |
1149 | self.assertEqual( |
1150 | - representation['self_link'], DummyAbsoluteURL.URL) |
1151 | + representation['self_link'], StubAbsoluteURL.URL) |
1152 | self.assertFalse('web_link' in representation) |
1153 | |
1154 | def test_wadl_omits_web_link_when_not_available(self): |
1155 | @@ -350,7 +350,7 @@ class TestSuppressWebLink(EntryTestCase): |
1156 | resource): |
1157 | representation = resource.toDataForJSON() |
1158 | self.assertEqual( |
1159 | - representation['self_link'], DummyAbsoluteURL.URL) |
1160 | + representation['self_link'], StubAbsoluteURL.URL) |
1161 | self.assertFalse('web_link' in representation) |
1162 | |
1163 | |
1164 | @@ -991,7 +991,7 @@ class NotificationsProviderTest(EntryTestCase): |
1165 | testmodule_objects = [HasOneField, IHasOneField] |
1166 | |
1167 | @implementer(INotificationsProvider) |
1168 | - class DummyWebsiteRequestWithNotifications: |
1169 | + class StubWebsiteRequestWithNotifications: |
1170 | """A request to the website, as opposed to the web service.""" |
1171 | |
1172 | @property |
1173 | @@ -1013,7 +1013,7 @@ class NotificationsProviderTest(EntryTestCase): |
1174 | # web service requests with notifications. |
1175 | def web_service_request_to_notification_request(service_request): |
1176 | """Create a corresponding request to the website.""" |
1177 | - return self.DummyWebsiteRequestWithNotifications() |
1178 | + return self.StubWebsiteRequestWithNotifications() |
1179 | |
1180 | getGlobalSiteManager().registerAdapter( |
1181 | web_service_request_to_notification_request, |
This technically changes a few bits of public API (`lazr. restful. metazcml. webservice_ sanity_ checks` and `lazr.restful. testing. webservice. Dummy*URL` ). In practice I think this is fine and doesn't need a major version bump or anything - lazr.restful only has one known significant user (Launchpad itself) and that doesn't use any of the relevant names - but just in case I'd be inclined to at least make a note of it in NEWS and bump the version to 1.2.0.