summaryrefslogtreecommitdiff
path: root/src/mailman/rest/docs/helpers.rst
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailman/rest/docs/helpers.rst')
-rw-r--r--src/mailman/rest/docs/helpers.rst17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/mailman/rest/docs/helpers.rst b/src/mailman/rest/docs/helpers.rst
index 5bcf5cad4..5614e6544 100644
--- a/src/mailman/rest/docs/helpers.rst
+++ b/src/mailman/rest/docs/helpers.rst
@@ -45,7 +45,7 @@ gets modified to contain the etag under the ``http_etag`` key.
>>> resource = dict(geddy='bass', alex='guitar', neil='drums')
>>> json_data = etag(resource)
>>> print(resource['http_etag'])
- "96e036d66248cab746b7d97047e08896fcfb2493"
+ "6929ecfbda2282980a4818fb75f82e812077f77a"
For convenience, the etag function also returns the JSON representation of the
dictionary after tagging, since that's almost always what you want.
@@ -58,7 +58,7 @@ dictionary after tagging, since that's almost always what you want.
>>> dump_msgdata(data)
alex : guitar
geddy : bass
- http_etag: "96e036d66248cab746b7d97047e08896fcfb2493"
+ http_etag: "6929ecfbda2282980a4818fb75f82e812077f77a"
neil : drums
@@ -69,8 +69,9 @@ Another helper unpacks ``POST`` and ``PUT`` request variables, validating and
converting their values.
::
+ >>> import six
>>> from mailman.rest.validator import Validator
- >>> validator = Validator(one=int, two=unicode, three=bool)
+ >>> validator = Validator(one=int, two=six.text_type, three=bool)
>>> class FakeRequest:
... params = None
@@ -81,7 +82,7 @@ On valid input, the validator can be used as a ``**keyword`` argument.
>>> def print_request(one, two, three):
... print(repr(one), repr(two), repr(three))
>>> print_request(**validator(FakeRequest))
- 1 u'two' True
+ 1 'two' True
On invalid input, an exception is raised.
@@ -119,7 +120,7 @@ Extra keys are also not allowed.
However, if optional keys are missing, it's okay.
::
- >>> validator = Validator(one=int, two=unicode, three=bool,
+ >>> validator = Validator(one=int, two=six.text_type, three=bool,
... four=int, five=int,
... _optional=('four', 'five'))
@@ -128,15 +129,15 @@ However, if optional keys are missing, it's okay.
>>> def print_request(one, two, three, four=None, five=None):
... print(repr(one), repr(two), repr(three), repr(four), repr(five))
>>> print_request(**validator(FakeRequest))
- 1 u'two' True 4 5
+ 1 'two' True 4 5
>>> del FakeRequest.params['four']
>>> print_request(**validator(FakeRequest))
- 1 u'two' True None 5
+ 1 'two' True None 5
>>> del FakeRequest.params['five']
>>> print_request(**validator(FakeRequest))
- 1 u'two' True None None
+ 1 'two' True None None
But if the optional values are present, they must of course also be valid.