Commit bf275b13 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 6787cb82
...@@ -392,7 +392,7 @@ def crack_bucket(zbucket): ...@@ -392,7 +392,7 @@ def crack_bucket(zbucket):
assert xbtree._zclassify(zbucket).is_zbucket, zbucket assert xbtree._zclassify(zbucket).is_zbucket, zbucket
return zbcheck.crack_bucket(zbucket, is_mapping=True) return zbcheck.crack_bucket(zbucket, is_mapping=True)
# assertT asserts that znode is normal tree node of type typ + has specified keys and children. # assertT asserts that znode is normal tree node + has specified keys and children.
# #
# by default children are checked exactly via "is" # by default children are checked exactly via "is"
# if a child is represented as 'T' or 'B' - it is only verified to be of tree # if a child is represented as 'T' or 'B' - it is only verified to be of tree
...@@ -416,6 +416,22 @@ def assertT(znode, keyv, *children): # -> [] of children marked with 'T'/'B' ...@@ -416,6 +416,22 @@ def assertT(znode, keyv, *children): # -> [] of children marked with 'T'/'B'
assert child is childOK assert child is childOK
return retv return retv
# assertB asserts that znode is bucket node with specified keys and values
def assertB(znode, *kvv):
_ = xbtree._zclassify(znode)
assert _.is_zbucket
keys, values = zbcheck.crack_bucket(znode, _.is_map)
if not _.is_map:
assert values is None
assert keys == kvv
else:
assert len(keys) == len(values)
assert len(keys) == len(kvv)
for (i,(k,v)) in enumerate(zip(keys, values)):
kok, vok = kvv[i]
assert k == kok
assert v is vok
def test_restructure(): def test_restructure():
# do restructure tests under ZODB because without ZODB connection it is not # do restructure tests under ZODB because without ZODB connection it is not
# always possible to __setstate__ for e.g. .../T/B. # always possible to __setstate__ for e.g. .../T/B.
...@@ -429,6 +445,9 @@ def test_restructure(): ...@@ -429,6 +445,9 @@ def test_restructure():
for i in range(N): for i in range(N):
X.append(XBlk('abcdefgh'[i])) X.append(XBlk('abcdefgh'[i]))
def assertB(znode, *keyv):
globals()['assertB'](znode, *[(k,X[k]) for k in keyv])
# Z prepares XLOTree 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]. # the tree is setup as {} k -> X[k].
def Z(*keys): def Z(*keys):
...@@ -773,8 +792,7 @@ def test_zwalkBFS(): ...@@ -773,8 +792,7 @@ def test_zwalkBFS():
# assertB asserts that znode is bucket + has specified keys # assertB asserts that znode is bucket + has specified keys
def assertB(znode, *keyv): def assertB(znode, *keyv):
assert isinstance(znode, IISet) assert isinstance(znode, IISet)
keys, _ = zbcheck.crack_bucket(znode, False) globals()['assertB'](znode, *keyv)
assert keys == keyv
R = xbtree._Range R = xbtree._Range
......
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