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
2bcabfa8
Commit
2bcabfa8
authored
May 12, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
7f4ea073
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
24 deletions
+42
-24
wcfs/internal/xbtree_test.py
wcfs/internal/xbtree_test.py
+42
-24
No files found.
wcfs/internal/xbtree_test.py
View file @
2bcabfa8
...
...
@@ -27,7 +27,10 @@ from BTrees.IIBTree import IITreeSet, IISet
from
BTrees.tests
import
testBTrees
from
BTrees
import
check
as
zbcheck
from
BTrees.check
import
BTREE_EMPTY
,
BTREE_ONE
,
BTREE_NORMAL
from
ZODB.MappingStorage
import
MappingStorage
from
ZODB
import
DB
from
persistent
import
Persistent
import
transaction
inf
=
float
(
'inf'
)
...
...
@@ -451,17 +454,29 @@ def test_walkBFS():
def
test_zwalkBFS
():
zt
=
buildDegenerateZTree
()
# T return kind + keys of a ztree node
def
T
(
ztree
):
assert
isinstance
(
ztree
,
IITreeSet
)
kind
,
keys
,
kids
=
zbcheck
.
crack_btree
(
ztree
,
False
)
return
(
kind
,
keys
)
# B returns keys from zbucket node
def
B
(
zbucket
):
assert
isinstance
(
zbucket
,
IISet
)
keys
,
_
=
zbcheck
.
crack_bucket
(
zbucket
,
False
)
return
keys
# assign oid to created objects
zstor
=
MappingStorage
()
db
=
DB
(
zstor
)
zconn
=
db
.
open
()
zroot
=
zconn
.
root
()
zroot
[
'x'
]
=
zt
transaction
.
commit
()
# assertT asserts that znode is tree + has specified keys and children
def
assertT
(
znode
,
keyv
,
*
children
):
assert
isinstance
(
znode
,
IITreeSet
)
kind
,
keys
,
kids
=
zbcheck
.
crack_btree
(
znode
,
False
)
assert
kind
==
BTREE_NORMAL
assert
keys
==
keyv
assert
len
(
kids
)
==
len
(
children
)
for
(
child
,
childOK
)
in
zip
(
kids
,
children
):
assert
child
is
childOK
# assertB asserts that znode is bucket + has specified keys
def
assertB
(
znode
,
*
keyv
):
assert
isinstance
(
znode
,
IISet
)
keys
,
_
=
zbcheck
.
crack_bucket
(
znode
,
False
)
assert
keys
==
keyv
R
=
xbtree
.
_Range
...
...
@@ -473,6 +488,22 @@ def test_zwalkBFS():
# [4,6)T, [6,10)B7, [10,∞)B11
# [4,6)B5
_
=
zwalkv
[
5
]
# [4,6)B5
assert
len
(
_
)
==
1
assert
_
[
0
].
range
==
R
(
4
,
6
)
assertB
(
_
[
0
].
node
,
5
)
b5
=
_
[
0
]
_
=
zwalkv
[
4
]
# [4,6)T, [6,10)B7, [10,∞)B11
assert
len
(
_
)
==
3
assert
_
[
0
].
range
==
R
(
4
,
6
)
assert
_
[
1
].
range
==
R
(
6
,
10
)
assert
_
[
2
].
range
==
R
(
10
,
inf
)
assertT
(
_
[
0
].
node
,
[],
b5
)
assertB
(
_
[
1
].
node
,
7
)
assertB
(
_
[
2
].
node
,
11
)
_
=
zwalkv
[
0
]
# [-∞,∞)T4,
assert
len
(
_
)
==
1
assert
_
[
0
].
range
==
R
(
-
inf
,
inf
)
...
...
@@ -507,19 +538,6 @@ def test_zwalkBFS():
assert
T
(
_
[
3
].
node
)
==
(
BTREE_ONE
,
B7
)
assert
T
(
_
[
4
].
node
)
==
(
BTREE_ONE
,
B11
)
_
=
zwalkv
[
4
]
# [4,6)T, [6,10)B7, [10,∞)B11
assert
len
(
_
)
==
3
assert
_
[
0
].
range
==
R
(
4
,
6
)
assert
_
[
1
].
range
==
R
(
6
,
10
)
assert
_
[
2
].
range
==
R
(
10
,
inf
)
assert
T
(
_
[
0
].
node
)
==
(
BTREE_ONE
,
B5
)
assert
B
(
_
[
1
].
node
)
==
[
7
]
assert
B
(
_
[
2
].
node
)
==
[
11
]
_
=
zwalkv
[
5
]
# [4,6)B5
assert
len
(
_
)
==
1
assert
_
[
0
].
range
==
R
(
4
,
6
)
assert
B
(
_
[
0
].
node
)
==
[
5
]
def
test_keyvSliceBy
():
...
...
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