Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Laurent S
erp5
Commits
f175a3b6
Commit
f175a3b6
authored
May 23, 2016
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testERP5Web: test that traversal hooks are automatically cleanedup
parent
c441db2c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
product/ERP5/tests/testERP5Web.py
product/ERP5/tests/testERP5Web.py
+30
-0
No files found.
product/ERP5/tests/testERP5Web.py
View file @
f175a3b6
...
@@ -43,6 +43,10 @@ HTTP_OK = 200
...
@@ -43,6 +43,10 @@ HTTP_OK = 200
MOVED_TEMPORARILY
=
302
MOVED_TEMPORARILY
=
302
class
DummyTraversalHook
(
object
):
def
__call__
(
self
,
container
,
request
):
return
class
WebTraversalHookTestMixin
(
object
):
class
WebTraversalHookTestMixin
(
object
):
"""Mixin class to test the WebSiteTraversalHook on both websection and website.
"""Mixin class to test the WebSiteTraversalHook on both websection and website.
"""
"""
...
@@ -70,6 +74,32 @@ class WebTraversalHookTestMixin(object):
...
@@ -70,6 +74,32 @@ class WebTraversalHookTestMixin(object):
self
.
web_section
.
setId
(
"new_id"
)
self
.
web_section
.
setId
(
"new_id"
)
self
.
assertEquals
(
1
,
len
(
self
.
web_section
.
__before_traverse__
))
self
.
assertEquals
(
1
,
len
(
self
.
web_section
.
__before_traverse__
))
def
test_TraversalHook_cleanup_on_edit
(
self
):
"""Old traversal hooks from cloned objects are automatically cleaned up
when section is edited.
"""
# artificially put this websection in a similar state that websection were before
# we fix the bug keeping traversal hooks on clone.
from
ZPublisher
import
BeforeTraverse
handle
=
'%s/different_id_than_%s'
%
(
self
.
web_section
.
meta_type
,
self
.
web_section
.
getId
())
BeforeTraverse
.
registerBeforeTraverse
(
self
.
web_section
,
self
.
traversal_hook_class
(),
handle
)
BeforeTraverse
.
registerBeforeTraverse
(
self
.
web_section
,
DummyTraversalHook
(),
'unrelated_traversal_hook_that_should_be_kept'
)
self
.
assertEquals
(
3
,
len
(
self
.
web_section
.
__before_traverse__
))
self
.
tic
()
self
.
web_section
.
edit
(
title
=
self
.
id
())
# We have cleaned up the useless before traversal hook, but keep the unrelated one
self
.
assertEquals
(
2
,
len
(
self
.
web_section
.
__before_traverse__
))
self
.
assertEquals
(
1
,
len
([
hook
for
hook
in
self
.
web_section
.
__before_traverse__
.
values
()
if
isinstance
(
hook
,
self
.
traversal_hook_class
)]))
self
.
assertEquals
(
1
,
len
([
hook
for
hook
in
self
.
web_section
.
__before_traverse__
.
values
()
if
isinstance
(
hook
,
DummyTraversalHook
)]))
class
TestWebSiteTraversalHook
(
WebTraversalHookTestMixin
,
ERP5TypeTestCase
):
class
TestWebSiteTraversalHook
(
WebTraversalHookTestMixin
,
ERP5TypeTestCase
):
def
afterSetUp
(
self
):
def
afterSetUp
(
self
):
super
(
TestWebSiteTraversalHook
,
self
).
afterSetUp
()
super
(
TestWebSiteTraversalHook
,
self
).
afterSetUp
()
...
...
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