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
0e66321c
Commit
0e66321c
authored
May 08, 2005
by
Stefan H. Holek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Spring cleaning! Improved docstrings, removed cruft, and added a ClassDiagram.pdf.
No functional changes.
parent
116b49f3
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
47 additions
and
120 deletions
+47
-120
lib/python/Testing/ZopeTestCase/ZopeTestCase.py
lib/python/Testing/ZopeTestCase/ZopeTestCase.py
+5
-1
lib/python/Testing/ZopeTestCase/doc/ClassDiagram.pdf
lib/python/Testing/ZopeTestCase/doc/ClassDiagram.pdf
+0
-0
lib/python/Testing/ZopeTestCase/functional.py
lib/python/Testing/ZopeTestCase/functional.py
+2
-2
lib/python/Testing/ZopeTestCase/interfaces.py
lib/python/Testing/ZopeTestCase/interfaces.py
+2
-6
lib/python/Testing/ZopeTestCase/testFunctional.py
lib/python/Testing/ZopeTestCase/testFunctional.py
+4
-1
lib/python/Testing/ZopeTestCase/testPortalTestCase.py
lib/python/Testing/ZopeTestCase/testPortalTestCase.py
+0
-38
lib/python/Testing/ZopeTestCase/testPythonScript.py
lib/python/Testing/ZopeTestCase/testPythonScript.py
+26
-24
lib/python/Testing/ZopeTestCase/testShoppingCart.py
lib/python/Testing/ZopeTestCase/testShoppingCart.py
+2
-2
lib/python/Testing/ZopeTestCase/testZODBCompat.py
lib/python/Testing/ZopeTestCase/testZODBCompat.py
+4
-4
lib/python/Testing/ZopeTestCase/testZopeTestCase.py
lib/python/Testing/ZopeTestCase/testZopeTestCase.py
+1
-39
lib/python/Testing/ZopeTestCase/zopedoctest/__init__.py
lib/python/Testing/ZopeTestCase/zopedoctest/__init__.py
+1
-3
No files found.
lib/python/Testing/ZopeTestCase/ZopeTestCase.py
View file @
0e66321c
...
...
@@ -114,7 +114,11 @@ class ZopeTestCase(base.TestCase):
class
FunctionalTestCase
(
functional
.
Functional
,
ZopeTestCase
):
'''Base class for functional Zope tests'''
'''Convenience base class for functional Zope tests
You can mix-in Functional with every xTestCase
to turn it into a functional test case.
'''
__implements__
=
(
functional
.
Functional
.
__implements__
,
ZopeTestCase
.
__implements__
)
...
...
lib/python/Testing/ZopeTestCase/doc/ClassDiagram.pdf
0 → 100644
View file @
0e66321c
File added
lib/python/Testing/ZopeTestCase/functional.py
View file @
0e66321c
...
...
@@ -12,9 +12,9 @@
##############################################################################
"""Support for functional unit testing in ZTC
After Marius Gedminas' functional.py module for Zope
3.
After Marius Gedminas' functional.py module for Zope3.
$Id
: functional.py,v 1.3 2004/09/12 16:49:59 shh42 Exp
$
$Id$
"""
import
sys
,
re
,
base64
...
...
lib/python/Testing/ZopeTestCase/interfaces.py
View file @
0e66321c
...
...
@@ -12,14 +12,10 @@
##############################################################################
"""ZopeTestCase interfaces
$Id
: interfaces.py,v 1.5 2005/02/07 21:59:35 shh42 Exp
$
$Id$
"""
try
:
from
Interface
import
Interface
except
ImportError
:
# Old interface package
from
Interface
import
Base
as
Interface
from
Interface
import
Interface
class
IZopeTestCase
(
Interface
):
...
...
lib/python/Testing/ZopeTestCase/testFunctional.py
View file @
0e66321c
...
...
@@ -12,7 +12,10 @@
##############################################################################
"""Example functional ZopeTestCase
$Id: testFunctional.py,v 1.16 2005/02/12 13:13:04 shh42 Exp $
Demonstrates how to use the publish() API to execute GET, POST, PUT, etc.
requests against the ZPublisher and how to examine the response.
$Id$
"""
import
os
,
sys
...
...
lib/python/Testing/ZopeTestCase/testPortalTestCase.py
View file @
0e66321c
...
...
@@ -343,44 +343,6 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
#self.assertEqual(self._called, ['afterClear', 'beforeSetUp', 'afterSetUp'])
self
.
assertEqual
(
self
.
_called
,
[
'beforeSetUp'
,
'afterSetUp'
])
# This is crazy
def
__test_crazyRoles_0
(
self
):
# Permission assignments should be reset
self
.
app
=
self
.
_app
()
perms
=
self
.
getPermissionsOfRole
(
'Anonymous'
,
self
.
app
)
for
perm
in
[
'Access contents information'
,
'View'
,
'Query Vocabulary'
,
'Search ZCatalog'
]:
if
perm
not
in
perms
:
self
.
fail
(
'Expected permission "%s"'
%
perm
)
def
__test_crazyRoles_1
(
self
):
# Permission assignments should be reset
self
.
app
=
self
.
_app
()
self
.
app
.
manage_role
(
'Anonymous'
,
[
'View'
])
self
.
assertPermissionsOfRole
([
'View'
],
'Anonymous'
,
self
.
app
)
self
.
failIf
(
getSecurityManager
().
checkPermission
(
'Access contents information'
,
self
.
app
))
def
__test_crazyRoles_2
(
self
):
# Permission assignments should be reset
self
.
app
=
self
.
_app
()
try
:
self
.
assertPermissionsOfRole
([
'View'
],
'Anonymous'
,
self
.
app
)
except
self
.
failureException
:
pass
def
__test_crazyRoles_3
(
self
):
# Permission assignments should be reset
self
.
app
=
self
.
_app
()
self
.
failUnless
(
getSecurityManager
().
checkPermission
(
'Access contents information'
,
self
.
app
))
def
__test_crazyRoles_4
(
self
):
# Permission assignments should be reset
self
.
app
=
self
.
_app
()
perms
=
self
.
getPermissionsOfRole
(
'Anonymous'
,
self
.
app
)
for
perm
in
[
'Access contents information'
,
'View'
,
'Query Vocabulary'
,
'Search ZCatalog'
]:
if
perm
not
in
perms
:
self
.
fail
(
'Expected permission "%s"'
%
perm
)
# Helpers
def
getPermissionsOfRole
(
self
,
role
,
context
=
None
):
...
...
lib/python/Testing/ZopeTestCase/testPythonScript.py
View file @
0e66321c
...
...
@@ -10,17 +10,19 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Example ZopeTestCase testing a PythonScript
object
in the default fixture
"""Example ZopeTestCase testing a PythonScript in the default fixture
Note that you are encouraged to call any of the following methods
from your own tests to modify the test user's security credentials:
This test module demonstrates the security API of ZopeTestCase.
- setRoles()
- setPermissions()
- login()
- logout()
Note that you are encouraged to call any of the following methods to
modify the test user's security credentials:
$Id: testPythonScript.py,v 1.9 2004/04/09 12:38:37 shh42 Exp $
setRoles()
setPermissions()
login()
logout()
$Id$
"""
import
os
,
sys
...
...
@@ -52,9 +54,9 @@ class TestPythonScript(ZopeTestCase.ZopeTestCase):
self
.
ps
=
self
.
folder
[
'ps'
]
self
.
ps
.
ZPythonScript_edit
(
ps_params1
,
ps_body1
)
# Test the
fixture ##############################################
# Test the
setup
def
test
Fixture
(
self
):
def
test
Setup
(
self
):
# The PythonScript should exist and be properly set up
self
.
failUnless
(
hasattr
(
self
.
folder
,
'ps'
))
self
.
assertEqual
(
self
.
ps
.
body
(),
ps_body1
+
'
\
n
'
)
...
...
@@ -62,7 +64,7 @@ class TestPythonScript(ZopeTestCase.ZopeTestCase):
owner
=
self
.
ps
.
getOwner
()
self
.
assertEqual
(
owner
.
getUserName
(),
ZopeTestCase
.
user_name
)
# Test the script
s ##############################################
# Test the script
(s)
def
testCanCallScript1WithArgument
(
self
):
# PythonScript should return 2
...
...
@@ -78,18 +80,18 @@ class TestPythonScript(ZopeTestCase.ZopeTestCase):
self
.
assertEqual
(
self
.
ps
(
1
),
2
)
def
testCannotCallScript2WithoutArgument
(
self
):
# PythonScript should raise a TypeError
# PythonScript should raise a TypeError
if called without arguments
self
.
ps
.
ZPythonScript_edit
(
ps_params2
,
ps_body2
)
self
.
assertRaises
(
TypeError
,
self
.
ps
,
())
# Test access protection
########################################
# Test access protection
with restrictedTraverse
def
testCannotAccessWithoutAccessPermission
(
self
):
# manage_main should be protected
self
.
assertRaises
(
Unauthorized
,
self
.
ps
.
restrictedTraverse
,
'manage_main'
)
def
testCanAccessWithAccessPermission
(
self
):
# manage_main should be accessible
# manage_main should be accessible
if we have the necessary permissions
self
.
setPermissions
(
access_permissions
)
try
:
self
.
ps
.
restrictedTraverse
(
'manage_main'
)
...
...
@@ -97,26 +99,26 @@ class TestPythonScript(ZopeTestCase.ZopeTestCase):
self
.
fail
(
'Access to manage_main was denied'
)
def
testCannotAccessIfAnonymous
(
self
):
# manage_main should be protected
# manage_main should be protected
from Anonymous
self
.
logout
()
self
.
assertRaises
(
Unauthorized
,
self
.
ps
.
restrictedTraverse
,
'manage_main'
)
def
testCanAccessIfManager
(
self
):
# manage_main should be accessible to Manager
s
# manage_main should be accessible to Manager
self
.
setRoles
([
'Manager'
])
try
:
self
.
ps
.
restrictedTraverse
(
'manage_main'
)
except
Unauthorized
:
self
.
fail
(
'Access to manage_main was denied to Manager'
)
# Test access protection with SecurityManager
###################
# Test access protection with SecurityManager
def
testCannotAccessWithoutAccessPermissionSecurityManager
(
self
):
# manage_main should be protected
self
.
assertRaises
(
Unauthorized
,
getSecurityManager
().
validateValue
,
self
.
ps
.
manage_main
)
def
testCanAccessWithAccessPermissionSecurityManager
(
self
):
# manage_main should be accessible
# manage_main should be accessible
if we have the necessary permissions
self
.
setPermissions
(
access_permissions
)
try
:
getSecurityManager
().
validateValue
(
self
.
ps
.
manage_main
)
...
...
@@ -124,19 +126,19 @@ class TestPythonScript(ZopeTestCase.ZopeTestCase):
self
.
fail
(
'Access to manage_main was denied'
)
def
testCannotAccessIfAnonymousSecurityManager
(
self
):
# manage_main should be protected
# manage_main should be protected
from Anonymous
self
.
logout
()
self
.
assertRaises
(
Unauthorized
,
getSecurityManager
().
validateValue
,
self
.
ps
.
manage_main
)
def
testCanAccessIfManagerSecurityManager
(
self
):
# manage_main should be accessible to Manager
s
# manage_main should be accessible to Manager
self
.
setRoles
([
'Manager'
])
try
:
getSecurityManager
().
validateValue
(
self
.
ps
.
manage_main
)
except
Unauthorized
:
self
.
fail
(
'Access to manage_main was denied to Manager'
)
# Test edit protection
##########################################
# Test edit protection
with restrictedTraverse
def
testCannotEditWithoutChangePermission
(
self
):
# PythonScript should not be editable
...
...
@@ -151,7 +153,7 @@ class TestPythonScript(ZopeTestCase.ZopeTestCase):
'ZPythonScript_edit was protected but no exception was raised'
)
def
testCanEditWithChangePermission
(
self
):
# PythonScript should be editable
# PythonScript should be editable
if we have the necessary permissions
self
.
setPermissions
(
change_permissions
)
try
:
self
.
ps
.
restrictedTraverse
(
'ZPythonScript_edit'
)(
ps_params2
,
ps_body2
)
...
...
@@ -162,7 +164,7 @@ class TestPythonScript(ZopeTestCase.ZopeTestCase):
self
.
assertEqual
(
self
.
ps
.
params
(),
ps_params2
)
def
testCannotEditIfAnonymous
(
self
):
# PythonScript should not be editable
# PythonScript should not be editable
by Anonymous
self
.
logout
()
try
:
self
.
ps
.
restrictedTraverse
(
'ZPythonScript_edit'
)(
ps_params2
,
ps_body2
)
...
...
@@ -175,7 +177,7 @@ class TestPythonScript(ZopeTestCase.ZopeTestCase):
'ZPythonScript_edit was protected but no exception was raised'
)
def
testCanEditIfManager
(
self
):
# PythonScript should be editable
for Managers
# PythonScript should be editable
by Manager
self
.
setRoles
([
'Manager'
])
try
:
self
.
ps
.
restrictedTraverse
(
'ZPythonScript_edit'
)(
ps_params2
,
ps_body2
)
...
...
lib/python/Testing/ZopeTestCase/testShoppingCart.py
View file @
0e66321c
...
...
@@ -10,7 +10,7 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Example ZopeTestCase testing the ShoppingCart example application
.
"""Example ZopeTestCase testing the ShoppingCart example application
Note the use of sessions and how the SESSION object is added to
the REQUEST in afterSetUp().
...
...
@@ -18,7 +18,7 @@ the REQUEST in afterSetUp().
You can use zLOG.LOG() if you set up the event log variables first.
Handy for debugging and tracing your tests.
$Id
: testShoppingCart.py,v 1.11 2005/02/23 17:14:56 shh42 Exp
$
$Id$
"""
import
os
,
sys
...
...
lib/python/Testing/ZopeTestCase/testZODBCompat.py
View file @
0e66321c
...
...
@@ -13,10 +13,10 @@
"""Tests ZODB behavior in ZopeTestCase
Demonstrates that cut/copy/paste/clone/rename and import/export
work i
n ZopeTestCase if a subtransaction is commited before performing
the respective operations
.
work i
f a subtransaction is committed before performing the respective
operation
.
$Id
: testZODBCompat.py,v 1.17 2004/04/09 12:38:37 shh42 Exp
$
$Id$
"""
import
os
,
sys
...
...
lib/python/Testing/ZopeTestCase/testZopeTestCase.py
View file @
0e66321c
...
...
@@ -19,7 +19,7 @@ See testPythonScript.py and testShoppingCart.py for
example test cases. See testSkeleton.py for a quick
way of getting started.
$Id
: testZopeTestCase.py,v 1.25 2005/01/30 14:22:48 shh42 Exp
$
$Id$
"""
import
os
,
sys
...
...
@@ -319,44 +319,6 @@ class TestZopeTestCase(ZopeTestCase.ZopeTestCase):
manager_perms
.
remove
(
'Take ownership'
)
self
.
assertPermissionsOfRole
(
manager_perms
,
'Manager'
)
# This is crazy
def
__test_crazyRoles_0
(
self
):
# Permission assignments should be reset
self
.
app
=
self
.
_app
()
perms
=
self
.
getPermissionsOfRole
(
'Anonymous'
,
self
.
app
)
for
perm
in
[
'Access contents information'
,
'View'
,
'Query Vocabulary'
,
'Search ZCatalog'
]:
if
perm
not
in
perms
:
self
.
fail
(
'Expected permission "%s"'
%
perm
)
def
__test_crazyRoles_1
(
self
):
# Permission assignments should be reset
self
.
app
=
self
.
_app
()
self
.
app
.
manage_role
(
'Anonymous'
,
[
'View'
])
self
.
assertPermissionsOfRole
([
'View'
],
'Anonymous'
,
self
.
app
)
self
.
failIf
(
getSecurityManager
().
checkPermission
(
'Access contents information'
,
self
.
app
))
def
__test_crazyRoles_2
(
self
):
# Permission assignments should be reset
self
.
app
=
self
.
_app
()
try
:
self
.
assertPermissionsOfRole
([
'View'
],
'Anonymous'
,
self
.
app
)
except
self
.
failureException
:
pass
def
__test_crazyRoles_3
(
self
):
# Permission assignments should be reset
self
.
app
=
self
.
_app
()
self
.
failUnless
(
getSecurityManager
().
checkPermission
(
'Access contents information'
,
self
.
app
))
def
__test_crazyRoles_4
(
self
):
# Permission assignments should be reset
self
.
app
=
self
.
_app
()
perms
=
self
.
getPermissionsOfRole
(
'Anonymous'
,
self
.
app
)
for
perm
in
[
'Access contents information'
,
'View'
,
'Query Vocabulary'
,
'Search ZCatalog'
]:
if
perm
not
in
perms
:
self
.
fail
(
'Expected permission "%s"'
%
perm
)
# Helpers
def
getPermissionsOfRole
(
self
,
role
,
context
=
None
):
...
...
lib/python/Testing/ZopeTestCase/zopedoctest/__init__.py
View file @
0e66321c
...
...
@@ -12,11 +12,9 @@
##############################################################################
"""ZopeTestCase doctest support
$Id
: __init__.py,v 1.2 2005/03/26 18:07:08 shh42 Exp
$
$Id$
"""
__version__
=
'0.9.7'
from
zope.testing.doctest
import
*
from
functional
import
*
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