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
Labels
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Jérome Perrin
erp5
Commits
6f6af0c5
Commit
6f6af0c5
authored
Oct 22, 2022
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: rewrite erp5_core_test with EPR5 Workflow.
parent
ef1cf2b3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
188 additions
and
166 deletions
+188
-166
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testBase.py
.../TestTemplateItem/portal_components/test.erp5.testBase.py
+15
-11
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testBusinessTemplate.py
...eItem/portal_components/test.erp5.testBusinessTemplate.py
+10
-5
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testInteractionWorkflow.py
...em/portal_components/test.erp5.testInteractionWorkflow.py
+163
-150
No files found.
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testBase.py
View file @
6f6af0c5
...
@@ -969,16 +969,20 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
...
@@ -969,16 +969,20 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
dummy_simulation_workflow_id
=
'fake_simulation_workflow'
dummy_simulation_workflow_id
=
'fake_simulation_workflow'
dummy_validation_workflow_id
=
'fake_validation_workflow'
dummy_validation_workflow_id
=
'fake_validation_workflow'
#Assume that erp5_styles workflow Manage permissions with acquired Role by default
#Assume that erp5_styles workflow Manage permissions with acquired Role by default
addWorkflowByType
(
pw
,
'erp5_workflow'
,
dummy_simulation_workflow_id
)
dummy_simulation_workflow
=
pw
.
newContent
(
addWorkflowByType
(
pw
,
'erp5_workflow'
,
dummy_validation_workflow_id
)
portal_type
=
'Workflow'
,
dummy_simulation_workflow
=
pw
[
dummy_simulation_workflow_id
]
reference
=
dummy_simulation_workflow_id
,
dummy_validation_workflow
=
pw
[
dummy_validation_workflow_id
]
)
dummy_validation_workflow
.
variables
.
setStateVar
(
'validation_state'
)
dummy_validation_workflow
=
pw
.
newContent
(
portal_type
=
'Workflow'
,
reference
=
dummy_validation_workflow_id
,
state_variable
=
'validation_state'
,
)
organisation_type
=
portal
.
portal_types
.
getTypeInfo
(
portal_type
)
organisation_type
=
portal
.
portal_types
.
getTypeInfo
(
portal_type
)
organisation_initial_workflow_list
=
organisation_type
.
getTypeWorkflowList
()
organisation_initial_workflow_list
=
organisation_type
.
getTypeWorkflowList
()
organisation_type
.
setTypeWorkflowList
([
dummy_validation_workflow_id
,
organisation_type
.
setTypeWorkflowList
([
dummy_validation_workflow_id
,
dummy_simulation_workflow_id
])
dummy_simulation_workflow_id
])
permission_list
=
list
(
dummy_simulation_workflow
.
permissions
)
permission_list
=
dummy_simulation_workflow
.
getWorkflowManagedPermissionList
(
)
manager_has_permission
=
{}
manager_has_permission
=
{}
for
permission
in
permission_list
:
for
permission
in
permission_list
:
manager_has_permission
[
permission
]
=
(
'Manager'
,)
manager_has_permission
[
permission
]
=
(
'Manager'
,)
...
@@ -989,7 +993,7 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
...
@@ -989,7 +993,7 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
user
=
getSecurityManager
().
getUser
()
user
=
getSecurityManager
().
getUser
()
try
:
try
:
self
.
assertTrue
(
permission_list
)
self
.
assertTrue
(
permission_list
)
self
.
assertFalse
(
dummy_simulation_workflow
.
states
.
draft
.
permission_roles
)
self
.
assertFalse
(
dummy_simulation_workflow
[
'state_draft'
].
getStatePermissionRoleListDict
()
)
#1
#1
obj
=
module
.
newContent
(
portal_type
=
portal_type
)
obj
=
module
.
newContent
(
portal_type
=
portal_type
)
#No role is defined by default on workflow
#No role is defined by default on workflow
...
@@ -999,21 +1003,21 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
...
@@ -999,21 +1003,21 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
for
permission
in
permission_list
:
for
permission
in
permission_list
:
self
.
assertTrue
(
user
.
has_permission
(
permission
,
obj
))
self
.
assertTrue
(
user
.
has_permission
(
permission
,
obj
))
#2 Now configure both workflow with same configuration
#2 Now configure both workflow with same configuration
dummy_simulation_workflow
.
states
.
draft
.
permission_roles
=
manager_has_permission
.
copy
(
)
dummy_simulation_workflow
[
'state_draft'
].
setStatePermissionRoleListDict
(
manager_has_permission
.
copy
()
)
dummy_validation_workflow
.
states
.
draft
.
permission_roles
=
manager_has_permission
.
copy
(
)
dummy_validation_workflow
[
'state_draft'
].
setStatePermissionRoleListDict
(
manager_has_permission
.
copy
()
)
dummy_simulation_workflow
.
updateRoleMappingsFor
(
obj
)
dummy_simulation_workflow
.
updateRoleMappingsFor
(
obj
)
dummy_validation_workflow
.
updateRoleMappingsFor
(
obj
)
dummy_validation_workflow
.
updateRoleMappingsFor
(
obj
)
for
permission
in
permission_list
:
for
permission
in
permission_list
:
self
.
assertTrue
(
user
.
has_permission
(
permission
,
obj
))
self
.
assertTrue
(
user
.
has_permission
(
permission
,
obj
))
#3 change only dummy_simulation_workflow
#3 change only dummy_simulation_workflow
dummy_simulation_workflow
.
states
.
draft
.
permission_roles
=
manager_has_no_permission
.
copy
(
)
dummy_simulation_workflow
[
'state_draft'
].
setStatePermissionRoleListDict
(
manager_has_no_permission
.
copy
()
)
dummy_simulation_workflow
.
updateRoleMappingsFor
(
obj
)
dummy_simulation_workflow
.
updateRoleMappingsFor
(
obj
)
for
permission
in
permission_list
:
for
permission
in
permission_list
:
self
.
assertFalse
(
user
.
has_permission
(
permission
,
obj
))
self
.
assertFalse
(
user
.
has_permission
(
permission
,
obj
))
#4 enable acquisition for dummy_simulation_workflow
#4 enable acquisition for dummy_simulation_workflow
dummy_simulation_workflow
.
states
.
draft
.
permission_roles
=
None
dummy_simulation_workflow
[
'state_draft'
].
setAcquirePermissionList
(
permission_list
)
dummy_simulation_workflow
.
updateRoleMappingsFor
(
obj
)
dummy_simulation_workflow
.
updateRoleMappingsFor
(
obj
)
for
permission
in
permission_list
:
for
permission
in
permission_list
:
self
.
assertTrue
(
user
.
has_permission
(
permission
,
obj
))
self
.
assertTrue
(
user
.
has_permission
(
permission
,
obj
))
...
...
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testBusinessTemplate.py
View file @
6f6af0c5
...
@@ -39,7 +39,6 @@ from urllib import pathname2url
...
@@ -39,7 +39,6 @@ from urllib import pathname2url
from
Products.ERP5Type.Globals
import
PersistentMapping
from
Products.ERP5Type.Globals
import
PersistentMapping
from
Products.ERP5Type.dynamic.lazy_class
import
ERP5BaseBroken
from
Products.ERP5Type.dynamic.lazy_class
import
ERP5BaseBroken
from
Products.ERP5Type.tests.utils
import
LogInterceptor
from
Products.ERP5Type.tests.utils
import
LogInterceptor
from
Products.ERP5Type.Workflow
import
addWorkflowByType
import
shutil
import
shutil
import
os
import
os
import
random
import
random
...
@@ -1315,8 +1314,11 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor):
...
@@ -1315,8 +1314,11 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor):
"""
"""
wf_id
=
'geek_workflow'
wf_id
=
'geek_workflow'
pw
=
self
.
getWorkflowTool
()
pw
=
self
.
getWorkflowTool
()
addWorkflowByType
(
pw
,
WORKFLOW_TYPE
,
wf_id
)
workflow
=
pw
.
newContent
(
workflow
=
pw
.
_getOb
(
wf_id
,
None
)
portal_type
=
'Workflow'
,
reference
=
wf_id
,
)
self
.
tic
()
self
.
assertTrue
(
workflow
is
not
None
)
self
.
assertTrue
(
workflow
is
not
None
)
sequence
.
edit
(
workflow_id
=
workflow
.
getId
())
sequence
.
edit
(
workflow_id
=
workflow
.
getId
())
...
@@ -2886,8 +2888,11 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor):
...
@@ -2886,8 +2888,11 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor):
"""
"""
wf_id
=
'custom_geek_workflow'
wf_id
=
'custom_geek_workflow'
pw
=
self
.
getWorkflowTool
()
pw
=
self
.
getWorkflowTool
()
addWorkflowByType
(
pw
,
WORKFLOW_TYPE
,
wf_id
)
workflow
=
pw
.
newContent
(
workflow
=
pw
.
_getOb
(
wf_id
,
None
)
portal_type
=
'Workflow'
,
reference
=
wf_id
,
)
self
.
tic
()
self
.
assertTrue
(
workflow
is
not
None
)
self
.
assertTrue
(
workflow
is
not
None
)
sequence
.
edit
(
workflow_id
=
workflow
.
getId
())
sequence
.
edit
(
workflow_id
=
workflow
.
getId
())
...
...
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testInteractionWorkflow.py
View file @
6f6af0c5
...
@@ -33,7 +33,6 @@ import transaction
...
@@ -33,7 +33,6 @@ import transaction
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5Type.Base
import
_aq_reset
from
Products.ERP5Type.Base
import
_aq_reset
from
AccessControl
import
ClassSecurityInfo
from
AccessControl
import
ClassSecurityInfo
from
Products.ERP5Type.Workflow
import
addWorkflowByType
class
TestInteractionWorkflow
(
ERP5TypeTestCase
):
class
TestInteractionWorkflow
(
ERP5TypeTestCase
):
...
@@ -76,20 +75,26 @@ class TestInteractionWorkflow(ERP5TypeTestCase):
...
@@ -76,20 +75,26 @@ class TestInteractionWorkflow(ERP5TypeTestCase):
def
_createInteractionWorkflowWithId
(
self
,
wf_id
):
def
_createInteractionWorkflowWithId
(
self
,
wf_id
):
wf_tool
=
self
.
getWorkflowTool
()
wf_tool
=
self
.
getWorkflowTool
()
return
addWorkflowByType
(
wf_tool
,
"interaction_workflow"
,
wf_id
)
return
wf_tool
.
newContent
(
portal_type
=
'Interaction Workflow'
,
reference
=
wf_id
,
)
def
createInteractionWorkflow
(
self
):
def
createInteractionWorkflow
(
self
):
if
getattr
(
self
.
getWorkflowTool
(),
'test_workflow'
,
None
)
is
None
:
if
getattr
(
self
.
getWorkflowTool
(),
'test_workflow'
,
None
)
is
None
:
self
.
_createInteractionWorkflowWithId
(
'test_workflow'
)
self
.
_createInteractionWorkflowWithId
(
'test_workflow'
)
wf
=
self
.
getWorkflowTool
()[
'test_workflow'
]
wf
=
self
.
getWorkflowTool
()[
'test_workflow'
]
self
.
wf
=
wf
self
.
wf
=
wf
if
getattr
(
wf
.
scripts
,
'afterEdit'
,
None
)
is
None
:
if
getattr
(
wf
,
'script_afterEdit'
,
None
)
is
None
:
wf
.
scripts
.
manage_addProduct
[
'PythonScripts'
]
\
wf
.
manage_addProduct
[
'PythonScripts'
]
\
.
manage_addPythonScript
(
id
=
'afterEdit'
)
.
manage_addPythonScript
(
id
=
'script_afterEdit'
)
self
.
script
=
wf
.
scripts
[
'afterEdit'
]
self
.
script
=
wf
.
script_afterEdit
if
getattr
(
wf
.
interactions
,
'edit_interaction'
,
None
)
is
None
:
if
getattr
(
wf
,
'interactions_edit_interaction'
,
None
)
is
None
:
wf
.
interactions
.
addInteraction
(
id
=
'edit_interaction'
)
wf
.
newContent
(
self
.
interaction
=
wf
.
interactions
[
'edit_interaction'
]
portal_type
=
'Interaction Workflow Interaction'
,
reference
=
'edit_interaction'
,
)
self
.
interaction
=
wf
.
interaction_edit_interaction
type_object
=
self
.
portal
.
portal_types
.
getTypeInfo
(
self
.
portal_type
)
type_object
=
self
.
portal
.
portal_types
.
getTypeInfo
(
self
.
portal_type
)
type_object
.
setTypeWorkflowList
([
'test_workflow'
,
'validation_workflow'
])
type_object
.
setTypeWorkflowList
([
'test_workflow'
,
'validation_workflow'
])
_aq_reset
()
# XXX Fails XXX _setLastId not found when doing newContent
_aq_reset
()
# XXX Fails XXX _setLastId not found when doing newContent
...
@@ -97,16 +102,24 @@ class TestInteractionWorkflow(ERP5TypeTestCase):
...
@@ -97,16 +102,24 @@ class TestInteractionWorkflow(ERP5TypeTestCase):
def
createInteractionWorkflowWithTwoInteractions
(
self
):
def
createInteractionWorkflowWithTwoInteractions
(
self
):
wf
=
self
.
_createInteractionWorkflowWithId
(
'test_workflow'
)
wf
=
self
.
_createInteractionWorkflowWithId
(
'test_workflow'
)
self
.
wf
=
wf
self
.
wf
=
wf
wf
.
scripts
.
manage_addProduct
[
'PythonScripts'
]
\
wf
.
manage_addProduct
[
'PythonScripts'
]
\
.
manage_addPythonScript
(
id
=
'afterEditA'
)
.
manage_addPythonScript
(
id
=
'script_afterEditA'
)
self
.
scriptA
=
wf
.
scripts
[
'afterEditA'
]
self
.
scriptA
=
wf
.
script_afterEditA
wf
.
interactions
.
addInteraction
(
id
=
'editA'
)
if
getattr
(
wf
,
'interactions_editA'
,
None
)
is
None
:
self
.
interactionA
=
wf
.
interactions
[
'editA'
]
wf
.
newContent
(
wf
.
scripts
.
manage_addProduct
[
'PythonScripts'
]
\
portal_type
=
'Interaction Workflow Interaction'
,
.
manage_addPythonScript
(
id
=
'afterEditB'
)
reference
=
'editA'
,
self
.
scriptB
=
wf
.
scripts
[
'afterEditB'
]
)
wf
.
interactions
.
addInteraction
(
id
=
'editB'
)
self
.
interactionA
=
wf
.
interaction_editA
self
.
interactionB
=
wf
.
interactions
[
'editB'
]
wf
.
manage_addProduct
[
'PythonScripts'
]
\
.
manage_addPythonScript
(
id
=
'script_afterEditB'
)
self
.
scriptB
=
wf
.
script_afterEditB
if
getattr
(
wf
,
'interactions_editB'
,
None
)
is
None
:
wf
.
newContent
(
portal_type
=
'Interaction Workflow Interaction'
,
reference
=
'editB'
,
)
self
.
interactionB
=
wf
.
interaction_editB
type_object
=
self
.
portal
.
portal_types
.
getTypeInfo
(
self
.
portal_type
)
type_object
=
self
.
portal
.
portal_types
.
getTypeInfo
(
self
.
portal_type
)
type_object
.
setTypeWorkflowList
([
'test_workflow'
,
'validation_workflow'
])
type_object
.
setTypeWorkflowList
([
'test_workflow'
,
'validation_workflow'
])
_aq_reset
()
# XXX Fails XXX _setLastId not found when doing newContent
_aq_reset
()
# XXX Fails XXX _setLastId not found when doing newContent
...
@@ -118,10 +131,10 @@ class TestInteractionWorkflow(ERP5TypeTestCase):
...
@@ -118,10 +131,10 @@ class TestInteractionWorkflow(ERP5TypeTestCase):
def
test_edit_interaction
(
self
):
def
test_edit_interaction
(
self
):
self
.
createInteractionWorkflow
()
self
.
createInteractionWorkflow
()
self
.
interaction
.
setProperties
(
self
.
interaction
.
edit
(
'afterEdit'
,
trigger_method_id_list
=
(
'edit'
,)
,
method_id
=
'edit'
,
after_script_value
=
self
.
script
,
after_script_name
=
(
'afterEdit'
,)
)
)
params
=
'sci,**kw'
params
=
'sci,**kw'
body
=
"context = sci.object
\
n
"
+
\
body
=
"context = sci.object
\
n
"
+
\
"context.setDescription('toto')"
"context.setDescription('toto')"
...
@@ -133,10 +146,10 @@ class TestInteractionWorkflow(ERP5TypeTestCase):
...
@@ -133,10 +146,10 @@ class TestInteractionWorkflow(ERP5TypeTestCase):
def
test_interaction_on_edit
(
self
):
def
test_interaction_on_edit
(
self
):
self
.
createInteractionWorkflow
()
self
.
createInteractionWorkflow
()
self
.
interaction
.
setProperties
(
self
.
interaction
.
edit
(
'afterEdit'
,
trigger_method_id_list
=
(
'edit'
,)
,
method_id
=
'edit'
,
after_script_value
=
self
.
script
,
after_script_name
=
(
'afterEdit'
,)
)
)
body
=
"context = sci.object
\
n
"
+
\
body
=
"context = sci.object
\
n
"
+
\
"context.setDescription('toto')"
"context.setDescription('toto')"
params
=
'sci,**kw'
params
=
'sci,**kw'
...
@@ -148,10 +161,10 @@ class TestInteractionWorkflow(ERP5TypeTestCase):
...
@@ -148,10 +161,10 @@ class TestInteractionWorkflow(ERP5TypeTestCase):
def
test_interaction_on_method
(
self
):
def
test_interaction_on_method
(
self
):
self
.
createInteractionWorkflow
()
self
.
createInteractionWorkflow
()
self
.
interaction
.
setProperties
(
self
.
interaction
.
edit
(
'afterEdit'
,
trigger_method_id_list
=
(
'doSomethingStupid'
,)
,
method_id
=
'doSomethingStupid'
,
after_script_value
=
self
.
script
,
after_script_name
=
(
'afterEdit'
,)
)
)
body
=
"context = sci.object
\
n
"
+
\
body
=
"context = sci.object
\
n
"
+
\
"context.setDescription('toto')"
"context.setDescription('toto')"
params
=
'sci,**kw'
params
=
'sci,**kw'
...
@@ -163,10 +176,10 @@ class TestInteractionWorkflow(ERP5TypeTestCase):
...
@@ -163,10 +176,10 @@ class TestInteractionWorkflow(ERP5TypeTestCase):
def
test_interaction_on_category_setter
(
self
):
def
test_interaction_on_category_setter
(
self
):
self
.
createInteractionWorkflow
()
self
.
createInteractionWorkflow
()
self
.
interaction
.
setProperties
(
self
.
interaction
.
edit
(
'afterEdit'
,
trigger_method_id_list
=
(
'setSizeList'
,
'_setSizeList'
,)
,
method_id
=
'setSizeList _setSizeList'
,
after_script_value
=
self
.
script
,
after_script_name
=
(
'afterEdit'
,)
)
)
body
=
"context = sci.object
\
n
"
+
\
body
=
"context = sci.object
\
n
"
+
\
"context.setDescription('toto')"
"context.setDescription('toto')"
params
=
'sci,**kw'
params
=
'sci,**kw'
...
@@ -178,10 +191,10 @@ class TestInteractionWorkflow(ERP5TypeTestCase):
...
@@ -178,10 +191,10 @@ class TestInteractionWorkflow(ERP5TypeTestCase):
def
test_interaction_executed_once
(
self
):
def
test_interaction_executed_once
(
self
):
self
.
createInteractionWorkflow
()
self
.
createInteractionWorkflow
()
self
.
interaction
.
setProperties
(
self
.
interaction
.
edit
(
'afterEdit'
,
trigger_method_id_list
=
(
'edit'
,)
,
method_id
=
'edit'
,
after_script_value
=
self
.
script
,
after_script_name
=
(
'afterEdit'
,)
)
)
params
=
'sci,**kw'
params
=
'sci,**kw'
body
=
"context = sci.object
\
n
"
+
\
body
=
"context = sci.object
\
n
"
+
\
"description = context.getDescription()
\
n
"
+
\
"description = context.getDescription()
\
n
"
+
\
...
@@ -195,10 +208,10 @@ class TestInteractionWorkflow(ERP5TypeTestCase):
...
@@ -195,10 +208,10 @@ class TestInteractionWorkflow(ERP5TypeTestCase):
def
test_returned_value
(
self
):
def
test_returned_value
(
self
):
self
.
createInteractionWorkflow
()
self
.
createInteractionWorkflow
()
self
.
interaction
.
setProperties
(
self
.
interaction
.
edit
(
'afterEdit'
,
trigger_method_id_list
=
(
'newContent'
,)
,
method_id
=
'newContent'
,
after_script_value
=
self
.
script
,
after_script_name
=
(
'afterEdit'
,)
)
)
params
=
'sci,**kw'
params
=
'sci,**kw'
body
=
"context = sci.object
\
n
"
+
\
body
=
"context = sci.object
\
n
"
+
\
"return 3
\
n
"
"return 3
\
n
"
...
@@ -212,10 +225,10 @@ class TestInteractionWorkflow(ERP5TypeTestCase):
...
@@ -212,10 +225,10 @@ class TestInteractionWorkflow(ERP5TypeTestCase):
def
test_multiple_methods
(
self
):
def
test_multiple_methods
(
self
):
self
.
createInteractionWorkflow
()
self
.
createInteractionWorkflow
()
self
.
interaction
.
setProperties
(
self
.
interaction
.
edit
(
'afterEdit'
,
trigger_method_id_list
=
(
'setCorporateName'
,
'setActivityCode'
,)
,
method_id
=
'setCorporateName setActivityCode'
,
after_script_value
=
self
.
script
,
after_script_name
=
(
'afterEdit'
,)
)
)
params
=
'sci,**kw'
params
=
'sci,**kw'
body
=
"context = sci.object
\
n
"
+
\
body
=
"context = sci.object
\
n
"
+
\
"description = context.getDescription()
\
n
"
+
\
"description = context.getDescription()
\
n
"
+
\
...
@@ -229,14 +242,14 @@ class TestInteractionWorkflow(ERP5TypeTestCase):
...
@@ -229,14 +242,14 @@ class TestInteractionWorkflow(ERP5TypeTestCase):
def
test_same_method_two_interactions
(
self
):
def
test_same_method_two_interactions
(
self
):
self
.
createInteractionWorkflowWithTwoInteractions
()
self
.
createInteractionWorkflowWithTwoInteractions
()
self
.
interactionA
.
setProperties
(
self
.
interactionA
.
edit
(
'afterEditA'
,
trigger_method_id_list
=
(
'edit'
,)
,
method_id
=
'edit'
,
after_script_value
=
self
.
scriptA
,
after_script_name
=
(
'afterEditA'
,)
)
)
self
.
interactionB
.
setProperties
(
self
.
interactionB
.
edit
(
'afterEditB'
,
trigger_method_id_list
=
(
'edit'
,)
,
method_id
=
'edit'
,
after_script_value
=
self
.
scriptB
,
after_script_name
=
(
'afterEditB'
,)
)
)
params
=
'sci,**kw'
params
=
'sci,**kw'
body
=
"context = sci.object
\
n
"
+
\
body
=
"context = sci.object
\
n
"
+
\
"context.log('InteractionWF.test_09 in script', 'a')
\
n
"
+
\
"context.log('InteractionWF.test_09 in script', 'a')
\
n
"
+
\
...
@@ -257,10 +270,10 @@ class TestInteractionWorkflow(ERP5TypeTestCase):
...
@@ -257,10 +270,10 @@ class TestInteractionWorkflow(ERP5TypeTestCase):
def
test_multiple_scripts
(
self
):
def
test_multiple_scripts
(
self
):
self
.
createInteractionWorkflowWithTwoInteractions
()
self
.
createInteractionWorkflowWithTwoInteractions
()
self
.
interactionA
.
setProperties
(
self
.
interactionA
.
edit
(
'afterEdit'
,
trigger_method_id_list
=
(
'edit'
,)
,
method_id
=
'edit'
,
after_script_value_list
=
(
self
.
scriptA
,
self
.
scriptB
)
,
after_script_name
=
(
'afterEditA'
,
'afterEditB'
)
)
)
params
=
'sci,**kw'
params
=
'sci,**kw'
body
=
"context = sci.object
\
n
"
+
\
body
=
"context = sci.object
\
n
"
+
\
"context.log('InteractionWF.test_10 in script', 'a')
\
n
"
+
\
"context.log('InteractionWF.test_10 in script', 'a')
\
n
"
+
\
...
@@ -281,14 +294,14 @@ class TestInteractionWorkflow(ERP5TypeTestCase):
...
@@ -281,14 +294,14 @@ class TestInteractionWorkflow(ERP5TypeTestCase):
def
test_private_accessor
(
self
):
def
test_private_accessor
(
self
):
self
.
createInteractionWorkflowWithTwoInteractions
()
self
.
createInteractionWorkflowWithTwoInteractions
()
self
.
interactionA
.
setProperties
(
self
.
interactionA
.
edit
(
'afterEditA'
,
trigger_method_id_list
=
(
'_setVatCode'
,)
,
method_id
=
'_setVatCode'
,
after_script_value
=
self
.
scriptA
,
after_script_name
=
(
'afterEditA'
,)
)
)
self
.
interactionB
.
setProperties
(
self
.
interactionB
.
edit
(
'afterEditB'
,
trigger_method_id_list
=
(
'setVatCode'
,)
,
method_id
=
'setVatCode'
,
after_script_value
=
self
.
scriptB
,
after_script_name
=
(
'afterEditB'
,)
)
)
params
=
'sci,**kw'
params
=
'sci,**kw'
body
=
"context = sci.object
\
n
"
+
\
body
=
"context = sci.object
\
n
"
+
\
"context.log('InteractionWF.test_11 in script', 'a')
\
n
"
+
\
"context.log('InteractionWF.test_11 in script', 'a')
\
n
"
+
\
...
@@ -309,14 +322,14 @@ class TestInteractionWorkflow(ERP5TypeTestCase):
...
@@ -309,14 +322,14 @@ class TestInteractionWorkflow(ERP5TypeTestCase):
def
test_private_accessor_on_acquired_property
(
self
):
def
test_private_accessor_on_acquired_property
(
self
):
self
.
createInteractionWorkflowWithTwoInteractions
()
self
.
createInteractionWorkflowWithTwoInteractions
()
self
.
interactionA
.
setProperties
(
self
.
interactionA
.
edit
(
'afterEditA'
,
trigger_method_id_list
=
(
'_setDefaultEmailText'
,)
,
method_id
=
'_setDefaultEmailText'
,
after_script_value
=
self
.
scriptA
,
after_script_name
=
(
'afterEditA'
,)
)
)
self
.
interactionB
.
setProperties
(
self
.
interactionB
.
edit
(
'afterEditB'
,
trigger_method_id_list
=
(
'setDefaultEmailText'
,)
,
method_id
=
'setDefaultEmailText'
,
after_script_value
=
self
.
scriptB
,
after_script_name
=
(
'afterEditB'
,)
)
)
params
=
'sci,**kw'
params
=
'sci,**kw'
body
=
"context = sci.object
\
n
"
+
\
body
=
"context = sci.object
\
n
"
+
\
"context.log('InteractionWF.test_12 in script', 'a')
\
n
"
+
\
"context.log('InteractionWF.test_12 in script', 'a')
\
n
"
+
\
...
@@ -341,10 +354,10 @@ class TestInteractionWorkflow(ERP5TypeTestCase):
...
@@ -341,10 +354,10 @@ class TestInteractionWorkflow(ERP5TypeTestCase):
# Check that edit does not detect the property modified in interaction
# Check that edit does not detect the property modified in interaction
# script as modified by user
# script as modified by user
self
.
createInteractionWorkflow
()
self
.
createInteractionWorkflow
()
self
.
interaction
.
setProperties
(
self
.
interaction
.
edit
(
'afterEdit'
,
trigger_method_id_list
=
(
'_setTitle'
,)
,
method_id
=
'_setTitle'
,
after_script_value
=
self
.
script
,
after_script_name
=
(
'afterEdit'
,)
)
)
params
=
'sci,**kw'
params
=
'sci,**kw'
body
=
"context = sci.object
\
n
"
+
\
body
=
"context = sci.object
\
n
"
+
\
"vat_code = context.getVatCode()
\
n
"
+
\
"vat_code = context.getVatCode()
\
n
"
+
\
...
@@ -383,10 +396,10 @@ class TestInteractionWorkflow(ERP5TypeTestCase):
...
@@ -383,10 +396,10 @@ class TestInteractionWorkflow(ERP5TypeTestCase):
def
test_BeforeScriptParameters
(
self
):
def
test_BeforeScriptParameters
(
self
):
self
.
createInteractionWorkflow
()
self
.
createInteractionWorkflow
()
self
.
interaction
.
setProperties
(
self
.
interaction
.
edit
(
'afterEdit'
,
trigger_method_id_list
=
(
'getProperty'
,)
,
method_id
=
'getProperty'
,
before_script_value
=
self
.
script
,
script_name
=
(
'afterEdit'
,)
)
)
params
=
'sci,**kw'
params
=
'sci,**kw'
body
=
"""
\
body
=
"""
\
context = sci['object']
context = sci['object']
...
@@ -404,10 +417,10 @@ context.setDescription('%s,%s,%s' % (d, args, result))
...
@@ -404,10 +417,10 @@ context.setDescription('%s,%s,%s' % (d, args, result))
def
test_AfterScriptParameters
(
self
):
def
test_AfterScriptParameters
(
self
):
self
.
createInteractionWorkflow
()
self
.
createInteractionWorkflow
()
self
.
interaction
.
setProperties
(
self
.
interaction
.
edit
(
'afterEdit'
,
trigger_method_id_list
=
(
'getProperty'
,)
,
method_id
=
'getProperty'
,
after_script_value
=
self
.
script
,
after_script_name
=
(
'afterEdit'
,)
)
)
params
=
'sci,**kw'
params
=
'sci,**kw'
body
=
"""
\
body
=
"""
\
context = sci['object']
context = sci['object']
...
@@ -426,10 +439,10 @@ context.setDescription('%s,%s,%s' % (d, args, result))
...
@@ -426,10 +439,10 @@ context.setDescription('%s,%s,%s' % (d, args, result))
def
test_BeforeCommitParameters
(
self
):
def
test_BeforeCommitParameters
(
self
):
self
.
createInteractionWorkflow
()
self
.
createInteractionWorkflow
()
self
.
interaction
.
setProperties
(
self
.
interaction
.
edit
(
'beforeCommit'
,
trigger_method_id_list
=
(
'getProperty'
,)
,
method_id
=
'getProperty'
,
before_commit_script_value
=
self
.
script
,
before_commit_script_name
=
(
'afterEdit'
,)
)
)
params
=
'sci, **kw'
params
=
'sci, **kw'
body
=
"""
\
body
=
"""
\
context = sci['object']
context = sci['object']
...
@@ -459,11 +472,11 @@ context.setDescription('%s,%s,%s' % (d, args, result))
...
@@ -459,11 +472,11 @@ context.setDescription('%s,%s,%s' % (d, args, result))
def
test_activity_interaction
(
self
):
def
test_activity_interaction
(
self
):
# Tests for Later Script (in activity)
# Tests for Later Script (in activity)
self
.
createInteractionWorkflow
()
self
.
createInteractionWorkflow
()
self
.
interaction
.
setProperties
(
self
.
interaction
.
edit
(
'editObject'
,
trigger_once_per_transaction
=
1
,
once_per_transaction
=
1
,
trigger_method_id_list
=
(
'_setGroup.*'
,)
,
method_id
=
'_setGroup.*'
,
activate_script_value
=
self
.
script
,
activate_script_name
=
(
'afterEdit'
,)
)
)
params
=
'sci, **kw'
params
=
'sci, **kw'
body
=
"""
\
body
=
"""
\
context = sci['object']
context = sci['object']
...
@@ -481,11 +494,11 @@ context.setTitle('Bar')
...
@@ -481,11 +494,11 @@ context.setTitle('Bar')
def
test_skip_temp_object
(
self
):
def
test_skip_temp_object
(
self
):
self
.
createInteractionWorkflow
()
self
.
createInteractionWorkflow
()
self
.
interaction
.
setProperties
(
self
.
interaction
.
edit
(
'editObject'
,
temporary_document_disallowed
=
0
,
temporary_document_disallowed
=
False
,
trigger_method_id_list
=
(
'_setGroup.*'
,)
,
method_id
=
'_setGroup.*'
,
after_script_value
=
self
.
script
,
after_script_name
=
(
'afterEdit'
,)
)
)
params
=
'sci, **kw'
params
=
'sci, **kw'
body
=
"""
\
body
=
"""
\
context = sci['object']
context = sci['object']
...
@@ -500,22 +513,22 @@ context.setTitle('Bar')
...
@@ -500,22 +513,22 @@ context.setTitle('Bar')
self
.
assertEqual
(
temp
.
getTitle
(),
'Bar'
)
self
.
assertEqual
(
temp
.
getTitle
(),
'Bar'
)
# but not if it has been forbidden
# but not if it has been forbidden
temp
.
setTitle
(
'Foo'
)
temp
.
setTitle
(
'Foo'
)
self
.
interaction
.
setProperties
(
self
.
interaction
.
edit
(
'editObject'
,
temporary_document_disallowed
=
1
,
temporary_document_disallowed
=
True
,
trigger_method_id_list
=
(
'_setGroup.*'
,)
,
method_id
=
'_setGroup.*'
,
after_script_value
=
self
.
script
,
after_script_name
=
(
'afterEdit'
,)
)
)
temp
.
setGroupValue
(
None
)
temp
.
setGroupValue
(
None
)
self
.
assertEqual
(
temp
.
getTitle
(),
'Foo'
)
self
.
assertEqual
(
temp
.
getTitle
(),
'Foo'
)
def
test_temp_object_doesnt_skip_normal
(
self
):
def
test_temp_object_doesnt_skip_normal
(
self
):
self
.
createInteractionWorkflow
()
self
.
createInteractionWorkflow
()
self
.
interaction
.
setProperties
(
self
.
interaction
.
edit
(
'editObject'
,
trigger_once_per_transaction
=
1
,
once_per_transaction
=
True
,
temporary_document_disallowed
=
1
,
temporary_document_disallowed
=
True
,
trigger_method_id_list
=
(
'_setGroup.*'
,)
,
method_id
=
'_setGroup.*'
,
after_script_value
=
self
.
script
,
after_script_name
=
(
'afterEdit'
,)
)
)
params
=
'sci, **kw'
params
=
'sci, **kw'
body
=
"""
\
body
=
"""
\
context = sci['object']
context = sci['object']
...
@@ -544,12 +557,12 @@ context.setTitle('Bar')
...
@@ -544,12 +557,12 @@ context.setTitle('Bar')
def
test_temp_object_does_skip_normal
(
self
):
def
test_temp_object_does_skip_normal
(
self
):
self
.
createInteractionWorkflow
()
self
.
createInteractionWorkflow
()
self
.
interaction
.
setProperties
(
self
.
interaction
.
edit
(
'editObject'
,
trigger_once_per_transaction
=
1
,
once_per_transaction
=
True
,
temporary_document_disallowed
=
0
,
temporary_document_disallowed
=
False
,
trigger_method_id_list
=
(
'_setGroup.*'
,)
,
method_id
=
'_setGroup.*'
,
after_script_value
=
self
.
script
,
after_script_name
=
(
'afterEdit'
,)
)
)
params
=
'sci, **kw'
params
=
'sci, **kw'
body
=
"""
\
body
=
"""
\
context = sci['object']
context = sci['object']
...
@@ -586,10 +599,10 @@ context.setTitle('Bar')
...
@@ -586,10 +599,10 @@ context.setTitle('Bar')
# test that we can add an interaction by defining methods using regular
# test that we can add an interaction by defining methods using regular
# expression
# expression
self
.
createInteractionWorkflow
()
self
.
createInteractionWorkflow
()
self
.
interaction
.
setProperties
(
self
.
interaction
.
edit
(
'regexp'
,
trigger_method_id_list
=
(
'_set.*'
,
'set.*'
)
,
method_id
=
'_set.* set.*'
,
after_script_value
=
self
.
script
,
after_script_name
=
(
'afterEdit'
,)
)
)
call_list
=
self
.
portal
.
REQUEST
[
'call_list'
]
=
[]
call_list
=
self
.
portal
.
REQUEST
[
'call_list'
]
=
[]
self
.
script
.
ZPythonScript_edit
(
'sci'
,
self
.
script
.
ZPythonScript_edit
(
'sci'
,
...
@@ -614,10 +627,10 @@ context.setTitle('Bar')
...
@@ -614,10 +627,10 @@ context.setTitle('Bar')
# wrapping a method in an interaction workflow adds a default security to
# wrapping a method in an interaction workflow adds a default security to
# this method if the method does not exists.
# this method if the method does not exists.
self
.
createInteractionWorkflow
()
self
.
createInteractionWorkflow
()
self
.
interaction
.
setProperties
(
self
.
interaction
.
edit
(
'default'
,
trigger_method_id_list
=
(
'nonExistantMethod'
,)
,
method_id
=
'nonExistantMethod'
,
after_script_value
=
self
.
script
,
after_script_name
=
(
'afterEdit'
,)
)
)
self
.
script
.
ZPythonScript_edit
(
'sci'
,
''
)
self
.
script
.
ZPythonScript_edit
(
'sci'
,
''
)
# the default security is "Access contents information"
# the default security is "Access contents information"
self
.
organisation
.
manage_permission
(
self
.
organisation
.
manage_permission
(
...
@@ -629,10 +642,10 @@ context.setTitle('Bar')
...
@@ -629,10 +642,10 @@ context.setTitle('Bar')
# wrapping a method in an interaction workflow adds a default security to
# wrapping a method in an interaction workflow adds a default security to
# this method, but does not override existing security definition
# this method, but does not override existing security definition
self
.
createInteractionWorkflow
()
self
.
createInteractionWorkflow
()
self
.
interaction
.
setProperties
(
self
.
interaction
.
edit
(
'default'
,
trigger_method_id_list
=
(
'setDescription'
,)
,
method_id
=
'setDescription'
,
after_script_value
=
self
.
script
,
after_script_name
=
(
'afterEdit'
,)
)
)
self
.
script
.
ZPythonScript_edit
(
'sci'
,
''
)
self
.
script
.
ZPythonScript_edit
(
'sci'
,
''
)
# This rely on the fact that 'setDescription' is protected with 'Modify
# This rely on the fact that 'setDescription' is protected with 'Modify
# portal content'
# portal content'
...
@@ -651,20 +664,20 @@ context.setTitle('Bar')
...
@@ -651,20 +664,20 @@ context.setTitle('Bar')
security
.
apply
(
Organisation
)
security
.
apply
(
Organisation
)
self
.
createInteractionWorkflow
()
self
.
createInteractionWorkflow
()
self
.
interaction
.
setProperties
(
self
.
interaction
.
edit
(
'default'
,
trigger_method_id_list
=
(
'doSomethingStupid'
,)
,
method_id
=
'doSomethingStupid'
,
after_script_value
=
self
.
script
,
after_script_name
=
(
'afterEdit'
,)
)
)
self
.
script
.
ZPythonScript_edit
(
'sci'
,
''
)
self
.
script
.
ZPythonScript_edit
(
'sci'
,
''
)
self
.
assertEqual
(
self
.
organisation
.
doSomethingStupid__roles__
,
())
self
.
assertEqual
(
self
.
organisation
.
doSomethingStupid__roles__
,
())
def
test_wrap_workflow_transition
(
self
):
def
test_wrap_workflow_transition
(
self
):
self
.
createInteractionWorkflow
()
self
.
createInteractionWorkflow
()
self
.
interaction
.
setProperties
(
self
.
interaction
.
edit
(
'default'
,
trigger_method_id_list
=
(
'validate'
,)
,
method_id
=
'validate'
,
after_script_value
=
self
.
script
,
after_script_name
=
(
'afterEdit'
,)
)
)
params
=
'sci, **kw'
params
=
'sci, **kw'
body
=
"context = sci[
\
'
object
\
'
]
\
n
"
+
\
body
=
"context = sci[
\
'
object
\
'
]
\
n
"
+
\
"context.setDescription('titi')"
"context.setDescription('titi')"
...
@@ -678,12 +691,12 @@ context.setTitle('Bar')
...
@@ -678,12 +691,12 @@ context.setTitle('Bar')
self
.
createInteractionWorkflow
()
self
.
createInteractionWorkflow
()
type_object
=
self
.
portal
.
portal_types
.
getTypeInfo
(
'Bank Account'
)
type_object
=
self
.
portal
.
portal_types
.
getTypeInfo
(
'Bank Account'
)
type_object
.
setTypeWorkflowList
([
'test_workflow'
,
'validation_workflow'
])
type_object
.
setTypeWorkflowList
([
'test_workflow'
,
'validation_workflow'
])
self
.
interaction
.
setProperties
(
self
.
interaction
.
edit
(
'default'
,
# only for bank accounts
# only for bank accounts
portal_type_filter_list
=
[
'Bank Account'
],
portal_type_filter
=
[
'Bank Account'
]
,
trigger_method_id_list
=
(
'getReference'
,)
,
method_id
=
'getReference'
,
after_script_value
=
self
.
script
,
after_script_name
=
(
'afterEdit'
,)
)
)
params
=
'sci, **kw'
params
=
'sci, **kw'
body
=
"context = sci[
\
'
object
\
'
]
\
n
"
+
\
body
=
"context = sci[
\
'
object
\
'
]
\
n
"
+
\
"context.setDescription('modified')"
"context.setDescription('modified')"
...
@@ -703,12 +716,12 @@ context.setTitle('Bar')
...
@@ -703,12 +716,12 @@ context.setTitle('Bar')
self
.
createInteractionWorkflow
()
self
.
createInteractionWorkflow
()
type_object
=
self
.
portal
.
portal_types
.
getTypeInfo
(
'Bank Account'
)
type_object
=
self
.
portal
.
portal_types
.
getTypeInfo
(
'Bank Account'
)
type_object
.
setTypeWorkflowList
([
'test_workflow'
,
'validation_workflow'
])
type_object
.
setTypeWorkflowList
([
'test_workflow'
,
'validation_workflow'
])
self
.
interaction
.
setProperties
(
self
.
interaction
.
edit
(
'default'
,
# only for bank accounts
# only for payment nodes portal type group (ie. bank account)
portal_type_group_filter_list
=
[
'payment_node'
],
portal_type_group_filter
=
[
'payment_node'
]
,
trigger_method_id_list
=
(
'getReference'
,)
,
method_id
=
'getReference'
,
after_script_value
=
self
.
script
,
after_script_name
=
(
'afterEdit'
,)
)
)
params
=
'sci, **kw'
params
=
'sci, **kw'
body
=
"context = sci[
\
'
object
\
'
]
\
n
"
+
\
body
=
"context = sci[
\
'
object
\
'
]
\
n
"
+
\
"context.setDescription('modified')"
"context.setDescription('modified')"
...
...
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