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
b8b99bcc
Commit
b8b99bcc
authored
Aug 01, 2010
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor tests into multiple test classes
parent
615217a1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
31 deletions
+53
-31
src/Products/ZCatalog/tests/test_zcatalog.py
src/Products/ZCatalog/tests/test_zcatalog.py
+53
-31
No files found.
src/Products/ZCatalog/tests/test_zcatalog.py
View file @
b8b99bcc
...
...
@@ -116,11 +116,23 @@ class PickySecurityManager:
raise
Unauthorized
(
name
)
class
TestZCatalog
(
unittest
.
TestCase
):
class
ZCatalogBase
(
object
):
def
setUp
(
self
):
def
_makeOne
(
self
):
from
Products.ZCatalog.ZCatalog
import
ZCatalog
self
.
_catalog
=
ZCatalog
(
'Catalog'
)
return
ZCatalog
(
'Catalog'
)
def
setUp
(
self
):
self
.
_catalog
=
self
.
_makeOne
()
def
tearDown
(
self
):
self
.
_catalog
=
None
class
TestZCatalog
(
ZCatalogBase
,
unittest
.
TestCase
):
def
setUp
(
self
):
ZCatalogBase
.
setUp
(
self
)
self
.
_catalog
.
resolve_path
=
self
.
_resolve_num
self
.
_catalog
.
addIndex
(
'title'
,
'KeywordIndex'
)
self
.
_catalog
.
addColumn
(
'title'
)
...
...
@@ -143,29 +155,6 @@ class TestZCatalog(unittest.TestCase):
verifyClass
(
IZCatalog
,
ZCatalog
)
def
testAddIndex
(
self
):
self
.
_catalog
.
addIndex
(
'id'
,
'FieldIndex'
)
self
.
assert_
(
'id'
in
self
.
_catalog
.
indexes
())
def
testDelIndex
(
self
):
self
.
assert_
(
'title'
in
self
.
_catalog
.
indexes
())
self
.
_catalog
.
delIndex
(
'title'
)
self
.
assert_
(
'title'
not
in
self
.
_catalog
.
indexes
())
def
testClearIndex
(
self
):
idx
=
self
.
_catalog
.
_catalog
.
getIndex
(
'title'
)
self
.
assertEquals
(
len
(
idx
),
self
.
upper
)
self
.
_catalog
.
clearIndex
(
'title'
)
self
.
assertEquals
(
len
(
idx
),
0
)
def
testAddColumn
(
self
):
self
.
_catalog
.
addColumn
(
'num'
,
default_value
=
0
)
self
.
assert_
(
'num'
in
self
.
_catalog
.
schema
())
def
testDelColumn
(
self
):
self
.
_catalog
.
delColumn
(
'title'
)
self
.
assert_
(
'title'
not
in
self
.
_catalog
.
schema
())
def
testGetMetadataForUID
(
self
):
testNum
=
str
(
self
.
upper
-
3
)
# as good as any..
data
=
self
.
_catalog
.
getMetadataForUID
(
testNum
)
...
...
@@ -264,19 +253,51 @@ class TestZCatalog(unittest.TestCase):
self
.
assertEquals
(
catalog
.
getobject
(
rid0
),
None
)
class
TestZCatalogGetObject
(
unittest
.
TestCase
):
class
TestAddDelColumnIndex
(
ZCatalogBase
,
unittest
.
TestCase
):
def
testAddIndex
(
self
):
self
.
_catalog
.
addIndex
(
'id'
,
'FieldIndex'
)
self
.
assert_
(
'id'
in
self
.
_catalog
.
indexes
())
def
testDelIndex
(
self
):
self
.
_catalog
.
addIndex
(
'title'
,
'FieldIndex'
)
self
.
assert_
(
'title'
in
self
.
_catalog
.
indexes
())
self
.
_catalog
.
delIndex
(
'title'
)
self
.
assert_
(
'title'
not
in
self
.
_catalog
.
indexes
())
def
testClearIndex
(
self
):
self
.
_catalog
.
addIndex
(
'title'
,
'FieldIndex'
)
idx
=
self
.
_catalog
.
_catalog
.
getIndex
(
'title'
)
for
x
in
range
(
10
):
ob
=
zdummy
(
x
)
self
.
_catalog
.
catalog_object
(
ob
,
str
(
x
))
self
.
assertEquals
(
len
(
idx
),
10
)
self
.
_catalog
.
clearIndex
(
'title'
)
self
.
assertEquals
(
len
(
idx
),
0
)
def
testAddColumn
(
self
):
self
.
_catalog
.
addColumn
(
'num'
,
default_value
=
0
)
self
.
assert_
(
'num'
in
self
.
_catalog
.
schema
())
def
testDelColumn
(
self
):
self
.
_catalog
.
addColumn
(
'title'
)
self
.
_catalog
.
delColumn
(
'title'
)
self
.
assert_
(
'title'
not
in
self
.
_catalog
.
schema
())
class
TestZCatalogGetObject
(
ZCatalogBase
,
unittest
.
TestCase
):
# Test what objects are returned by brain.getObject()
def
setUp
(
self
):
from
Products.ZCatalog.ZCatalog
import
ZCatalog
catalog
=
ZCatalog
(
'catalog'
)
catalog
.
addIndex
(
'id'
,
'FieldIndex'
)
ZCatalogBase
.
setUp
(
self
)
self
.
_catalog
.
addIndex
(
'id'
,
'FieldIndex'
)
root
=
Folder
(
''
)
root
.
getPhysicalRoot
=
lambda
:
root
self
.
root
=
root
self
.
root
.
catalog
=
catalog
self
.
root
.
catalog
=
self
.
_
catalog
def
tearDown
(
self
):
ZCatalogBase
.
tearDown
(
self
)
noSecurityManager
()
def
test_getObject_found
(
self
):
...
...
@@ -375,5 +396,6 @@ class TestZCatalogGetObject(unittest.TestCase):
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
TestZCatalog
))
suite
.
addTest
(
unittest
.
makeSuite
(
TestAddDelColumnIndex
))
suite
.
addTest
(
unittest
.
makeSuite
(
TestZCatalogGetObject
))
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