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
15c8dbc0
Commit
15c8dbc0
authored
May 20, 2010
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add unit tests for AccessRule's current behavior.
parent
2d116d62
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
80 additions
and
0 deletions
+80
-0
src/Products/SiteAccess/tests/testAccessRule.py
src/Products/SiteAccess/tests/testAccessRule.py
+80
-0
No files found.
src/Products/SiteAccess/tests/testAccessRule.py
0 → 100644
View file @
15c8dbc0
import
unittest
class
AccessRuleTests
(
unittest
.
TestCase
):
_old_SAR
=
None
def
setUp
(
self
):
from
Testing.ZopeTestCase
import
ZopeLite
ZopeLite
.
startup
()
def
tearDown
(
self
):
if
self
.
_old_SAR
is
not
None
:
self
.
_set_SUPPRESS_ACCESSRULE
(
self
.
_old_SAR
)
def
_set_SUPPRESS_ACCESSRULE
(
self
,
value
):
from
Products.SiteAccess
import
AccessRule
as
AR
(
self
.
_old_SAR
,
AR
.
SUPPRESS_ACCESSRULE
)
=
(
AR
.
SUPPRESS_ACCESSRULE
,
value
)
def
_getTargetClass
(
self
):
from
Products.SiteAccess.AccessRule
import
AccessRule
return
AccessRule
def
_makeOne
(
self
,
method_id
=
'testing'
):
return
self
.
_getTargetClass
()(
method_id
)
def
test___call___w_SUPPRESS_ACCESSRULE_set
(
self
):
self
.
_set_SUPPRESS_ACCESSRULE
(
1
)
_called
=
[]
def
_func
(
*
args
):
_called
.
append
(
args
)
rule
=
self
.
_makeOne
()
request
=
DummyRequest
(
TraversalRequestNameStack
=
[])
container
=
DummyContainer
(
testing
=
_func
)
rule
(
container
,
request
)
self
.
failIf
(
_called
)
def
test___call___w_SUPPRESS_ACCESSRULE_in_URL
(
self
):
# This behavior will change once we land lp:142878.
_called
=
[]
def
_func
(
*
args
):
_called
.
append
(
args
)
rule
=
self
.
_makeOne
()
request
=
DummyRequest
(
TraversalRequestNameStack
=
[
'_SUPPRESS_ACCESSRULE'
])
request
.
steps
=
[]
container
=
DummyContainer
(
testing
=
_func
)
rule
(
container
,
request
)
self
.
failIf
(
_called
)
self
.
assertEqual
(
request
.
_virtual_root
,
[
'_SUPPRESS_ACCESSRULE'
])
def
test___call___wo_SUPPRESS_ACCESSRULE
(
self
):
_called
=
[]
def
_func
(
*
args
):
_called
.
append
(
args
)
rule
=
self
.
_makeOne
()
request
=
DummyRequest
(
TraversalRequestNameStack
=
[])
request
.
steps
=
[]
container
=
DummyContainer
(
testing
=
_func
)
rule
(
container
,
request
)
self
.
failUnless
(
_called
)
self
.
assertEqual
(
request
.
_virtual_root
,
None
)
class
DummyRequest
(
dict
):
_virtual_root
=
None
def
setVirtualRoot
(
self
,
root
):
self
.
_virtual_root
=
root
class
DummyContainer
(
object
):
def
__init__
(
self
,
**
kw
):
self
.
__dict__
.
update
(
kw
)
def
test_suite
():
return
unittest
.
TestSuite
((
unittest
.
makeSuite
(
AccessRuleTests
),
))
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