Commit 71082818 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent e63d2c94
......@@ -324,26 +324,22 @@ def crack_bucket(zbucket):
def test_restructure():
#T = xbtree.Tree
#B = xbtree.Bucket
#1/0
# do restructure tests under ZODB because without ZODB connection it is not
# always possible to __setstate__ for e.g. .../T/B.
zstor = MappingStorage()
db = DB(zstor)
zconn = db.open()
#zroot = zconn.root()
N = 8 # maxkey
X = [] # X[i] = XBlk corresponding to block #i
X = [] # X[i] -> XBlk corresponding to block #i
for i in range(N):
X.append(XBlk('abcdefgh'[i]))
# prepare ztree with given keys via usual way
# Z prepares XLOTree ztree with given keys via usual way.
# the tree is setup as {} k -> X[k].
def Z(*keys):
ztree = XLOTree() # XXX -> class with node size=2
ztree = XLOTree()
zconn.add(ztree)
for k in keys:
ztree[k] = X[k]
......@@ -354,11 +350,21 @@ def test_restructure():
# R restructures ztree to have specified new topology.
def R(ztree, newtopo):
items = list(ztree.items())
for (k,v) in items:
assert ztree[k] == v
newStructure = xbtree.TopoDecode(newtopo)
xbtree.Restructure(ztree, newStructure)
# XXX verify iteration producess the same [] of (key, v)
# XXX verify [k] gives the same v (for all k)
assert xbtree.StructureOf(ztree) == newStructure
# verify iteration producess the same [] of (key, v)
assert list(ztree.items()) == items
# verify [k] gives the same v (for all k)
for (k,v) in items:
assert ztree[k] == v
# Z0 creates new empty tree
def Z0():
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment