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
1239c640
Commit
1239c640
authored
May 30, 2005
by
Stefan H. Holek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sync up with standalone version 0.9.8.
parent
f544c678
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
107 additions
and
42 deletions
+107
-42
lib/python/Testing/ZopeTestCase/PortalTestCase.py
lib/python/Testing/ZopeTestCase/PortalTestCase.py
+5
-2
lib/python/Testing/ZopeTestCase/ZopeLite.py
lib/python/Testing/ZopeTestCase/ZopeLite.py
+2
-1
lib/python/Testing/ZopeTestCase/__init__.py
lib/python/Testing/ZopeTestCase/__init__.py
+10
-5
lib/python/Testing/ZopeTestCase/doc/API.stx
lib/python/Testing/ZopeTestCase/doc/API.stx
+16
-2
lib/python/Testing/ZopeTestCase/doc/CHANGES.txt
lib/python/Testing/ZopeTestCase/doc/CHANGES.txt
+9
-3
lib/python/Testing/ZopeTestCase/doc/ClassDiagram.pdf
lib/python/Testing/ZopeTestCase/doc/ClassDiagram.pdf
+0
-0
lib/python/Testing/ZopeTestCase/doc/VERSION.txt
lib/python/Testing/ZopeTestCase/doc/VERSION.txt
+1
-0
lib/python/Testing/ZopeTestCase/testBaseTestCase.py
lib/python/Testing/ZopeTestCase/testBaseTestCase.py
+1
-0
lib/python/Testing/ZopeTestCase/testPortalTestCase.py
lib/python/Testing/ZopeTestCase/testPortalTestCase.py
+52
-19
lib/python/Testing/ZopeTestCase/testPythonScript.py
lib/python/Testing/ZopeTestCase/testPythonScript.py
+3
-2
lib/python/Testing/ZopeTestCase/testWebserver.py
lib/python/Testing/ZopeTestCase/testWebserver.py
+2
-3
lib/python/Testing/ZopeTestCase/testZopeTestCase.py
lib/python/Testing/ZopeTestCase/testZopeTestCase.py
+5
-5
lib/python/Testing/ZopeTestCase/utils.py
lib/python/Testing/ZopeTestCase/utils.py
+1
-0
No files found.
lib/python/Testing/ZopeTestCase/PortalTestCase.py
View file @
1239c640
...
@@ -96,7 +96,7 @@ class PortalTestCase(base.TestCase):
...
@@ -96,7 +96,7 @@ class PortalTestCase(base.TestCase):
def
_refreshSkinData
(
self
):
def
_refreshSkinData
(
self
):
'''Refreshes the skin cache.'''
'''Refreshes the skin cache.'''
if
hasattr
(
self
.
portal
,
'clearCurrentSkin'
):
if
hasattr
(
aq_base
(
self
.
portal
)
,
'clearCurrentSkin'
):
self
.
portal
.
clearCurrentSkin
()
self
.
portal
.
clearCurrentSkin
()
else
:
# CMF 1.4
else
:
# CMF 1.4
self
.
portal
.
_v_skindata
=
None
self
.
portal
.
_v_skindata
=
None
...
@@ -119,6 +119,9 @@ class PortalTestCase(base.TestCase):
...
@@ -119,6 +119,9 @@ class PortalTestCase(base.TestCase):
or more lightweight version of the memberarea.
or more lightweight version of the memberarea.
'''
'''
pm
=
self
.
portal
.
portal_membership
pm
=
self
.
portal
.
portal_membership
if
hasattr
(
aq_base
(
pm
),
'createMemberArea'
):
pm
.
createMemberArea
(
name
)
else
:
# CMF 1.4
pm
.
createMemberarea
(
name
)
pm
.
createMemberarea
(
name
)
# Security interface
# Security interface
...
...
lib/python/Testing/ZopeTestCase/ZopeLite.py
View file @
1239c640
...
@@ -22,7 +22,7 @@ Typically used as in
...
@@ -22,7 +22,7 @@ Typically used as in
Zope2.installProduct('SomeProduct')
Zope2.installProduct('SomeProduct')
app = Zope2.app()
app = Zope2.app()
$Id
: ZopeLite.py,v 1.24 2004/08/18 09:28:54 shh42 Exp
$
$Id$
"""
"""
import
os
,
sys
,
time
import
os
,
sys
,
time
...
@@ -182,6 +182,7 @@ debug = Zope2.debug
...
@@ -182,6 +182,7 @@ debug = Zope2.debug
DB
=
Zope2
.
DB
DB
=
Zope2
.
DB
configure
=
Zope2
.
configure
configure
=
Zope2
.
configure
def
startup
():
pass
def
startup
():
pass
Zope
=
Zope2
# ZODB sandbox factory
# ZODB sandbox factory
from
ZODB.DemoStorage
import
DemoStorage
from
ZODB.DemoStorage
import
DemoStorage
...
...
lib/python/Testing/ZopeTestCase/__init__.py
View file @
1239c640
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
##############################################################################
##############################################################################
"""Names exported by the ZopeTestCase package
"""Names exported by the ZopeTestCase package
$Id
: __init__.py,v 1.25 2005/02/22 14:59:16 shh42 Exp
$
$Id$
"""
"""
import
ZopeLite
as
Zope2
import
ZopeLite
as
Zope2
...
@@ -33,14 +33,14 @@ from ZopeTestCase import FunctionalTestCase
...
@@ -33,14 +33,14 @@ from ZopeTestCase import FunctionalTestCase
from
PortalTestCase
import
portal_name
from
PortalTestCase
import
portal_name
from
PortalTestCase
import
PortalTestCase
from
PortalTestCase
import
PortalTestCase
from
base
import
TestCase
from
base
import
app
from
base
import
close
from
profiler
import
Profiled
from
profiler
import
Profiled
from
sandbox
import
Sandboxed
from
sandbox
import
Sandboxed
from
functional
import
Functional
from
functional
import
Functional
from
base
import
TestCase
from
base
import
app
from
base
import
close
from
ZODB.tests.warnhook
import
WarningsHook
from
ZODB.tests.warnhook
import
WarningsHook
from
unittest
import
main
from
unittest
import
main
...
@@ -49,3 +49,8 @@ from zopedoctest import ZopeDocFileSuite
...
@@ -49,3 +49,8 @@ from zopedoctest import ZopeDocFileSuite
from
zopedoctest
import
FunctionalDocTestSuite
from
zopedoctest
import
FunctionalDocTestSuite
from
zopedoctest
import
FunctionalDocFileSuite
from
zopedoctest
import
FunctionalDocFileSuite
import
zopedoctest
as
doctest
import
transaction
Zope
=
Zope2
lib/python/Testing/ZopeTestCase/doc/API.stx
View file @
1239c640
...
@@ -39,28 +39,42 @@ Module Testing.ZopeTestCase
...
@@ -39,28 +39,42 @@ Module Testing.ZopeTestCase
_print(msg)
_print(msg)
ZopeDocTestSuite(module=None, **kw)
ZopeDocFileSuite(*paths, **kw)
FunctionalDocTestSuite(module=None, **kw)
FunctionalDocFileSuite(*paths, **kw)
Classes
Classes
TestCase
ZopeTestCase
ZopeTestCase
FunctionalTestCase
FunctionalTestCase
PortalTestCase
PortalTestCase
TestCase
Profiled
Profiled
Sandboxed
Sandboxed
Functional
Functional
WarningsHook
Modules
Modules
ZopeLite as Zope
ZopeLite as Zope
utils
utils
doctest
transaction
Module ZopeLite
Module ZopeLite
...
...
lib/python/Testing/ZopeTestCase/doc/CHANGES.txt
View file @
1239c640
0.9.
7
(Zope 2.8 edition)
0.9.
8
(Zope 2.8 edition)
- Renamed 'doctest' package to 'zopedoctest' because of name-shadowing
- Renamed 'doctest' package to 'zopedoctest' because of name-shadowing
issues discovered during integration into Zope 2.8.
issues discovered during integration into Zope 2.8. Tests may still use
'from Testing.ZopeTestCase import doctest' as the name is aliased there.
- Greatly improved the doctest story. ZopeTestCase now implements four test
- Greatly improved the doctest story. ZopeTestCase now implements four test
suite factories: ZopeDocTestSuite, ZopeDocFileSuite, FunctionalDocTestSuite,
suite factories: ZopeDocTestSuite, ZopeDocFileSuite, FunctionalDocTestSuite,
and FunctionalDocFileSuite.
and FunctionalDocFileSuite.
...
@@ -10,7 +11,8 @@
...
@@ -10,7 +11,8 @@
- ZopeLite now takes care not to monkey patch an already started Zope.
- ZopeLite now takes care not to monkey patch an already started Zope.
- PortalTestCase.setUp() no longer calls _refreshSkinData() as CMF is smart
- PortalTestCase.setUp() no longer calls _refreshSkinData() as CMF is smart
enough now.
enough now.
- Fixed _refreshSkinData() helper to work with CMF >= 1.5.
- Fixed PortalTestCase._refreshSkinData() helper to work with CMF >= 1.5.
- Made PortalTestCase.createMemberarea() work better with CMF >= 1.5.
- Fixed a bug where using sessions in sandboxed (functional) tests would cause
- Fixed a bug where using sessions in sandboxed (functional) tests would cause
connection pool depletion and subsequent hangs. Thanks to Balazs Ree.
connection pool depletion and subsequent hangs. Thanks to Balazs Ree.
- Encapsulated the ConnectionRegistry in its own module, connections.py.
- Encapsulated the ConnectionRegistry in its own module, connections.py.
...
@@ -19,6 +21,10 @@
...
@@ -19,6 +21,10 @@
to Sidnei da Silva.
to Sidnei da Silva.
- Modified runalltests.py so it imports modules more like test.py, i.e.
- Modified runalltests.py so it imports modules more like test.py, i.e.
without touching sys.path and without the help of imp.
without touching sys.path and without the help of imp.
- The standalone version of ZopeTestCase gained a Zope 2.8-style transaction
module. Tests may now use 'from Testing.ZopeTestCase import transaction'
which is guaranteed to work across Zope versions.
- The REQUEST now contains the ACTUAL_URL variable introduced in Zope 2.7.4.
0.9.6
0.9.6
- Dropped support for Zope 2.5 as it lacks the setSecurityManager() API.
- Dropped support for Zope 2.5 as it lacks the setSecurityManager() API.
...
...
lib/python/Testing/ZopeTestCase/doc/ClassDiagram.pdf
View file @
1239c640
No preview for this file type
lib/python/Testing/ZopeTestCase/doc/VERSION.txt
0 → 100644
View file @
1239c640
ZopeTestCase 0.9.8
lib/python/Testing/ZopeTestCase/testBaseTestCase.py
View file @
1239c640
...
@@ -388,6 +388,7 @@ class TestRequestVariables(base.TestCase):
...
@@ -388,6 +388,7 @@ class TestRequestVariables(base.TestCase):
self
.
failIfEqual
(
request
.
get
(
'BASE0'
,
''
),
''
)
self
.
failIfEqual
(
request
.
get
(
'BASE0'
,
''
),
''
)
self
.
failIfEqual
(
request
.
get
(
'BASE1'
,
''
),
''
)
self
.
failIfEqual
(
request
.
get
(
'BASE1'
,
''
),
''
)
self
.
failIfEqual
(
request
.
get
(
'BASE2'
,
''
),
''
)
self
.
failIfEqual
(
request
.
get
(
'BASE2'
,
''
),
''
)
self
.
failIfEqual
(
request
.
get
(
'ACTUAL_URL'
,
''
),
''
)
import
gc
import
gc
...
...
lib/python/Testing/ZopeTestCase/testPortalTestCase.py
View file @
1239c640
...
@@ -61,13 +61,22 @@ class DummyPortal(Folder):
...
@@ -61,13 +61,22 @@ class DummyPortal(Folder):
class
DummyMembershipTool
(
SimpleItem
):
class
DummyMembershipTool
(
SimpleItem
):
id
=
'portal_membership'
id
=
'portal_membership'
def
__init__
(
self
):
self
.
_called
=
[]
def
createMemberarea
(
self
,
member_id
):
def
createMemberarea
(
self
,
member_id
):
self
.
_called
.
append
(
'createMemberarea'
)
portal
=
self
.
aq_inner
.
aq_parent
portal
=
self
.
aq_inner
.
aq_parent
portal
.
Members
.
manage_addFolder
(
member_id
)
portal
.
Members
.
manage_addFolder
(
member_id
)
def
getHomeFolder
(
self
,
member_id
):
def
getHomeFolder
(
self
,
member_id
):
portal
=
self
.
aq_inner
.
aq_parent
portal
=
self
.
aq_inner
.
aq_parent
return
getattr
(
portal
.
Members
,
member_id
)
return
getattr
(
portal
.
Members
,
member_id
)
class
NewMembershipTool
(
DummyMembershipTool
):
def
createMemberArea
(
self
,
member_id
):
self
.
_called
.
append
(
'createMemberArea'
)
portal
=
self
.
aq_inner
.
aq_parent
portal
.
Members
.
manage_addFolder
(
member_id
)
class
TestPortalTestCase
(
ZopeTestCase
.
PortalTestCase
):
class
TestPortalTestCase
(
ZopeTestCase
.
PortalTestCase
):
'''Incrementally exercise the PortalTestCase API.'''
'''Incrementally exercise the PortalTestCase API.'''
...
@@ -105,7 +114,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
...
@@ -105,7 +114,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
def
test_getPortal
(
self
):
def
test_getPortal
(
self
):
# Portal should be set up
# Portal should be set up
self
.
app
=
self
.
_app
()
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
getP
ortal
()
self
.
portal
=
self
.
_p
ortal
()
self
.
failUnless
(
hasattr_
(
self
.
app
,
portal_name
))
self
.
failUnless
(
hasattr_
(
self
.
app
,
portal_name
))
self
.
failUnless
(
hasattr_
(
self
.
portal
,
'Members'
))
self
.
failUnless
(
hasattr_
(
self
.
portal
,
'Members'
))
self
.
failUnless
(
hasattr_
(
self
.
portal
,
'portal_membership'
))
self
.
failUnless
(
hasattr_
(
self
.
portal
,
'portal_membership'
))
...
@@ -114,7 +123,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
...
@@ -114,7 +123,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
def
test_setupUserFolder
(
self
):
def
test_setupUserFolder
(
self
):
# User folder should be set up.
# User folder should be set up.
self
.
app
=
self
.
_app
()
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
getP
ortal
()
self
.
portal
=
self
.
_p
ortal
()
self
.
failIf
(
hasattr_
(
self
.
portal
,
'acl_users'
))
self
.
failIf
(
hasattr_
(
self
.
portal
,
'acl_users'
))
self
.
_setupUserFolder
()
self
.
_setupUserFolder
()
self
.
failUnless
(
hasattr_
(
self
.
portal
,
'acl_users'
))
self
.
failUnless
(
hasattr_
(
self
.
portal
,
'acl_users'
))
...
@@ -124,7 +133,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
...
@@ -124,7 +133,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
def
test_setupUser
(
self
):
def
test_setupUser
(
self
):
# User should be set up
# User should be set up
self
.
app
=
self
.
_app
()
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
getP
ortal
()
self
.
portal
=
self
.
_p
ortal
()
self
.
_setupUserFolder
()
self
.
_setupUserFolder
()
self
.
_setupUser
()
self
.
_setupUser
()
acl_user
=
self
.
portal
.
acl_users
.
getUserById
(
user_name
)
acl_user
=
self
.
portal
.
acl_users
.
getUserById
(
user_name
)
...
@@ -135,7 +144,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
...
@@ -135,7 +144,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
def
test_setupHomeFolder
(
self
):
def
test_setupHomeFolder
(
self
):
# User's home folder should be set up
# User's home folder should be set up
self
.
app
=
self
.
_app
()
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
getP
ortal
()
self
.
portal
=
self
.
_p
ortal
()
self
.
_setupUserFolder
()
self
.
_setupUserFolder
()
self
.
_setupUser
()
self
.
_setupUser
()
self
.
login
()
self
.
login
()
...
@@ -151,14 +160,14 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
...
@@ -151,14 +160,14 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
def
test_refreshSkinData
(
self
):
def
test_refreshSkinData
(
self
):
# The skin cache should be refreshed
# The skin cache should be refreshed
self
.
app
=
self
.
_app
()
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
getP
ortal
()
self
.
portal
=
self
.
_p
ortal
()
self
.
_refreshSkinData
()
self
.
_refreshSkinData
()
self
.
assertEqual
(
self
.
portal
.
_called
,
[
'clearCurrentSkin'
,
'setupCurrentSkin'
])
self
.
assertEqual
(
self
.
portal
.
_called
,
[
'clearCurrentSkin'
,
'setupCurrentSkin'
])
def
test_setRoles
(
self
):
def
test_setRoles
(
self
):
# Roles should be set for user
# Roles should be set for user
self
.
app
=
self
.
_app
()
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
getP
ortal
()
self
.
portal
=
self
.
_p
ortal
()
self
.
_setupUserFolder
()
self
.
_setupUserFolder
()
self
.
_setupUser
()
self
.
_setupUser
()
test_roles
=
[
'Manager'
,
'Member'
]
test_roles
=
[
'Manager'
,
'Member'
]
...
@@ -169,7 +178,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
...
@@ -169,7 +178,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
def
test_setRoles_2
(
self
):
def
test_setRoles_2
(
self
):
# Roles should be set for logged in user
# Roles should be set for logged in user
self
.
app
=
self
.
_app
()
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
getP
ortal
()
self
.
portal
=
self
.
_p
ortal
()
self
.
_setupUserFolder
()
self
.
_setupUserFolder
()
self
.
_setupUser
()
self
.
_setupUser
()
self
.
login
()
self
.
login
()
...
@@ -181,7 +190,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
...
@@ -181,7 +190,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
def
test_setRoles_3
(
self
):
def
test_setRoles_3
(
self
):
# Roles should be set for a specified user
# Roles should be set for a specified user
self
.
app
=
self
.
_app
()
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
getP
ortal
()
self
.
portal
=
self
.
_p
ortal
()
self
.
_setupUserFolder
()
self
.
_setupUserFolder
()
self
.
portal
.
acl_users
.
userFolderAddUser
(
'user_2'
,
'secret'
,
[],
[])
self
.
portal
.
acl_users
.
userFolderAddUser
(
'user_2'
,
'secret'
,
[],
[])
test_roles
=
[
'Manager'
,
'Member'
]
test_roles
=
[
'Manager'
,
'Member'
]
...
@@ -192,7 +201,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
...
@@ -192,7 +201,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
def
test_setRoles_4
(
self
):
def
test_setRoles_4
(
self
):
# Roles should be set from a tuple
# Roles should be set from a tuple
self
.
app
=
self
.
_app
()
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
getP
ortal
()
self
.
portal
=
self
.
_p
ortal
()
self
.
_setupUserFolder
()
self
.
_setupUserFolder
()
self
.
_setupUser
()
self
.
_setupUser
()
test_roles
=
[
'Manager'
,
'Member'
]
test_roles
=
[
'Manager'
,
'Member'
]
...
@@ -203,7 +212,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
...
@@ -203,7 +212,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
def
test_setRoles_5
(
self
):
def
test_setRoles_5
(
self
):
# Roles should be set from a string
# Roles should be set from a string
self
.
app
=
self
.
_app
()
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
getP
ortal
()
self
.
portal
=
self
.
_p
ortal
()
self
.
_setupUserFolder
()
self
.
_setupUserFolder
()
self
.
_setupUser
()
self
.
_setupUser
()
test_roles
=
[
'Manager'
]
test_roles
=
[
'Manager'
]
...
@@ -214,7 +223,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
...
@@ -214,7 +223,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
def
test_setPermissions
(
self
):
def
test_setPermissions
(
self
):
# Permissions should be set for user
# Permissions should be set for user
self
.
app
=
self
.
_app
()
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
getP
ortal
()
self
.
portal
=
self
.
_p
ortal
()
test_perms
=
[
'Add Folders'
,
'Delete objects'
]
test_perms
=
[
'Add Folders'
,
'Delete objects'
]
self
.
setPermissions
(
test_perms
)
self
.
setPermissions
(
test_perms
)
self
.
assertPermissionsOfRole
(
test_perms
,
'Member'
)
self
.
assertPermissionsOfRole
(
test_perms
,
'Member'
)
...
@@ -222,7 +231,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
...
@@ -222,7 +231,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
def
test_setPermissions_2
(
self
):
def
test_setPermissions_2
(
self
):
# Permissions should be set for specified role
# Permissions should be set for specified role
self
.
app
=
self
.
_app
()
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
getP
ortal
()
self
.
portal
=
self
.
_p
ortal
()
self
.
portal
.
_addRole
(
'role_2'
)
self
.
portal
.
_addRole
(
'role_2'
)
test_perms
=
[
'Add Folders'
,
'Delete objects'
]
test_perms
=
[
'Add Folders'
,
'Delete objects'
]
self
.
assertPermissionsOfRole
([],
'role_2'
)
self
.
assertPermissionsOfRole
([],
'role_2'
)
...
@@ -232,7 +241,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
...
@@ -232,7 +241,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
def
test_setPermissions_3
(
self
):
def
test_setPermissions_3
(
self
):
# Permissions should be set from a tuple
# Permissions should be set from a tuple
self
.
app
=
self
.
_app
()
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
getP
ortal
()
self
.
portal
=
self
.
_p
ortal
()
test_perms
=
[
'Add Folders'
,
'Delete objects'
]
test_perms
=
[
'Add Folders'
,
'Delete objects'
]
self
.
setPermissions
(
tuple
(
test_perms
))
self
.
setPermissions
(
tuple
(
test_perms
))
self
.
assertPermissionsOfRole
(
test_perms
,
'Member'
)
self
.
assertPermissionsOfRole
(
test_perms
,
'Member'
)
...
@@ -240,7 +249,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
...
@@ -240,7 +249,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
def
test_setPermissions_4
(
self
):
def
test_setPermissions_4
(
self
):
# Permissions should be set from a string
# Permissions should be set from a string
self
.
app
=
self
.
_app
()
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
getP
ortal
()
self
.
portal
=
self
.
_p
ortal
()
test_perms
=
[
'Add Folders'
]
test_perms
=
[
'Add Folders'
]
self
.
setPermissions
(
'Add Folders'
)
self
.
setPermissions
(
'Add Folders'
)
self
.
assertPermissionsOfRole
(
test_perms
,
'Member'
)
self
.
assertPermissionsOfRole
(
test_perms
,
'Member'
)
...
@@ -248,7 +257,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
...
@@ -248,7 +257,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
def
test_login
(
self
):
def
test_login
(
self
):
# User should be able to log in
# User should be able to log in
self
.
app
=
self
.
_app
()
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
getP
ortal
()
self
.
portal
=
self
.
_p
ortal
()
self
.
_setupUserFolder
()
self
.
_setupUserFolder
()
self
.
_setupUser
()
self
.
_setupUser
()
auth_name
=
getSecurityManager
().
getUser
().
getUserName
()
auth_name
=
getSecurityManager
().
getUser
().
getUserName
()
...
@@ -260,7 +269,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
...
@@ -260,7 +269,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
def
test_login_2
(
self
):
def
test_login_2
(
self
):
# A specified user should be logged in
# A specified user should be logged in
self
.
app
=
self
.
_app
()
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
getP
ortal
()
self
.
portal
=
self
.
_p
ortal
()
self
.
_setupUserFolder
()
self
.
_setupUserFolder
()
self
.
portal
.
acl_users
.
userFolderAddUser
(
'user_2'
,
'secret'
,
[],
[])
self
.
portal
.
acl_users
.
userFolderAddUser
(
'user_2'
,
'secret'
,
[],
[])
auth_name
=
getSecurityManager
().
getUser
().
getUserName
()
auth_name
=
getSecurityManager
().
getUser
().
getUserName
()
...
@@ -272,14 +281,14 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
...
@@ -272,14 +281,14 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
def
test_login_3
(
self
):
def
test_login_3
(
self
):
# Unknown user should raise AttributeError
# Unknown user should raise AttributeError
self
.
app
=
self
.
_app
()
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
getP
ortal
()
self
.
portal
=
self
.
_p
ortal
()
self
.
_setupUserFolder
()
self
.
_setupUserFolder
()
self
.
assertRaises
(
AttributeError
,
self
.
login
,
'user_3'
)
self
.
assertRaises
(
AttributeError
,
self
.
login
,
'user_3'
)
def
test_logout
(
self
):
def
test_logout
(
self
):
# User should be able to log out
# User should be able to log out
self
.
app
=
self
.
_app
()
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
getP
ortal
()
self
.
portal
=
self
.
_p
ortal
()
self
.
_setupUserFolder
()
self
.
_setupUserFolder
()
self
.
_setupUser
()
self
.
_setupUser
()
self
.
login
()
self
.
login
()
...
@@ -290,7 +299,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
...
@@ -290,7 +299,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
def
test_clear
(
self
):
def
test_clear
(
self
):
# Everything should be removed
# Everything should be removed
self
.
app
=
self
.
_app
()
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
getP
ortal
()
self
.
portal
=
self
.
_p
ortal
()
self
.
_setupUserFolder
()
self
.
_setupUserFolder
()
self
.
_setupUser
()
self
.
_setupUser
()
self
.
_setupHomeFolder
()
self
.
_setupHomeFolder
()
...
@@ -343,6 +352,30 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
...
@@ -343,6 +352,30 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
#self.assertEqual(self._called, ['afterClear', 'beforeSetUp', 'afterSetUp'])
#self.assertEqual(self._called, ['afterClear', 'beforeSetUp', 'afterSetUp'])
self
.
assertEqual
(
self
.
_called
,
[
'beforeSetUp'
,
'afterSetUp'
])
self
.
assertEqual
(
self
.
_called
,
[
'beforeSetUp'
,
'afterSetUp'
])
def
test_createMemberarea
(
self
):
# Should call the membership tool's createMemberarea
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
_portal
()
self
.
_setupUserFolder
()
self
.
_setupUser
()
self
.
login
()
self
.
createMemberarea
(
user_name
)
self
.
assertEqual
(
self
.
portal
.
portal_membership
.
_called
,
[
'createMemberarea'
])
self
.
failUnless
(
hasattr_
(
self
.
portal
.
Members
,
user_name
))
def
test_createMemberarea_NewTool
(
self
):
# Should call the membership tool's createMemberArea
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
_portal
()
self
.
_setupUserFolder
()
self
.
_setupUser
()
self
.
portal
.
_delObject
(
'portal_membership'
)
self
.
portal
.
_setObject
(
'portal_membership'
,
NewMembershipTool
())
self
.
login
()
self
.
createMemberarea
(
user_name
)
self
.
assertEqual
(
self
.
portal
.
portal_membership
.
_called
,
[
'createMemberArea'
])
self
.
failUnless
(
hasattr_
(
self
.
portal
.
Members
,
user_name
))
# Helpers
# Helpers
def
getPermissionsOfRole
(
self
,
role
,
context
=
None
):
def
getPermissionsOfRole
(
self
,
role
,
context
=
None
):
...
...
lib/python/Testing/ZopeTestCase/testPythonScript.py
View file @
1239c640
...
@@ -30,11 +30,12 @@ if __name__ == '__main__':
...
@@ -30,11 +30,12 @@ if __name__ == '__main__':
execfile
(
os
.
path
.
join
(
sys
.
path
[
0
],
'framework.py'
))
execfile
(
os
.
path
.
join
(
sys
.
path
[
0
],
'framework.py'
))
from
Testing
import
ZopeTestCase
from
Testing
import
ZopeTestCase
from
AccessControl
import
Unauthorized
from
AccessControl
import
getSecurityManager
ZopeTestCase
.
installProduct
(
'PythonScripts'
)
ZopeTestCase
.
installProduct
(
'PythonScripts'
)
from
AccessControl
import
Unauthorized
from
AccessControl
import
getSecurityManager
access_permissions
=
[
'View management screens'
]
access_permissions
=
[
'View management screens'
]
change_permissions
=
[
'Change Python Scripts'
]
change_permissions
=
[
'Change Python Scripts'
]
...
...
lib/python/Testing/ZopeTestCase/testWebserver.py
View file @
1239c640
...
@@ -26,7 +26,7 @@ need to URL-call back into the Zope server.
...
@@ -26,7 +26,7 @@ need to URL-call back into the Zope server.
If you want to write functional unit tests, see the testFunctional.py
If you want to write functional unit tests, see the testFunctional.py
example instead.
example instead.
$Id
: testWebserver.py,v 1.16 2005/02/12 13:11:10 shh42 Exp
$
$Id$
"""
"""
import
os
,
sys
import
os
,
sys
...
@@ -38,11 +38,10 @@ if __name__ == '__main__':
...
@@ -38,11 +38,10 @@ if __name__ == '__main__':
from
Testing
import
ZopeTestCase
from
Testing
import
ZopeTestCase
from
Testing.ZopeTestCase
import
transaction
from
AccessControl
import
Unauthorized
from
AccessControl
import
Unauthorized
import
urllib
import
urllib
import
transaction
# Create the error_log object
# Create the error_log object
ZopeTestCase
.
utils
.
setupSiteErrorLog
()
ZopeTestCase
.
utils
.
setupSiteErrorLog
()
...
...
lib/python/Testing/ZopeTestCase/testZopeTestCase.py
View file @
1239c640
...
@@ -28,17 +28,17 @@ if __name__ == '__main__':
...
@@ -28,17 +28,17 @@ if __name__ == '__main__':
from
Testing
import
ZopeTestCase
from
Testing
import
ZopeTestCase
from
Testing.ZopeTestCase
import
folder_name
from
Testing.ZopeTestCase
import
user_name
from
Testing.ZopeTestCase
import
user_role
from
Testing.ZopeTestCase
import
standard_permissions
from
Acquisition
import
aq_base
from
Acquisition
import
aq_base
from
AccessControl
import
getSecurityManager
from
AccessControl
import
getSecurityManager
from
types
import
ListType
from
types
import
ListType
import
transaction
import
transaction
folder_name
=
ZopeTestCase
.
folder_name
user_name
=
ZopeTestCase
.
user_name
user_role
=
ZopeTestCase
.
user_role
standard_permissions
=
ZopeTestCase
.
standard_permissions
def
hasattr_
(
ob
,
attr
):
def
hasattr_
(
ob
,
attr
):
return
hasattr
(
aq_base
(
ob
),
attr
)
return
hasattr
(
aq_base
(
ob
),
attr
)
...
...
lib/python/Testing/ZopeTestCase/utils.py
View file @
1239c640
...
@@ -136,6 +136,7 @@ def makerequest(app, stdout=sys.stdout):
...
@@ -136,6 +136,7 @@ def makerequest(app, stdout=sys.stdout):
environ
[
'REQUEST_METHOD'
]
=
'GET'
environ
[
'REQUEST_METHOD'
]
=
'GET'
request
=
Request
(
sys
.
stdin
,
environ
,
response
)
request
=
Request
(
sys
.
stdin
,
environ
,
response
)
request
.
_steps
=
[
'noobject'
]
# Fake a published object
request
.
_steps
=
[
'noobject'
]
# Fake a published object
request
[
'ACTUAL_URL'
]
=
request
.
get
(
'URL'
)
# Zope 2.7.4
return
app
.
__of__
(
RequestContainer
(
REQUEST
=
request
))
return
app
.
__of__
(
RequestContainer
(
REQUEST
=
request
))
...
...
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