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
e897dfa8
Commit
e897dfa8
authored
Aug 05, 2010
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fill in more tests for the plan
parent
a9e41899
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
83 additions
and
18 deletions
+83
-18
src/Products/ZCatalog/plan.py
src/Products/ZCatalog/plan.py
+1
-1
src/Products/ZCatalog/tests/test_plan.py
src/Products/ZCatalog/tests/test_plan.py
+82
-17
No files found.
src/Products/ZCatalog/plan.py
View file @
e897dfa8
...
...
@@ -251,7 +251,7 @@ class CatalogPlan(object):
self
.
init_timer
()
self
.
start_time
=
time
.
time
()
def
start_split
(
self
,
name
,
result
=
None
):
def
start_split
(
self
,
name
):
self
.
interim
[
name
]
=
Duration
(
time
.
time
(),
None
)
def
stop_split
(
self
,
name
,
result
=
None
,
limit
=
False
):
...
...
src/Products/ZCatalog/tests/test_plan.py
View file @
e897dfa8
...
...
@@ -12,6 +12,7 @@
##############################################################################
import
os
import
time
import
unittest
from
zope.testing
import
cleanup
...
...
@@ -194,25 +195,89 @@ class TestCatalogPlan(cleanup.CleanUp, unittest.TestCase):
def
setUp
(
self
):
cleanup
.
CleanUp
.
setUp
(
self
)
from
Products.ZCatalog.ZCatalog
import
ZCatalog
self
.
zcat
=
ZCatalog
(
'catalog'
)
self
.
zcat
.
long_query_time
=
0.0
self
.
zcat
.
addIndex
(
'num'
,
'FieldIndex'
)
self
.
zcat
.
addIndex
(
'big'
,
'FieldIndex'
)
self
.
zcat
.
addIndex
(
'numbers'
,
'KeywordIndex'
)
from
Products.ZCatalog.Catalog
import
Catalog
self
.
cat
=
Catalog
(
'catalog'
)
for
i
in
range
(
9
):
obj
=
dummy
(
i
)
self
.
zcat
.
catalog_object
(
obj
,
str
(
i
))
def
_makeOne
(
self
,
catalog
=
None
,
query
=
None
):
from
..plan
import
CatalogPlan
if
catalog
is
None
:
catalog
=
self
.
cat
return
CatalogPlan
(
catalog
,
query
=
query
)
def
test_get_id
(
self
):
plan
=
self
.
_makeOne
()
self
.
assertEquals
(
plan
.
get_id
(),
(
''
,
'NonPersistentCatalog'
))
def
test_get_id_persistent
(
self
):
from
Products.ZCatalog.ZCatalog
import
ZCatalog
zcat
=
ZCatalog
(
'catalog'
)
plan
=
self
.
_makeOne
(
zcat
.
_catalog
)
self
.
assertEquals
(
plan
.
get_id
(),
(
'catalog'
,))
def
test_plan_empty
(
self
):
plan
=
self
.
_makeOne
()
self
.
assertEquals
(
plan
.
plan
(),
None
)
def
test_start
(
self
):
plan
=
self
.
_makeOne
()
plan
.
start
()
self
.
assert_
(
plan
.
start_time
<=
time
.
time
())
def
test_start_split
(
self
):
plan
=
self
.
_makeOne
()
plan
.
start_split
(
'index1'
)
self
.
assert_
(
'index1'
in
plan
.
interim
)
def
test_stop_split
(
self
):
plan
=
self
.
_makeOne
()
plan
.
start_split
(
'index1'
)
plan
.
stop_split
(
'index1'
)
self
.
assert_
(
'index1'
in
plan
.
interim
)
i1
=
plan
.
interim
[
'index1'
]
self
.
assert_
(
i1
.
start
<=
i1
.
end
)
self
.
assert_
(
'index1'
in
plan
.
benchmark
)
def
test_stop_split_sort_on
(
self
):
plan
=
self
.
_makeOne
()
plan
.
start_split
(
'sort_on'
)
plan
.
stop_split
(
'sort_on'
)
self
.
assert_
(
'sort_on'
in
plan
.
interim
)
so
=
plan
.
interim
[
'sort_on'
]
self
.
assert_
(
so
.
start
<=
so
.
end
)
self
.
assert_
(
'sort_on'
not
in
plan
.
benchmark
)
def
test_stop
(
self
):
plan
=
self
.
_makeOne
(
query
=
{
'index1'
:
1
,
'index2'
:
2
})
plan
.
start
()
plan
.
start_split
(
'index1'
)
plan
.
stop_split
(
'index1'
)
plan
.
start_split
(
'index1'
)
plan
.
stop_split
(
'index1'
)
plan
.
start_split
(
'sort_on'
)
plan
.
stop_split
(
'sort_on'
)
plan
.
stop
()
self
.
assert_
(
plan
.
duration
>
0
)
self
.
assert_
(
'index1'
in
plan
.
benchmark
)
self
.
assertEquals
(
plan
.
benchmark
[
'index1'
].
hits
,
2
)
self
.
assert_
(
'index2'
in
plan
.
benchmark
)
self
.
assertEquals
(
plan
.
benchmark
[
'index2'
].
hits
,
0
)
self
.
assertEquals
(
set
(
plan
.
plan
()),
set
((
'index1'
,
'index2'
)))
def
test_log
(
self
):
plan
=
self
.
_makeOne
(
query
=
{
'index1'
:
1
})
plan
.
threshold
=
0.0
plan
.
start
()
plan
.
start_split
(
'index1'
)
plan
.
stop_split
(
'index1'
)
plan
.
stop
()
plan
.
log
()
report
=
plan
.
report
()
self
.
assertEquals
(
len
(
report
),
1
)
self
.
assertEquals
(
report
[
0
][
'counter'
],
2
)
plan
.
reset
()
self
.
assertEquals
(
len
(
plan
.
report
()),
0
)
# get_id
# init_timer
# plan
# start
# start_split
# stop_split
# stop
# log
class
TestCatalogReport
(
cleanup
.
CleanUp
,
unittest
.
TestCase
):
...
...
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