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
a0db671f
Commit
a0db671f
authored
Jul 24, 2010
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split out report tests into a separate module
parent
f665560b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
117 additions
and
87 deletions
+117
-87
src/Products/ZCatalog/tests/testCatalog.py
src/Products/ZCatalog/tests/testCatalog.py
+0
-87
src/Products/ZCatalog/tests/test_report.py
src/Products/ZCatalog/tests/test_report.py
+117
-0
No files found.
src/Products/ZCatalog/tests/testCatalog.py
View file @
a0db671f
...
...
@@ -852,92 +852,6 @@ class TestZCatalogGetObject(unittest.TestCase):
self
.
assertEqual
(
brain
.
_unrestrictedGetObject
(),
None
)
class
TestCatalogReport
(
unittest
.
TestCase
):
def
setUp
(
self
):
from
Products.ZCatalog.ZCatalog
import
ZCatalog
vocabulary
=
Vocabulary
.
Vocabulary
(
'Vocabulary'
,
'Vocabulary'
,
globbing
=
1
)
self
.
zcat
=
ZCatalog
(
'catalog'
)
self
.
zcat
.
long_query_time
=
0.0
self
.
zcat
.
addIndex
(
'num'
,
'FieldIndex'
)
self
.
zcat
.
addIndex
(
'big'
,
'FieldIndex'
)
self
.
zcat
.
addIndex
(
'title'
,
'TextIndex'
)
self
.
zcat
.
_catalog
.
vocabulary
=
vocabulary
for
i
in
range
(
9
):
obj
=
zdummy
(
i
)
obj
.
big
=
i
>
5
self
.
zcat
.
catalog_object
(
obj
,
str
(
i
))
def
tearDown
(
self
):
from
Products.ZCatalog.report
import
clear_value_indexes
clear_value_indexes
()
def
test_ReportLength
(
self
):
""" tests the report aggregation """
self
.
zcat
.
manage_resetCatalogReport
()
self
.
zcat
.
searchResults
(
title
=
'4 or 5 or 6'
,
sort_on
=
'num'
)
self
.
zcat
.
searchResults
(
title
=
'1 or 6 or 7'
,
sort_on
=
'num'
)
self
.
zcat
.
searchResults
(
title
=
'3 or 8 or 9'
,
sort_on
=
'num'
)
self
.
zcat
.
searchResults
(
big
=
True
,
sort_on
=
'num'
)
self
.
zcat
.
searchResults
(
big
=
True
,
sort_on
=
'num'
)
self
.
zcat
.
searchResults
(
big
=
False
,
sort_on
=
'num'
)
self
.
zcat
.
searchResults
(
num
=
[
5
,
4
,
3
],
sort_on
=
'num'
)
self
.
zcat
.
searchResults
(
num
=
(
3
,
4
,
5
),
sort_on
=
'num'
)
self
.
assertEqual
(
4
,
len
(
self
.
zcat
.
getCatalogReport
()))
def
test_ReportCounter
(
self
):
""" tests the counter of equal queries """
self
.
zcat
.
manage_resetCatalogReport
()
self
.
zcat
.
searchResults
(
title
=
'4 or 5 or 6'
,
sort_on
=
'num'
)
self
.
zcat
.
searchResults
(
title
=
'1 or 6 or 7'
,
sort_on
=
'num'
)
self
.
zcat
.
searchResults
(
title
=
'3 or 8 or 9'
,
sort_on
=
'num'
)
r
=
self
.
zcat
.
getCatalogReport
()[
0
]
self
.
assertEqual
(
r
[
'counter'
],
3
)
def
test_ReportKey
(
self
):
""" tests the query keys for uniqueness """
# query key 1
key
=
(
'sort_on'
,
(
'big'
,
'True'
))
self
.
zcat
.
manage_resetCatalogReport
()
self
.
zcat
.
searchResults
(
big
=
True
,
sort_on
=
'num'
)
self
.
zcat
.
searchResults
(
big
=
True
,
sort_on
=
'num'
)
r
=
self
.
zcat
.
getCatalogReport
()[
0
]
self
.
assertEqual
(
r
[
'query'
],
key
)
self
.
assertEqual
(
r
[
'counter'
],
2
)
# query key 2
key
=
(
'sort_on'
,
(
'big'
,
'False'
))
self
.
zcat
.
manage_resetCatalogReport
()
self
.
zcat
.
searchResults
(
big
=
False
,
sort_on
=
'num'
)
r
=
self
.
zcat
.
getCatalogReport
()[
0
]
self
.
assertEqual
(
r
[
'query'
],
key
)
self
.
assertEqual
(
r
[
'counter'
],
1
)
# query key 3
key
=
(
'sort_on'
,
(
'num'
,
'[3, 4, 5]'
))
self
.
zcat
.
manage_resetCatalogReport
()
self
.
zcat
.
searchResults
(
num
=
[
5
,
4
,
3
],
sort_on
=
'num'
)
self
.
zcat
.
searchResults
(
num
=
(
3
,
4
,
5
),
sort_on
=
'num'
)
r
=
self
.
zcat
.
getCatalogReport
()[
0
]
self
.
assertEqual
(
r
[
'query'
],
key
)
self
.
assertEqual
(
r
[
'counter'
],
2
)
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
TestAddDelColumn
)
)
...
...
@@ -947,7 +861,6 @@ def test_suite():
suite
.
addTest
(
unittest
.
makeSuite
(
TestRS
)
)
suite
.
addTest
(
unittest
.
makeSuite
(
TestMerge
)
)
suite
.
addTest
(
unittest
.
makeSuite
(
TestZCatalogGetObject
)
)
suite
.
addTest
(
unittest
.
makeSuite
(
TestCatalogReport
))
return
suite
if
__name__
==
'__main__'
:
...
...
src/Products/ZCatalog/tests/test_report.py
0 → 100644
View file @
a0db671f
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
import
unittest
from
Products.ZCatalog
import
Vocabulary
class
dummy
(
object
):
def
__init__
(
self
,
num
):
self
.
num
=
num
def
title
(
self
):
return
'%d'
%
self
.
num
class
TestCatalogReport
(
unittest
.
TestCase
):
def
setUp
(
self
):
from
Products.ZCatalog.ZCatalog
import
ZCatalog
vocabulary
=
Vocabulary
.
Vocabulary
(
'Vocabulary'
,
'Vocabulary'
,
globbing
=
1
)
self
.
zcat
=
ZCatalog
(
'catalog'
)
self
.
zcat
.
long_query_time
=
0.0
self
.
zcat
.
addIndex
(
'num'
,
'FieldIndex'
)
self
.
zcat
.
addIndex
(
'big'
,
'FieldIndex'
)
self
.
zcat
.
addIndex
(
'title'
,
'TextIndex'
)
self
.
zcat
.
_catalog
.
vocabulary
=
vocabulary
for
i
in
range
(
9
):
obj
=
dummy
(
i
)
obj
.
big
=
i
>
5
self
.
zcat
.
catalog_object
(
obj
,
str
(
i
))
def
tearDown
(
self
):
from
Products.ZCatalog.report
import
clear_value_indexes
clear_value_indexes
()
def
test_ReportLength
(
self
):
""" tests the report aggregation """
self
.
zcat
.
manage_resetCatalogReport
()
self
.
zcat
.
searchResults
(
title
=
'4 or 5 or 6'
,
sort_on
=
'num'
)
self
.
zcat
.
searchResults
(
title
=
'1 or 6 or 7'
,
sort_on
=
'num'
)
self
.
zcat
.
searchResults
(
title
=
'3 or 8 or 9'
,
sort_on
=
'num'
)
self
.
zcat
.
searchResults
(
big
=
True
,
sort_on
=
'num'
)
self
.
zcat
.
searchResults
(
big
=
True
,
sort_on
=
'num'
)
self
.
zcat
.
searchResults
(
big
=
False
,
sort_on
=
'num'
)
self
.
zcat
.
searchResults
(
num
=
[
5
,
4
,
3
],
sort_on
=
'num'
)
self
.
zcat
.
searchResults
(
num
=
(
3
,
4
,
5
),
sort_on
=
'num'
)
self
.
assertEqual
(
4
,
len
(
self
.
zcat
.
getCatalogReport
()))
def
test_ReportCounter
(
self
):
""" tests the counter of equal queries """
self
.
zcat
.
manage_resetCatalogReport
()
self
.
zcat
.
searchResults
(
title
=
'4 or 5 or 6'
,
sort_on
=
'num'
)
self
.
zcat
.
searchResults
(
title
=
'1 or 6 or 7'
,
sort_on
=
'num'
)
self
.
zcat
.
searchResults
(
title
=
'3 or 8 or 9'
,
sort_on
=
'num'
)
r
=
self
.
zcat
.
getCatalogReport
()[
0
]
self
.
assertEqual
(
r
[
'counter'
],
3
)
def
test_ReportKey
(
self
):
""" tests the query keys for uniqueness """
# query key 1
key
=
(
'sort_on'
,
(
'big'
,
'True'
))
self
.
zcat
.
manage_resetCatalogReport
()
self
.
zcat
.
searchResults
(
big
=
True
,
sort_on
=
'num'
)
self
.
zcat
.
searchResults
(
big
=
True
,
sort_on
=
'num'
)
r
=
self
.
zcat
.
getCatalogReport
()[
0
]
self
.
assertEqual
(
r
[
'query'
],
key
)
self
.
assertEqual
(
r
[
'counter'
],
2
)
# query key 2
key
=
(
'sort_on'
,
(
'big'
,
'False'
))
self
.
zcat
.
manage_resetCatalogReport
()
self
.
zcat
.
searchResults
(
big
=
False
,
sort_on
=
'num'
)
r
=
self
.
zcat
.
getCatalogReport
()[
0
]
self
.
assertEqual
(
r
[
'query'
],
key
)
self
.
assertEqual
(
r
[
'counter'
],
1
)
# query key 3
key
=
(
'sort_on'
,
(
'num'
,
'[3, 4, 5]'
))
self
.
zcat
.
manage_resetCatalogReport
()
self
.
zcat
.
searchResults
(
num
=
[
5
,
4
,
3
],
sort_on
=
'num'
)
self
.
zcat
.
searchResults
(
num
=
(
3
,
4
,
5
),
sort_on
=
'num'
)
r
=
self
.
zcat
.
getCatalogReport
()[
0
]
self
.
assertEqual
(
r
[
'query'
],
key
)
self
.
assertEqual
(
r
[
'counter'
],
2
)
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
TestCatalogReport
))
return
suite
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