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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
erp5
Commits
1a3d26d1
Commit
1a3d26d1
authored
Aug 24, 2016
by
iv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ERP5Workflow: rename variables + call directly Base_viewDict script
instead of using self.publish()
parent
84a5644f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
60 deletions
+58
-60
product/ERP5Workflow/tests/testERP5Workflow.py
product/ERP5Workflow/tests/testERP5Workflow.py
+58
-60
No files found.
product/ERP5Workflow/tests/testERP5Workflow.py
View file @
1a3d26d1
...
@@ -61,51 +61,51 @@ class TestERP5Workflow(ERP5TypeTestCase):
...
@@ -61,51 +61,51 @@ class TestERP5Workflow(ERP5TypeTestCase):
workflow
.
setReference
(
'wf'
)
workflow
.
setReference
(
'wf'
)
# state variable
# state variable
workflow
.
setStateVariable
(
'current_state'
)
workflow
.
setStateVariable
(
'current_state'
)
s1
=
workflow
.
newContent
(
portal_type
=
'State'
,
s
tate
1
=
workflow
.
newContent
(
portal_type
=
'State'
,
title
=
'State 1'
)
title
=
'State 1'
)
s2
=
workflow
.
newContent
(
portal_type
=
'State'
,
s
tate
2
=
workflow
.
newContent
(
portal_type
=
'State'
,
title
=
'State 2'
)
title
=
'State 2'
)
s
1
.
setReference
(
's
1'
)
s
tate1
.
setReference
(
'state
1'
)
s
2
.
setReference
(
's
2'
)
s
tate2
.
setReference
(
'state
2'
)
t1
=
workflow
.
newContent
(
portal_type
=
'Transition'
,
t
ransition
1
=
workflow
.
newContent
(
portal_type
=
'Transition'
,
title
=
'Transition 1'
)
title
=
'Transition 1'
)
t
1
.
setReference
(
't
1'
)
t
ransition1
.
setReference
(
'transition
1'
)
s
1
.
setDestinationValue
(
t
1
)
s
tate1
.
setDestinationValue
(
transition
1
)
t
1
.
setDestinationValue
(
s
2
)
t
ransition1
.
setDestinationValue
(
state
2
)
# set initial state
# set initial state
workflow
.
setSourceValue
(
s1
)
workflow
.
setSourceValue
(
s
tate
1
)
# create a document and associate it to this workflow
# create a document and associate it to this workflow
self
.
getPortalObject
().
portal_types
.
_getOb
(
'Folder'
)
\
self
.
getPortalObject
().
portal_types
.
_getOb
(
'Folder'
)
\
.
edit
(
type_workflow_list
=
(
'wf'
))
.
edit
(
type_workflow_list
=
(
'wf'
))
doc
=
self
.
portal
.
newContent
(
portal_type
=
'Folder'
,
id
=
'test_doc'
)
doc
=
self
.
portal
.
newContent
(
portal_type
=
'Folder'
,
id
=
'test_doc'
)
self
.
assertEqual
(
's1'
,
workflow
.
_getWorkflowStateOf
(
doc
,
id_only
=
1
))
self
.
assertEqual
(
's
tate
1'
,
workflow
.
_getWorkflowStateOf
(
doc
,
id_only
=
1
))
# pass a transition
# pass a transition
workflow
.
_executeTransition
(
doc
,
t1
)
workflow
.
_executeTransition
(
doc
,
t
ransition
1
)
self
.
assertEqual
(
's2'
,
workflow
.
_getWorkflowStateOf
(
doc
,
id_only
=
1
))
self
.
assertEqual
(
's
tate
2'
,
workflow
.
_getWorkflowStateOf
(
doc
,
id_only
=
1
))
def
test_getAvailableTransitionList
(
self
):
def
test_getAvailableTransitionList
(
self
):
workflow
=
self
.
workflow_module
.
newContent
(
portal_type
=
'Workflow'
)
workflow
=
self
.
workflow_module
.
newContent
(
portal_type
=
'Workflow'
)
workflow
.
setReference
(
'wf'
)
workflow
.
setReference
(
'wf'
)
workflow
.
setStateVariable
(
'current_state'
)
workflow
.
setStateVariable
(
'current_state'
)
s1
=
workflow
.
newContent
(
portal_type
=
'State'
,
s
tate
1
=
workflow
.
newContent
(
portal_type
=
'State'
,
title
=
'State 1'
)
title
=
'State 1'
)
s
1
.
setReference
(
's
1'
)
s
tate1
.
setReference
(
'state
1'
)
workflow
.
setSourceValue
(
s1
)
workflow
.
setSourceValue
(
s
tate
1
)
t1
=
workflow
.
newContent
(
portal_type
=
'Transition'
,
t
ransition
1
=
workflow
.
newContent
(
portal_type
=
'Transition'
,
title
=
'Transition 1'
)
title
=
'Transition 1'
)
t
1
.
setReference
(
't
1'
)
t
ransition1
.
setReference
(
'transition
1'
)
t2
=
workflow
.
newContent
(
portal_type
=
'Transition'
,
t
ransition
2
=
workflow
.
newContent
(
portal_type
=
'Transition'
,
title
=
'Transition 2'
,
title
=
'Transition 2'
,
guard_expression
=
'python: False'
)
guard_expression
=
'python: False'
)
t
2
.
setReference
(
't
2'
)
t
ransition2
.
setReference
(
'transition
2'
)
s
1
.
setDestinationValueList
([
t1
,
t
2
])
s
tate1
.
setDestinationValueList
([
transition1
,
transition
2
])
self
.
getPortalObject
().
portal_types
.
_getOb
(
'Folder'
)
\
self
.
getPortalObject
().
portal_types
.
_getOb
(
'Folder'
)
\
.
edit
(
type_workflow_list
=
(
'wf'
))
.
edit
(
type_workflow_list
=
(
'wf'
))
doc
=
self
.
portal
.
newContent
(
portal_type
=
'Folder'
,
id
=
'test_doc'
)
doc
=
self
.
portal
.
newContent
(
portal_type
=
'Folder'
,
id
=
'test_doc'
)
self
.
assertEqual
([
t
1
,
t2
],
s
1
.
getDestinationValueList
())
self
.
assertEqual
([
t
ransition1
,
transition2
],
state
1
.
getDestinationValueList
())
def
test_WorkflowVariables
(
self
):
def
test_WorkflowVariables
(
self
):
...
@@ -113,31 +113,31 @@ class TestERP5Workflow(ERP5TypeTestCase):
...
@@ -113,31 +113,31 @@ class TestERP5Workflow(ERP5TypeTestCase):
portal_type
=
'Workflow'
)
portal_type
=
'Workflow'
)
workflow
.
setReference
(
'wf'
)
workflow
.
setReference
(
'wf'
)
workflow
.
setStateVariable
(
'current_state'
)
workflow
.
setStateVariable
(
'current_state'
)
s1
=
workflow
.
newContent
(
portal_type
=
'State'
,
s
tate
1
=
workflow
.
newContent
(
portal_type
=
'State'
,
title
=
'State 1'
)
title
=
'State 1'
)
s
1
.
setReference
(
's
1'
)
s
tate1
.
setReference
(
'state
1'
)
workflow
.
setSourceValue
(
s1
)
workflow
.
setSourceValue
(
s
tate
1
)
t1
=
workflow
.
newContent
(
portal_type
=
'Transition'
,
t
ransition
1
=
workflow
.
newContent
(
portal_type
=
'Transition'
,
title
=
'Transition 1'
,
title
=
'Transition 1'
,
destination_value
=
s1
)
destination_value
=
s
tate
1
)
t
1
.
setReference
(
't
1'
)
t
ransition1
.
setReference
(
'transition
1'
)
s
1
.
setDestinationValue
(
t
1
)
s
tate1
.
setDestinationValue
(
transition
1
)
v1
=
workflow
.
newContent
(
portal_type
=
'Workflow Variable'
,
v
ariable
1
=
workflow
.
newContent
(
portal_type
=
'Workflow Variable'
,
title
=
'actor'
)
title
=
'actor'
)
v1
.
setReference
(
'actor'
)
v
ariable
1
.
setReference
(
'actor'
)
v1
.
variable_expression
=
'user/getUserName'
v
ariable
1
.
variable_expression
=
'user/getUserName'
self
.
getPortalObject
().
portal_types
.
_getOb
(
'Folder'
)
\
self
.
getPortalObject
().
portal_types
.
_getOb
(
'Folder'
)
\
.
edit
(
type_workflow_list
=
(
'wf'
))
.
edit
(
type_workflow_list
=
(
'wf'
))
doc
=
self
.
portal
.
newContent
(
portal_type
=
'Folder'
,
id
=
'test_doc'
)
doc
=
self
.
portal
.
newContent
(
portal_type
=
'Folder'
,
id
=
'test_doc'
)
workflow
.
_executeTransition
(
doc
,
t1
)
workflow
.
_executeTransition
(
doc
,
t
ransition
1
)
current_state
=
workflow
.
getCurrentStatusDict
(
doc
)
current_state
=
workflow
.
getCurrentStatusDict
(
doc
)
self
.
assertTrue
(
isinstance
(
current_state
,
dict
))
self
.
assertTrue
(
isinstance
(
current_state
,
dict
))
self
.
assertEqual
(
s1
.
getReference
(),
current_state
.
get
(
'current_state'
))
self
.
assertEqual
(
s
tate
1
.
getReference
(),
current_state
.
get
(
'current_state'
))
self
.
assertEqual
(
'ERP5TypeTestCase'
,
current_state
.
get
(
'actor'
))
self
.
assertEqual
(
'ERP5TypeTestCase'
,
current_state
.
get
(
'actor'
))
history
=
doc
.
workflow_history
[
'wf'
]
history
=
doc
.
workflow_history
[
'wf'
]
self
.
assertEqual
(
len
(
history
),
2
)
# create, t1
self
.
assertEqual
(
len
(
history
),
2
)
# create, t
ransition
1
def
test_afterScript
(
self
):
def
test_afterScript
(
self
):
...
@@ -146,31 +146,32 @@ class TestERP5Workflow(ERP5TypeTestCase):
...
@@ -146,31 +146,32 @@ class TestERP5Workflow(ERP5TypeTestCase):
state_base_category
=
'current_state'
state_base_category
=
'current_state'
)
)
workflow
.
setReference
(
'wf'
)
workflow
.
setReference
(
'wf'
)
s1
=
workflow
.
newContent
(
portal_type
=
'State'
,
s
tate
1
=
workflow
.
newContent
(
portal_type
=
'State'
,
title
=
'State 1'
)
title
=
'State 1'
)
s2
=
workflow
.
newContent
(
portal_type
=
'State'
,
s
tate
2
=
workflow
.
newContent
(
portal_type
=
'State'
,
title
=
'State 2'
)
title
=
'State 2'
)
s1
.
setReference
(
's1'
)
state1
.
setReference
(
'state1'
)
s2
.
setReference
(
's2'
)
state2
.
setReference
(
'state2'
)
t1
=
workflow
.
newContent
(
portal_type
=
'Transition'
,
title
=
'Transition 1'
)
transition1
=
workflow
.
newContent
(
portal_type
=
'Transition'
,
t1
.
setReference
(
't1'
)
title
=
'Transition 1'
)
s1
.
setDestinationValue
(
t1
)
transition1
.
setReference
(
'transition1'
)
t1
.
setDestinationValue
(
s2
)
state1
.
setDestinationValue
(
transition1
)
workflow
.
setSourceValue
(
s1
)
transition1
.
setDestinationValue
(
state2
)
workflow
.
setSourceValue
(
state1
)
script
=
workflow
.
newContent
(
portal_type
=
'Workflow Script'
,
script
=
workflow
.
newContent
(
portal_type
=
'Workflow Script'
,
id
=
'Document_testAfterScript'
)
id
=
'Document_testAfterScript'
)
script
.
setParameterSignature
(
"state_change"
)
script
.
setParameterSignature
(
"state_change"
)
script
.
setParameterSignature
(
"state_change"
)
script
.
setParameterSignature
(
"state_change"
)
script
.
setBody
(
"state_change['object'].setDescription('After script was "
+
script
.
setBody
(
"state_change['object'].setDescription('After script was "
+
"executed.')"
)
"executed.')"
)
t
1
.
setCategoryList
(
t
1
.
getCategoryList
()
+
t
ransition1
.
setCategoryList
(
transition
1
.
getCategoryList
()
+
[
'after_script/'
+
script
.
getRelativeUrl
()])
[
'after_script/'
+
script
.
getRelativeUrl
()])
self
.
getPortalObject
().
portal_types
.
_getOb
(
'Folder'
)
\
self
.
getPortalObject
().
portal_types
.
_getOb
(
'Folder'
)
\
.
edit
(
type_workflow_list
=
(
'wf'
))
.
edit
(
type_workflow_list
=
(
'wf'
))
doc
=
self
.
portal
.
newContent
(
portal_type
=
'Folder'
,
id
=
'test_doc'
)
doc
=
self
.
portal
.
newContent
(
portal_type
=
'Folder'
,
id
=
'test_doc'
)
workflow
.
_executeTransition
(
doc
,
t1
)
workflow
.
_executeTransition
(
doc
,
t
ransition
1
)
self
.
assertEqual
(
'After script was executed.'
,
doc
.
getDescription
())
self
.
assertEqual
(
'After script was executed.'
,
doc
.
getDescription
())
# FIXME: not passing parameter to an after script is probably too
# FIXME: not passing parameter to an after script is probably too
# restrictive
# restrictive
...
@@ -179,27 +180,27 @@ class TestERP5Workflow(ERP5TypeTestCase):
...
@@ -179,27 +180,27 @@ class TestERP5Workflow(ERP5TypeTestCase):
workflow
=
self
.
workflow_module
.
newContent
(
portal_type
=
'Workflow'
)
workflow
=
self
.
workflow_module
.
newContent
(
portal_type
=
'Workflow'
)
workflow
.
setReference
(
'wf'
)
workflow
.
setReference
(
'wf'
)
workflow
.
setStateVariable
(
'current_state'
)
workflow
.
setStateVariable
(
'current_state'
)
s1
=
workflow
.
newContent
(
portal_type
=
'State'
,
title
=
'State 1'
)
s
tate
1
=
workflow
.
newContent
(
portal_type
=
'State'
,
title
=
'State 1'
)
s2
=
workflow
.
newContent
(
portal_type
=
'State'
,
title
=
'State 2'
)
s
tate
2
=
workflow
.
newContent
(
portal_type
=
'State'
,
title
=
'State 2'
)
s
1
.
setReference
(
's
1'
)
s
tate1
.
setReference
(
'state
1'
)
s
2
.
setReference
(
's
2'
)
s
tate2
.
setReference
(
'state
2'
)
t1
=
workflow
.
newContent
(
portal_type
=
'Transition'
,
title
=
'Transition 1'
)
t
ransition
1
=
workflow
.
newContent
(
portal_type
=
'Transition'
,
title
=
'Transition 1'
)
t
1
.
setReference
(
't
1'
)
t
ransition1
.
setReference
(
'transition
1'
)
s
1
.
setDestinationValue
(
t
1
)
s
tate1
.
setDestinationValue
(
transition
1
)
t
1
.
setDestinationValue
(
s
2
)
t
ransition1
.
setDestinationValue
(
state
2
)
workflow
.
setSourceValue
(
s1
)
workflow
.
setSourceValue
(
s
tate
1
)
script
=
workflow
.
newContent
(
portal_type
=
'Workflow Script'
,
script
=
workflow
.
newContent
(
portal_type
=
'Workflow Script'
,
id
=
'Document_testBeforeScript'
)
id
=
'Document_testBeforeScript'
)
script
.
setParameterSignature
(
"state_change"
)
script
.
setParameterSignature
(
"state_change"
)
script
.
setBody
(
"state_change['object'].setDescription('Before script was "
+
script
.
setBody
(
"state_change['object'].setDescription('Before script was "
+
"executed.')"
)
"executed.')"
)
t
1
.
setCategoryList
(
t
1
.
getCategoryList
()
+
t
ransition1
.
setCategoryList
(
transition
1
.
getCategoryList
()
+
[
'before_script/'
+
script
.
getRelativeUrl
()])
[
'before_script/'
+
script
.
getRelativeUrl
()])
self
.
getPortalObject
().
portal_types
.
_getOb
(
'Folder'
)
\
self
.
getPortalObject
().
portal_types
.
_getOb
(
'Folder'
)
\
.
edit
(
type_workflow_list
=
(
'wf'
))
.
edit
(
type_workflow_list
=
(
'wf'
))
doc
=
self
.
portal
.
newContent
(
portal_type
=
'Folder'
,
id
=
'test_doc'
)
doc
=
self
.
portal
.
newContent
(
portal_type
=
'Folder'
,
id
=
'test_doc'
)
workflow
.
_executeTransition
(
doc
,
t1
)
workflow
.
_executeTransition
(
doc
,
t
ransition
1
)
self
.
assertEqual
(
'Before script was executed.'
,
doc
.
getDescription
())
self
.
assertEqual
(
'Before script was executed.'
,
doc
.
getDescription
())
# FIXME: not passing parameter to an before script is probably too
# FIXME: not passing parameter to an before script is probably too
# restrictive
# restrictive
...
@@ -242,10 +243,7 @@ class TestERP5Workflow(ERP5TypeTestCase):
...
@@ -242,10 +243,7 @@ class TestERP5Workflow(ERP5TypeTestCase):
transition
.
setReference
(
'change_something'
)
transition
.
setReference
(
'change_something'
)
transition
.
setGuardRoleList
([
'Assignee'
,
'Assignor'
])
transition
.
setGuardRoleList
([
'Assignee'
,
'Assignor'
])
transition
.
setCategoryList
(
'destination/'
+
transition
.
getPath
())
transition
.
setCategoryList
(
'destination/'
+
transition
.
getPath
())
http_response
=
self
.
publish
(
transition
.
getPath
()
+
'/Base_viewDict'
,
transition
.
Base_viewDict
()
basic
=
'ERP5TypeTestCase:'
,)
self
.
assertEqual
(
http_response
.
status
,
200
)
def
test_WorkflowSecurity
(
self
):
def
test_WorkflowSecurity
(
self
):
"""
"""
...
...
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