Commit 4e16e489 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 0f1e0c44
...@@ -450,7 +450,9 @@ def assertB(znode, *kvv): ...@@ -450,7 +450,9 @@ def assertB(znode, *kvv):
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. We also want to make
# sure Restructure correctly marks modified nodes as changed so that the
# changes are actually persisted to storage on commit.
zstor = MappingStorage() zstor = MappingStorage()
db = DB(zstor) db = DB(zstor)
zconn = db.open() zconn = db.open()
...@@ -502,10 +504,17 @@ def test_restructure(): ...@@ -502,10 +504,17 @@ def test_restructure():
newStructure = newtopo newStructure = newtopo
xbtree.Restructure(ztree, newStructure) xbtree.Restructure(ztree, newStructure)
transaction.commit()
# force objects state to be reloaded from storage.
# this leads further checks to also verify if Restructure modified a
# node, but did not marked it as changed. If this bug is indeed there -
# then the modifications will be lost on live cache clear.
zconn.cacheMinimize()
assert xbtree.StructureOf(ztree, onlyKeys=True) == \ assert xbtree.StructureOf(ztree, onlyKeys=True) == \
newStructure.copy(onlyKeys=True) newStructure.copy(onlyKeys=True)
# verify iteration producess the same [] of (key, v) # verify iteration produces the same [] of (key, v)
assert list(ztree.items()) == items assert list(ztree.items()) == items
# verify [k] gives the same v (for all k) # verify [k] gives the same v (for all k)
for (k,v) in items: for (k,v) in items:
...@@ -726,9 +735,8 @@ def test_restructure(): ...@@ -726,9 +735,8 @@ def test_restructure():
R(z, 'T4/T2-T/T-T-T6,10/B1-B3-T-T-T/T-B7-B11/B5') R(z, 'T4/T2-T/T-T-T6,10/B1-B3-T-T-T/T-B7-B11/B5')
R(z, 'T/B1,3,5,7,11') R(z, 'T/B1,3,5,7,11')
# make sure changed objects are marked as such and so included into commit # make sure changed objects are marked as such and so included into commit
# (just R also partly verifies this on every call)
z = Z(0,2,3) z = Z(0,2,3)
transaction.commit() transaction.commit()
def Rz(newtopo): def Rz(newtopo):
......
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