summaryrefslogtreecommitdiff
path: root/wsgitools
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2009-02-27 02:28:31 +0100
committerHelmut Grohne <helmut@subdivi.de>2009-02-27 02:28:31 +0100
commita3f5b782fded63de63641f3e411301eb6ab96dfb (patch)
tree42dfb38746a51d9594dbf02c3dd9b5f753f1cd61 /wsgitools
parentf4813885ceaebbf0c37fbca6764019c15950d6e7 (diff)
downloadwsgitools-a3f5b782fded63de63641f3e411301eb6ab96dfb.tar.gz
added more doctests for digest module
Diffstat (limited to 'wsgitools')
-rwxr-xr-xwsgitools/digest.py31
1 files changed, 30 insertions, 1 deletions
diff --git a/wsgitools/digest.py b/wsgitools/digest.py
index bebb2e2..91ea8cf 100755
--- a/wsgitools/digest.py
+++ b/wsgitools/digest.py
@@ -22,6 +22,11 @@ def parse_digest_response(data, ret=dict()):
{'foo': 'bar'}
>>> sorted(parse_digest_response('foo="bar=qux",spam=egg').items())
[('foo', 'bar=qux'), ('spam', 'egg')]
+ >>> try:
+ ... parse_digest_response('spam')
+ ... except ValueError:
+ ... print "ValueError"
+ ValueError
"""
data = data.strip()
key, rest = data.split('=', 1) # raises ValueError
@@ -129,6 +134,17 @@ class StatelessNonceStore(NonceStoreBase):
nonces.
This nonce store is usable with L{scgi.forkpool}.
+
+ >>> s = StatelessNonceStore()
+ >>> n = s.newnonce()
+ >>> s.checknonce("spam")
+ False
+ >>> s.isnonce(n)
+ True
+ >>> s.checknonce(n)
+ True
+ >>> s.checknonce(n)
+ True
"""
def __init__(self, maxage=300, secret=None):
"""
@@ -206,7 +222,20 @@ class StatelessNonceStore(NonceStoreBase):
__all__.append("MemoryNonceStore")
class MemoryNonceStore(NonceStoreBase):
- """Simple in-memory mechanism to store nonces."""
+ """
+ Simple in-memory mechanism to store nonces.
+
+ >>> s = MemoryNonceStore(maxuses=1)
+ >>> n = s.newnonce()
+ >>> s.checknonce("spam")
+ False
+ >>> s.isnonce(n)
+ True
+ >>> s.checknonce(n)
+ True
+ >>> s.checknonce(n)
+ False
+ """
def __init__(self, maxage=300, maxuses=5):
"""
@type maxage: int