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):
def
_refreshSkinData
(
self
):
'''Refreshes the skin cache.'''
if
hasattr
(
self
.
portal
,
'clearCurrentSkin'
):
if
hasattr
(
aq_base
(
self
.
portal
)
,
'clearCurrentSkin'
):
self
.
portal
.
clearCurrentSkin
()
else
:
# CMF 1.4
self
.
portal
.
_v_skindata
=
None
...
...
@@ -119,6 +119,9 @@ class PortalTestCase(base.TestCase):
or more lightweight version of the memberarea.
'''
pm
=
self
.
portal
.
portal_membership
if
hasattr
(
aq_base
(
pm
),
'createMemberArea'
):
pm
.
createMemberArea
(
name
)
else
:
# CMF 1.4
pm
.
createMemberarea
(
name
)
# Security interface
...
...
lib/python/Testing/ZopeTestCase/ZopeLite.py
View file @
1239c640
...
...
@@ -22,7 +22,7 @@ Typically used as in
Zope2.installProduct('SomeProduct')
app = Zope2.app()
$Id
: ZopeLite.py,v 1.24 2004/08/18 09:28:54 shh42 Exp
$
$Id$
"""
import
os
,
sys
,
time
...
...
@@ -182,6 +182,7 @@ debug = Zope2.debug
DB
=
Zope2
.
DB
configure
=
Zope2
.
configure
def
startup
():
pass
Zope
=
Zope2
# ZODB sandbox factory
from
ZODB.DemoStorage
import
DemoStorage
...
...
lib/python/Testing/ZopeTestCase/__init__.py
View file @
1239c640
...
...
@@ -12,7 +12,7 @@
##############################################################################
"""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
...
...
@@ -33,14 +33,14 @@ from ZopeTestCase import FunctionalTestCase
from
PortalTestCase
import
portal_name
from
PortalTestCase
import
PortalTestCase
from
base
import
TestCase
from
base
import
app
from
base
import
close
from
profiler
import
Profiled
from
sandbox
import
Sandboxed
from
functional
import
Functional
from
base
import
TestCase
from
base
import
app
from
base
import
close
from
ZODB.tests.warnhook
import
WarningsHook
from
unittest
import
main
...
...
@@ -49,3 +49,8 @@ from zopedoctest import ZopeDocFileSuite
from
zopedoctest
import
FunctionalDocTestSuite
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
_print(msg)
ZopeDocTestSuite(module=None, **kw)
ZopeDocFileSuite(*paths, **kw)
FunctionalDocTestSuite(module=None, **kw)
FunctionalDocFileSuite(*paths, **kw)
Classes
TestCase
ZopeTestCase
FunctionalTestCase
PortalTestCase
TestCase
Profiled
Sandboxed
Functional
WarningsHook
Modules
ZopeLite as Zope
utils
doctest
transaction
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
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
suite factories: ZopeDocTestSuite, ZopeDocFileSuite, FunctionalDocTestSuite,
and FunctionalDocFileSuite.
...
...
@@ -10,7 +11,8 @@
- ZopeLite now takes care not to monkey patch an already started Zope.
- PortalTestCase.setUp() no longer calls _refreshSkinData() as CMF is smart
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
connection pool depletion and subsequent hangs. Thanks to Balazs Ree.
- Encapsulated the ConnectionRegistry in its own module, connections.py.
...
...
@@ -19,6 +21,10 @@
to Sidnei da Silva.
- Modified runalltests.py so it imports modules more like test.py, i.e.
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
- 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):
self
.
failIfEqual
(
request
.
get
(
'BASE0'
,
''
),
''
)
self
.
failIfEqual
(
request
.
get
(
'BASE1'
,
''
),
''
)
self
.
failIfEqual
(
request
.
get
(
'BASE2'
,
''
),
''
)
self
.
failIfEqual
(
request
.
get
(
'ACTUAL_URL'
,
''
),
''
)
import
gc
...
...
lib/python/Testing/ZopeTestCase/testPortalTestCase.py
View file @
1239c640
...
...
@@ -61,13 +61,22 @@ class DummyPortal(Folder):
class
DummyMembershipTool
(
SimpleItem
):
id
=
'portal_membership'
def
__init__
(
self
):
self
.
_called
=
[]
def
createMemberarea
(
self
,
member_id
):
self
.
_called
.
append
(
'createMemberarea'
)
portal
=
self
.
aq_inner
.
aq_parent
portal
.
Members
.
manage_addFolder
(
member_id
)
def
getHomeFolder
(
self
,
member_id
):
portal
=
self
.
aq_inner
.
aq_parent
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
):
'''Incrementally exercise the PortalTestCase API.'''
...
...
@@ -105,7 +114,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
def
test_getPortal
(
self
):
# Portal should be set up
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
.
portal
,
'Members'
))
self
.
failUnless
(
hasattr_
(
self
.
portal
,
'portal_membership'
))
...
...
@@ -114,7 +123,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
def
test_setupUserFolder
(
self
):
# User folder should be set up.
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
getP
ortal
()
self
.
portal
=
self
.
_p
ortal
()
self
.
failIf
(
hasattr_
(
self
.
portal
,
'acl_users'
))
self
.
_setupUserFolder
()
self
.
failUnless
(
hasattr_
(
self
.
portal
,
'acl_users'
))
...
...
@@ -124,7 +133,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
def
test_setupUser
(
self
):
# User should be set up
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
getP
ortal
()
self
.
portal
=
self
.
_p
ortal
()
self
.
_setupUserFolder
()
self
.
_setupUser
()
acl_user
=
self
.
portal
.
acl_users
.
getUserById
(
user_name
)
...
...
@@ -135,7 +144,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
def
test_setupHomeFolder
(
self
):
# User's home folder should be set up
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
getP
ortal
()
self
.
portal
=
self
.
_p
ortal
()
self
.
_setupUserFolder
()
self
.
_setupUser
()
self
.
login
()
...
...
@@ -151,14 +160,14 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
def
test_refreshSkinData
(
self
):
# The skin cache should be refreshed
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
getP
ortal
()
self
.
portal
=
self
.
_p
ortal
()
self
.
_refreshSkinData
()
self
.
assertEqual
(
self
.
portal
.
_called
,
[
'clearCurrentSkin'
,
'setupCurrentSkin'
])
def
test_setRoles
(
self
):
# Roles should be set for user
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
getP
ortal
()
self
.
portal
=
self
.
_p
ortal
()
self
.
_setupUserFolder
()
self
.
_setupUser
()
test_roles
=
[
'Manager'
,
'Member'
]
...
...
@@ -169,7 +178,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
def
test_setRoles_2
(
self
):
# Roles should be set for logged in user
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
getP
ortal
()
self
.
portal
=
self
.
_p
ortal
()
self
.
_setupUserFolder
()
self
.
_setupUser
()
self
.
login
()
...
...
@@ -181,7 +190,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
def
test_setRoles_3
(
self
):
# Roles should be set for a specified user
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
getP
ortal
()
self
.
portal
=
self
.
_p
ortal
()
self
.
_setupUserFolder
()
self
.
portal
.
acl_users
.
userFolderAddUser
(
'user_2'
,
'secret'
,
[],
[])
test_roles
=
[
'Manager'
,
'Member'
]
...
...
@@ -192,7 +201,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
def
test_setRoles_4
(
self
):
# Roles should be set from a tuple
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
getP
ortal
()
self
.
portal
=
self
.
_p
ortal
()
self
.
_setupUserFolder
()
self
.
_setupUser
()
test_roles
=
[
'Manager'
,
'Member'
]
...
...
@@ -203,7 +212,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
def
test_setRoles_5
(
self
):
# Roles should be set from a string
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
getP
ortal
()
self
.
portal
=
self
.
_p
ortal
()
self
.
_setupUserFolder
()
self
.
_setupUser
()
test_roles
=
[
'Manager'
]
...
...
@@ -214,7 +223,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
def
test_setPermissions
(
self
):
# Permissions should be set for user
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
getP
ortal
()
self
.
portal
=
self
.
_p
ortal
()
test_perms
=
[
'Add Folders'
,
'Delete objects'
]
self
.
setPermissions
(
test_perms
)
self
.
assertPermissionsOfRole
(
test_perms
,
'Member'
)
...
...
@@ -222,7 +231,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
def
test_setPermissions_2
(
self
):
# Permissions should be set for specified role
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
getP
ortal
()
self
.
portal
=
self
.
_p
ortal
()
self
.
portal
.
_addRole
(
'role_2'
)
test_perms
=
[
'Add Folders'
,
'Delete objects'
]
self
.
assertPermissionsOfRole
([],
'role_2'
)
...
...
@@ -232,7 +241,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
def
test_setPermissions_3
(
self
):
# Permissions should be set from a tuple
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
getP
ortal
()
self
.
portal
=
self
.
_p
ortal
()
test_perms
=
[
'Add Folders'
,
'Delete objects'
]
self
.
setPermissions
(
tuple
(
test_perms
))
self
.
assertPermissionsOfRole
(
test_perms
,
'Member'
)
...
...
@@ -240,7 +249,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
def
test_setPermissions_4
(
self
):
# Permissions should be set from a string
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
getP
ortal
()
self
.
portal
=
self
.
_p
ortal
()
test_perms
=
[
'Add Folders'
]
self
.
setPermissions
(
'Add Folders'
)
self
.
assertPermissionsOfRole
(
test_perms
,
'Member'
)
...
...
@@ -248,7 +257,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
def
test_login
(
self
):
# User should be able to log in
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
getP
ortal
()
self
.
portal
=
self
.
_p
ortal
()
self
.
_setupUserFolder
()
self
.
_setupUser
()
auth_name
=
getSecurityManager
().
getUser
().
getUserName
()
...
...
@@ -260,7 +269,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
def
test_login_2
(
self
):
# A specified user should be logged in
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
getP
ortal
()
self
.
portal
=
self
.
_p
ortal
()
self
.
_setupUserFolder
()
self
.
portal
.
acl_users
.
userFolderAddUser
(
'user_2'
,
'secret'
,
[],
[])
auth_name
=
getSecurityManager
().
getUser
().
getUserName
()
...
...
@@ -272,14 +281,14 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
def
test_login_3
(
self
):
# Unknown user should raise AttributeError
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
getP
ortal
()
self
.
portal
=
self
.
_p
ortal
()
self
.
_setupUserFolder
()
self
.
assertRaises
(
AttributeError
,
self
.
login
,
'user_3'
)
def
test_logout
(
self
):
# User should be able to log out
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
getP
ortal
()
self
.
portal
=
self
.
_p
ortal
()
self
.
_setupUserFolder
()
self
.
_setupUser
()
self
.
login
()
...
...
@@ -290,7 +299,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
def
test_clear
(
self
):
# Everything should be removed
self
.
app
=
self
.
_app
()
self
.
portal
=
self
.
getP
ortal
()
self
.
portal
=
self
.
_p
ortal
()
self
.
_setupUserFolder
()
self
.
_setupUser
()
self
.
_setupHomeFolder
()
...
...
@@ -343,6 +352,30 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
#self.assertEqual(self._called, ['afterClear', '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
def
getPermissionsOfRole
(
self
,
role
,
context
=
None
):
...
...
lib/python/Testing/ZopeTestCase/testPythonScript.py
View file @
1239c640
...
...
@@ -30,11 +30,12 @@ if __name__ == '__main__':
execfile
(
os
.
path
.
join
(
sys
.
path
[
0
],
'framework.py'
))
from
Testing
import
ZopeTestCase
from
AccessControl
import
Unauthorized
from
AccessControl
import
getSecurityManager
ZopeTestCase
.
installProduct
(
'PythonScripts'
)
from
AccessControl
import
Unauthorized
from
AccessControl
import
getSecurityManager
access_permissions
=
[
'View management screens'
]
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.
If you want to write functional unit tests, see the testFunctional.py
example instead.
$Id
: testWebserver.py,v 1.16 2005/02/12 13:11:10 shh42 Exp
$
$Id$
"""
import
os
,
sys
...
...
@@ -38,11 +38,10 @@ if __name__ == '__main__':
from
Testing
import
ZopeTestCase
from
Testing.ZopeTestCase
import
transaction
from
AccessControl
import
Unauthorized
import
urllib
import
transaction
# Create the error_log object
ZopeTestCase
.
utils
.
setupSiteErrorLog
()
...
...
lib/python/Testing/ZopeTestCase/testZopeTestCase.py
View file @
1239c640
...
...
@@ -28,17 +28,17 @@ if __name__ == '__main__':
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
AccessControl
import
getSecurityManager
from
types
import
ListType
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
):
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):
environ
[
'REQUEST_METHOD'
]
=
'GET'
request
=
Request
(
sys
.
stdin
,
environ
,
response
)
request
.
_steps
=
[
'noobject'
]
# Fake a published object
request
[
'ACTUAL_URL'
]
=
request
.
get
(
'URL'
)
# Zope 2.7.4
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