Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
12fc9c5d
Commit
12fc9c5d
authored
Dec 14, 2008
by
Martijn Pieters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test cleanups from the trunk
parent
9abec195
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
83 deletions
+43
-83
lib/python/Products/PluginIndexes/PathIndex/tests/testPathIndex.py
...n/Products/PluginIndexes/PathIndex/tests/testPathIndex.py
+43
-83
No files found.
lib/python/Products/PluginIndexes/PathIndex/tests/testPathIndex.py
View file @
12fc9c5d
...
@@ -24,20 +24,12 @@ from Products.PluginIndexes.PathIndex.PathIndex import PathIndex
...
@@ -24,20 +24,12 @@ from Products.PluginIndexes.PathIndex.PathIndex import PathIndex
class
Dummy
:
class
Dummy
:
meta_type
=
"foo"
def
__init__
(
self
,
path
):
def
__init__
(
self
,
path
):
self
.
path
=
path
self
.
path
=
path
def
getPhysicalPath
(
self
):
def
getPhysicalPath
(
self
):
return
self
.
path
.
split
(
'/'
)
return
self
.
path
.
split
(
'/'
)
def
__str__
(
self
):
return
'<Dummy: %s>'
%
self
.
path
__repr__
=
__str__
class
PathIndexTests
(
unittest
.
TestCase
):
class
PathIndexTests
(
unittest
.
TestCase
):
""" Test PathIndex objects """
""" Test PathIndex objects """
...
@@ -81,7 +73,7 @@ class PathIndexTests(unittest.TestCase):
...
@@ -81,7 +73,7 @@ class PathIndexTests(unittest.TestCase):
self
.
assertEqual
(
self
.
_index
.
numObjects
()
,
0
)
self
.
assertEqual
(
self
.
_index
.
numObjects
()
,
0
)
self
.
assertEqual
(
self
.
_index
.
getEntryForObject
(
1234
),
None
)
self
.
assertEqual
(
self
.
_index
.
getEntryForObject
(
1234
),
None
)
self
.
_index
.
unindex_object
(
1234
)
# nothrow
self
.
_index
.
unindex_object
(
1234
)
# nothrow
self
.
assertEqual
(
self
.
_index
.
_apply_index
(
{
"suxpath"
:
"xxx"
}
),
None
)
self
.
assertEqual
(
self
.
_index
.
_apply_index
(
dict
(
suxpath
=
"xxx"
)
),
None
)
def
testUnIndex
(
self
):
def
testUnIndex
(
self
):
self
.
_populateIndex
()
self
.
_populateIndex
()
...
@@ -114,79 +106,49 @@ class PathIndexTests(unittest.TestCase):
...
@@ -114,79 +106,49 @@ class PathIndexTests(unittest.TestCase):
self
.
_index
.
unindex_object
(
1
)
self
.
_index
.
unindex_object
(
1
)
def
testRoot
(
self
):
def
testRoot
(
self
):
self
.
_populateIndex
()
self
.
_populateIndex
()
tests
=
(
(
"/"
,
0
,
range
(
1
,
19
)),
)
for
comp
,
level
,
results
in
tests
:
for
path
in
[
comp
,
"/"
+
comp
,
"/"
+
comp
+
"/"
]:
res
=
self
.
_index
.
_apply_index
(
{
"path"
:{
'query'
:
path
,
"level"
:
level
}})
lst
=
list
(
res
[
0
].
keys
())
self
.
assertEqual
(
lst
,
results
)
for
comp
,
level
,
results
in
tests
:
for
path
in
[
comp
,
"/"
+
comp
,
"/"
+
comp
+
"/"
]:
res
=
self
.
_index
.
_apply_index
(
{
"path"
:{
'query'
:(
(
path
,
level
),)}})
lst
=
list
(
res
[
0
].
keys
())
self
.
assertEqual
(
lst
,
results
)
def
testRoot
(
self
):
queries
=
(
dict
(
path
=
dict
(
query
=
'/'
,
level
=
0
)),
self
.
_populateIndex
()
dict
(
path
=
((
'/'
,
0
),)),
tests
=
(
(
"/"
,
0
,
range
(
1
,
19
)),
)
)
for
q
in
queries
:
for
comp
,
level
,
results
in
tests
:
res
=
self
.
_index
.
_apply_index
(
q
)
for
path
in
[
comp
,
"/"
+
comp
,
"/"
+
comp
+
"/"
]:
self
.
assertEqual
(
list
(
res
[
0
].
keys
()),
range
(
1
,
19
))
res
=
self
.
_index
.
_apply_index
(
{
"path"
:{
'query'
:
path
,
"level"
:
level
}})
lst
=
list
(
res
[
0
].
keys
())
self
.
assertEqual
(
lst
,
results
)
for
comp
,
level
,
results
in
tests
:
for
path
in
[
comp
,
"/"
+
comp
,
"/"
+
comp
+
"/"
]:
res
=
self
.
_index
.
_apply_index
(
{
"path"
:{
'query'
:(
(
path
,
level
),)}})
lst
=
list
(
res
[
0
].
keys
())
self
.
assertEqual
(
lst
,
results
)
def
testSimpleTests
(
self
):
def
testSimpleTests
(
self
):
self
.
_populateIndex
()
self
.
_populateIndex
()
tests
=
[
tests
=
[
# component, level, expected results
(
"aa"
,
0
,
[
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
]),
(
"aa"
,
0
,
[
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
]),
(
"aa"
,
1
,
[
1
,
2
,
3
,
10
,
11
,
12
]
),
(
"aa"
,
1
,
[
1
,
2
,
3
,
10
,
11
,
12
]
),
(
"bb"
,
0
,
[
10
,
11
,
12
,
13
,
14
,
15
,
16
,
17
,
18
]),
(
"bb"
,
0
,
[
10
,
11
,
12
,
13
,
14
,
15
,
16
,
17
,
18
]),
(
"bb"
,
1
,
[
4
,
5
,
6
,
13
,
14
,
15
]
),
(
"bb"
,
1
,
[
4
,
5
,
6
,
13
,
14
,
15
]),
(
"bb/cc"
,
0
,
[
16
,
17
,
18
]
),
(
"bb/cc"
,
0
,
[
16
,
17
,
18
]),
(
"bb/cc"
,
1
,
[
6
,
15
]
),
(
"bb/cc"
,
1
,
[
6
,
15
]),
(
"bb/aa"
,
0
,
[
10
,
11
,
12
]
),
(
"bb/aa"
,
0
,
[
10
,
11
,
12
]),
(
"bb/aa"
,
1
,
[
4
,
13
]
),
(
"bb/aa"
,
1
,
[
4
,
13
]),
(
"aa/cc"
,
-
1
,
[
3
,
7
,
8
,
9
,
12
]
),
(
"aa/cc"
,
-
1
,
[
3
,
7
,
8
,
9
,
12
]),
(
"bb/bb"
,
-
1
,
[
5
,
13
,
14
,
15
]
),
(
"bb/bb"
,
-
1
,
[
5
,
13
,
14
,
15
]),
(
"18.html"
,
3
,
[
18
]
),
(
"18.html"
,
3
,
[
18
]),
(
"18.html"
,
-
1
,
[
18
]
),
(
"18.html"
,
-
1
,
[
18
]),
(
"cc/18.html"
,
-
1
,
[
18
]
),
(
"cc/18.html"
,
-
1
,
[
18
]),
(
"cc/18.html"
,
2
,
[
18
]
),
(
"cc/18.html"
,
2
,
[
18
]),
]
]
for
comp
,
level
,
results
in
tests
:
for
comp
,
level
,
results
in
tests
:
for
path
in
[
comp
,
"/"
+
comp
,
"/"
+
comp
+
"/"
]:
for
path
in
[
comp
,
"/"
+
comp
,
"/"
+
comp
+
"/"
]:
res
=
self
.
_index
.
_apply_index
(
# Test with the level passed in as separate parameter
{
"path"
:{
'query'
:
path
,
"level"
:
level
}})
res
=
self
.
_index
.
_apply_index
(
dict
(
path
=
lst
=
list
(
res
[
0
].
keys
(
))
dict
(
query
=
path
,
level
=
level
)
))
self
.
assertEqual
(
l
st
,
results
)
self
.
assertEqual
(
l
ist
(
res
[
0
].
keys
()),
results
)
for
comp
,
level
,
results
in
tests
:
# Test with the level passed in as part of the path parameter
for
path
in
[
comp
,
"/"
+
comp
,
"/"
+
comp
+
"/"
]:
res
=
self
.
_index
.
_apply_index
(
dict
(
path
=
res
=
self
.
_index
.
_apply_index
(
dict
(
query
=
((
path
,
level
),))))
{
"path"
:{
'query'
:(
(
path
,
level
),)}})
self
.
assertEqual
(
list
(
res
[
0
].
keys
()),
results
)
lst
=
list
(
res
[
0
].
keys
())
self
.
assertEqual
(
lst
,
results
)
def
testComplexOrTests
(
self
):
def
testComplexOrTests
(
self
):
self
.
_populateIndex
()
self
.
_populateIndex
()
tests
=
[
tests
=
[
([
'aa'
,
'bb'
],
1
,[
1
,
2
,
3
,
4
,
5
,
6
,
10
,
11
,
12
,
13
,
14
,
15
]),
([
'aa'
,
'bb'
],
1
,[
1
,
2
,
3
,
4
,
5
,
6
,
10
,
11
,
12
,
13
,
14
,
15
]),
...
@@ -194,36 +156,34 @@ class PathIndexTests(unittest.TestCase):
...
@@ -194,36 +156,34 @@ class PathIndexTests(unittest.TestCase):
([(
'cc'
,
1
),(
'cc'
,
2
)],
0
,[
3
,
6
,
7
,
8
,
9
,
12
,
15
,
16
,
17
,
18
]),
([(
'cc'
,
1
),(
'cc'
,
2
)],
0
,[
3
,
6
,
7
,
8
,
9
,
12
,
15
,
16
,
17
,
18
]),
]
]
for
lst
,
level
,
results
in
tests
:
for
lst
,
level
,
results
in
tests
:
res
=
self
.
_index
.
_apply_index
(
dict
(
path
=
res
=
self
.
_index
.
_apply_index
(
dict
(
query
=
lst
,
level
=
level
,
operator
=
'or'
)))
{
"path"
:{
'query'
:
lst
,
"level"
:
level
,
"operator"
:
"or"
}})
lst
=
list
(
res
[
0
].
keys
())
lst
=
list
(
res
[
0
].
keys
())
self
.
assertEqual
(
lst
,
results
)
self
.
assertEqual
(
lst
,
results
)
def
testComplexANDTests
(
self
):
def
testComplexANDTests
(
self
):
self
.
_populateIndex
()
self
.
_populateIndex
()
tests
=
[
tests
=
[
([
'aa'
,
'bb'
],
1
,[]),
# Path query (as list or (path, level) tuple), level, expected
([(
'aa'
,
0
),(
'bb'
,
1
)],
0
,[
4
,
5
,
6
]),
([
'aa'
,
'bb'
],
1
,
[]),
([(
'aa'
,
0
),(
'cc'
,
2
)],
0
,[
3
,
6
,
9
]),
([(
'aa'
,
0
),
(
'bb'
,
1
)],
0
,
[
4
,
5
,
6
]),
([(
'aa'
,
0
),
(
'cc'
,
2
)],
0
,
[
3
,
6
,
9
]),
]
]
for
lst
,
level
,
results
in
tests
:
for
lst
,
level
,
results
in
tests
:
res
=
self
.
_index
.
_apply_index
(
res
=
self
.
_index
.
_apply_index
(
dict
(
path
=
{
"path"
:{
'query'
:
lst
,
"level"
:
level
,
"operator"
:
"and"
}}
)
dict
(
query
=
lst
,
level
=
level
,
operator
=
'and'
))
)
lst
=
list
(
res
[
0
].
keys
())
lst
=
list
(
res
[
0
].
keys
())
self
.
assertEqual
(
lst
,
results
)
self
.
assertEqual
(
lst
,
results
)
def
testQueryPathReturnedInResult
(
self
):
def
testQueryPathReturnedInResult
(
self
):
index
=
self
.
_index
index
=
self
.
_index
index
.
index_object
(
1
,
Dummy
(
"/ff"
))
index
.
index_object
(
1
,
Dummy
(
"/ff"
))
index
.
index_object
(
2
,
Dummy
(
"/ff/gg"
))
index
.
index_object
(
2
,
Dummy
(
"/ff/gg"
))
index
.
index_object
(
3
,
Dummy
(
"/ff/gg/3.html"
))
index
.
index_object
(
3
,
Dummy
(
"/ff/gg/3.html"
))
index
.
index_object
(
4
,
Dummy
(
"/ff/gg/4.html"
))
index
.
index_object
(
4
,
Dummy
(
"/ff/gg/4.html"
))
res
=
index
.
_apply_index
(
{
'path'
:
{
'query'
:
'/ff/gg'
}}
)
res
=
index
.
_apply_index
(
dict
(
path
=
dict
(
query
=
'/ff/gg'
))
)
lst
=
list
(
res
[
0
].
keys
())
lst
=
list
(
res
[
0
].
keys
())
self
.
assertEqual
(
lst
,
[
2
,
3
,
4
])
self
.
assertEqual
(
lst
,
[
2
,
3
,
4
])
...
...
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