Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
edebb8ad
Commit
edebb8ad
authored
Jun 05, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
8d90dfb2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
17 deletions
+26
-17
wcfs/internal/xbtree_test.py
wcfs/internal/xbtree_test.py
+26
-17
No files found.
wcfs/internal/xbtree_test.py
View file @
edebb8ad
...
...
@@ -18,12 +18,10 @@
# See COPYING file for full licensing terms.
# See https://www.nexedi.com/licensing for rationale and options.
# XXX review
from
__future__
import
print_function
,
absolute_import
from
wendelin.wcfs.internal
import
xbtree
from
BTrees.LOBTree
import
LOBTree
,
LOBucket
from
BTrees.LOBTree
import
LOBTree
from
BTrees.IIBTree
import
IITreeSet
,
IISet
from
BTrees.tests
import
testBTrees
from
BTrees
import
check
as
zbcheck
...
...
@@ -41,7 +39,7 @@ T = xbtree.Tree
B
=
lambda
*
keyv
:
xbtree
.
Bucket
(
keyv
,
None
)
Bv
=
lambda
keyv
,
*
valuev
:
xbtree
.
Bucket
(
keyv
,
valuev
)
# build ztree with known degenerate topology, see:
# build
DegenerateZTree builds
ztree with known degenerate topology, see:
# https://github.com/zopefoundation/ZODB/commit/6cd24e99f89b
# https://github.com/zopefoundation/BTrees/blob/4.7.2-1-g078ba60/BTrees/tests/testBTrees.py#L20
def
buildDegenerateZTree
():
...
...
@@ -141,9 +139,7 @@ def test_allStructs():
assert
XY
([
1
,
3
],
0
,
0
)
==
[
T
([],
B
(
1
,
3
))
]
assert
X
([],
0
,
1
)
==
[
T
([],
B
())
]
# nothing to split (?) -> y
#assert X([], 0, 1) == [ T([], B()), T([0], B(), B()) ]
assert
Y
([],
0
,
1
)
==
[
T
([],
B
())
]
assert
XY
([],
0
,
1
)
==
[
T
([],
B
())
]
# nothing to split
assert
X
([],
1
,
0
)
==
[
T
([],
B
()),
...
...
@@ -492,7 +488,7 @@ def test_restructure():
return
ztree
# R restructures ztree to have specified new topology.
#
Unless dontcommit=Y is specified, the result is committ
ed.
#
The result is committed unless dontcommit=Y specifi
ed.
def
R
(
ztree
,
newtopo
,
dontcommit
=
False
):
# verify ztree consistency
items
=
list
(
ztree
.
items
())
...
...
@@ -511,7 +507,7 @@ def test_restructure():
# 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
.
# then the modifications will be lost
after live cache clearance
.
zconn
.
cacheMinimize
()
assert
xbtree
.
StructureOf
(
ztree
,
onlyKeys
=
True
)
==
\
...
...
@@ -523,10 +519,10 @@ def test_restructure():
for
(
k
,
v
)
in
items
:
assert
ztree
[
k
]
==
v
# S returns topo-encoded keys-only structure of ztree
# S returns topo-encoded keys-only structure of ztree.
# Sv returns topo-encoded structure of ztree with values.
def
S
(
ztree
):
return
xbtree
.
TopoEncode
(
xbtree
.
StructureOf
(
ztree
,
onlyKeys
=
True
))
# Sv returns topo-encoded structure of ztree with values
def
Sv
(
ztree
):
return
xbtree
.
TopoEncode
(
xbtree
.
StructureOf
(
ztree
),
xencode
)
...
...
@@ -713,7 +709,7 @@ def test_restructure():
assertB
(
b8
,
8
)
# ---- new strucure given with values ----
# ---- new struc
t
ure given with values ----
z
=
Z
(
0
,
2
)
R
(
z
,
T
([
1
],
Bv
([
0
],
X
[
0
]),
Bv
([
2
],
X
[
2
])))
b0
,
b2
=
assertT
(
z
,
[
1
],
'B'
,
'B'
)
...
...
@@ -738,7 +734,7 @@ def test_restructure():
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')
# verify changed objects are marked as such and so included into commit
# verify
that
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)
transaction.commit()
...
...
@@ -793,7 +789,6 @@ def test_restructure():
#
# ( we make sure that Restructure can make the restructurement and that
# after restructure a tree remains valid without any error introduced )
for nkeys in range(5): # XXX !slow -> ↑
for xkeyv in xbtree._iterSplitByN(-1, 5+1, nkeys):
keyv = xkeyv[1:-1] # -1, ..., N -> ...
...
...
@@ -813,9 +808,24 @@ def test_restructure():
def test_walkBFS():
R = xbtree._Range
# XXX ø
# XXX 1 k->v
# T/B
b = B()
t = T([], b)
walkv = list(xbtree.__walkBFS(t))
assert len(walkv) == 2 # (t) (b)
_ = walkv[0]
assert len(_) == 1
assert _[0].range == R(-inf, inf)
assert _[0].node is t
_ = walkv[1]
assert len(_) == 1
assert _[0].range == R(-inf, inf)
assert _[0].node is b
# T0/T-T/B-B
bl = B(); br = B()
tl = T([], bl)
tr = T([], br)
...
...
@@ -926,7 +936,6 @@ def test_zwalkBFS():
def test_keyvSliceBy():
X = xbtree._keyvSliceBy
assert X([], 0,0) == []
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment