[Checkins] SVN: zc.zk/trunk/src/zc/zk/ Fixed: The testing ZooKeeper mock didn't properly error when bad
jim
cvs-admin at zope.org
Wed Aug 8 20:47:23 UTC 2012
Log message for revision 127438:
Fixed: The testing ZooKeeper mock didn't properly error when bad
paths were passed to APIs.
Changed:
U zc.zk/trunk/src/zc/zk/README.txt
U zc.zk/trunk/src/zc/zk/testing.py
-=-
Modified: zc.zk/trunk/src/zc/zk/README.txt
===================================================================
--- zc.zk/trunk/src/zc/zk/README.txt 2012-08-07 17:03:55 UTC (rev 127437)
+++ zc.zk/trunk/src/zc/zk/README.txt 2012-08-08 20:47:19 UTC (rev 127438)
@@ -1165,6 +1165,12 @@
Change History
==============
+0.9.2 (2012-08-08)
+------------------
+
+- Fixed: The testing ZooKeeper mock didn't properly error when bad
+ paths were passed to APIs.
+
0.9.1 (2012-07-10)
------------------
Modified: zc.zk/trunk/src/zc/zk/testing.py
===================================================================
--- zc.zk/trunk/src/zc/zk/testing.py 2012-08-07 17:03:55 UTC (rev 127437)
+++ zc.zk/trunk/src/zc/zk/testing.py 2012-08-08 20:47:19 UTC (rev 127438)
@@ -308,6 +308,52 @@
return session
def _traverse(self, path):
+ """This is used by a bunch of the methods.
+
+ We'll test som edge cases here.
+
+ We error on bad paths:
+
+ >>> zk = zc.zk.ZK('zookeeper.example.com:2181')
+
+ >>> zk.exists('')
+ Traceback (most recent call last):
+ ...
+ BadArgumentsException: bad argument
+ >>> zk.exists('xxx')
+ Traceback (most recent call last):
+ ...
+ BadArgumentsException: bad argument
+ >>> zk.exists('..')
+ Traceback (most recent call last):
+ ...
+ BadArgumentsException: bad argument
+ >>> zk.exists('.')
+ Traceback (most recent call last):
+ ...
+ BadArgumentsException: bad argument
+
+ >>> zk.get('')
+ Traceback (most recent call last):
+ ...
+ BadArgumentsException: bad argument
+ >>> zk.get('xxx')
+ Traceback (most recent call last):
+ ...
+ BadArgumentsException: bad argument
+ >>> zk.get('..')
+ Traceback (most recent call last):
+ ...
+ BadArgumentsException: bad argument
+ >>> zk.get('.')
+ Traceback (most recent call last):
+ ...
+ BadArgumentsException: bad argument
+
+
+ """
+ if badpath(path):
+ raise zookeeper.BadArgumentsException('bad argument')
node = self.root
for name in path.split('/')[1:]:
if not name:
@@ -405,7 +451,7 @@
path = base + '/' + name
if base.endswith('/'):
raise zookeeper.BadArgumentsException('bad arguments')
- node = self._traverse(base)
+ node = self._traverse(base or '/')
for p in node.acl:
if not (p['perms'] & zookeeper.PERM_CREATE):
raise zookeeper.NoAuthException('not authenticated')
@@ -434,7 +480,7 @@
if node.children:
raise zookeeper.NotEmptyException('not empty')
base, name = path.rsplit('/', 1)
- bnode = self._traverse(base)
+ bnode = self._traverse(base or '/')
if not clear:
for p in bnode.acl:
if not (p['perms'] & zookeeper.PERM_DELETE):
@@ -491,8 +537,6 @@
>>> zk.close()
"""
- if badpath(path):
- raise zookeeper.BadArgumentsException('bad argument')
with self.lock:
self._check_handle(handle)
try:
More information about the checkins
mailing list