[Checkins] SVN: zc.zk/trunk/src/zc/zk/testing.py On second thought, no.
Jim Fulton
jim at zope.com
Thu Dec 8 18:52:17 UTC 2011
Log message for revision 123637:
On second thought, no.
Changed:
U zc.zk/trunk/src/zc/zk/testing.py
-=-
Modified: zc.zk/trunk/src/zc/zk/testing.py
===================================================================
--- zc.zk/trunk/src/zc/zk/testing.py 2011-12-08 18:50:19 UTC (rev 123636)
+++ zc.zk/trunk/src/zc/zk/testing.py 2011-12-08 18:52:16 UTC (rev 123637)
@@ -72,34 +72,41 @@
The connection string to use for the emulation server. This
defaults to 'zookeeper.example.com:2181'.
"""
- faux_zookeeper = ZooKeeper(
- connection_string, Node(zookeeper = Node('', quota=Node())))
-
+ if tree:
+ zk = ZooKeeper(connection_string, Node())
+ else:
+ zk = ZooKeeper(
+ connection_string,
+ Node(
+ fooservice = Node(
+ json.dumps(dict(
+ database = "/databases/foomain",
+ threads = 1,
+ favorite_color= "red",
+ )),
+ providers = Node()
+ ),
+ zookeeper = Node('', quota=Node()),
+ ),
+ )
teardowns = []
for name in ZooKeeper.__dict__:
if name[0] == '_':
continue
cm = mock.patch('zookeeper.'+name)
m = cm.__enter__()
- m.side_effect = getattr(faux_zookeeper, name)
+ m.side_effect = getattr(zk, name)
teardowns.append(cm.__exit__)
- zk = zc.zk.ZooKeeper(connection_string)
- if not tree:
- tree = """
- /fooservice
- database = '/databases/foomain'
- threads = 1
- favorite_color = 'red'
- /providers
- """
- zk.import_tree(tree)
- zk.close()
+ if tree:
+ zk = zc.zk.ZooKeeper(connection_string)
+ zk.import_tree(tree)
+ zk.close()
globs = getattr(test, 'globs', test.__dict__)
globs['wait_until'] = wait_until
globs['zc.zk.testing'] = teardowns
- globs['ZooKeeper'] = faux_zookeeper
+ globs['ZooKeeper'] = zk
globs.setdefault('assert_', assert_)
def tearDown(test):
More information about the checkins
mailing list