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
Binh
erp5
Commits
06c9fdb8
Commit
06c9fdb8
authored
Mar 06, 2015
by
wenjie.zheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_workflow: testerp5anddcworkflow, add workflow history test and other test.
parent
bee8b076
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
20 deletions
+57
-20
bt5/erp5_workflow/TestTemplateItem/portal_components/test.erp5.testerp5anddcworkflow.py
...Item/portal_components/test.erp5.testerp5anddcworkflow.py
+57
-20
No files found.
bt5/erp5_workflow/TestTemplateItem/portal_components/test.erp5.testerp5anddcworkflow.py
View file @
06c9fdb8
...
@@ -3,14 +3,11 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
...
@@ -3,14 +3,11 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from
Products.ERP5Type.Utils
import
convertToUpperCase
,
convertToMixedCase
from
Products.ERP5Type.Utils
import
convertToUpperCase
,
convertToMixedCase
class
TestERP5WorkflowMixin
(
ERP5TypeTestCase
):
class
TestERP5WorkflowMixin
(
ERP5TypeTestCase
):
def
getBusinessTemplateList
(
self
):
"""Returns list of BT to be installed."""
return
(
'erp5_workflow'
,)
def
getTestObject
(
self
):
def
getTestObject
(
self
):
self
.
portal
=
self
.
getPortal
()
self
.
portal
=
self
.
getPortal
()
type_test_object
=
self
.
portal
.
portal_types
.
_getOb
(
'ERP5Workflow Test Object'
)
type_test_object
=
self
.
portal
.
portal_types
.
_getOb
(
'ERP5Workflow Test Object'
)
test_object
=
self
.
portal
.
erp5workflow_test_module
.
newContent
(
portal_type
=
'ERP5Workflow Test Object'
,
id
=
'erp5_test_object'
)
test_object
=
self
.
portal
.
erp5workflow_test_module
.
newContent
(
portal_type
=
'ERP5Workflow Test Object'
)
return
test_object
return
test_object
def
doActionFor
():
def
doActionFor
():
...
@@ -19,39 +16,63 @@ class TestERP5WorkflowMixin(ERP5TypeTestCase):
...
@@ -19,39 +16,63 @@ class TestERP5WorkflowMixin(ERP5TypeTestCase):
"""
"""
raise
NotImplemented
raise
NotImplemented
def
getStateFor
():
"""
Needs to be overidden
"""
raise
NotImplemented
def
resetComponentTool
(
self
):
# Force reset of portal_components to regenerate accessors
# Since it is already handled by interactions, we only need to commit
# to allow component tool to do it's reset
self
.
commit
()
def
test_01_testAfterScript
(
self
):
def
test_01_testAfterScript
(
self
):
new_object
=
self
.
getTestObject
()
new_object
=
self
.
getTestObject
()
self
.
doActionFor
(
new_object
,
"validate"
)
self
.
doActionFor
(
new_object
,
"validate"
)
self
.
assertEqual
(
new_object
.
getDescription
(),
"After script was executed."
)
self
.
assertEqual
(
new_object
.
getDescription
(),
"After script was executed."
)
#self.assertEqual(new_object.getValidationState(), "validated")
def
test_02_testBeforeScript
(
self
):
def
test_02_testBeforeScript
(
self
):
new_object
=
self
.
getTestObject
()
new_object
=
self
.
getTestObject
()
self
.
doActionFor
(
new_object
,
"validate"
)
self
.
doActionFor
(
new_object
,
"validate"
)
self
.
doActionFor
(
new_object
,
"invalidate"
)
self
.
doActionFor
(
new_object
,
"invalidate"
)
#new_object.invalidate()
self
.
assertEqual
(
new_object
.
getDescription
(),
"Before script was executed."
)
self
.
assertEqual
(
new_object
.
getDescription
(),
"Before script was executed."
)
#self.assertEqual(new_object.getValidationState(), "invalidated")
def
checkPermissionAreWellSet
(
self
):
pass
# what should be test?
def
test_03_testChangeOfState
(
self
):
def
test_03_testChangeOfState
(
self
):
pass
new_object
=
self
.
getTestObject
()
self
.
doActionFor
(
new_object
,
"validate"
)
self
.
doActionFor
(
new_object
,
"invalidate"
)
self
.
assertEqual
(
self
.
getStateFor
(
new_object
),
'invalidated'
)
# Doesn't exist yet
def
test_04_testDoWorkflowMethodTransition
(
self
):
new_object
=
self
.
getTestObject
()
self
.
assertEqual
(
self
.
getStateFor
(
new_object
),
'draft'
)
# change state through a workflow method
getattr
(
new_object
,
'validate'
)()
self
.
assertEqual
(
self
.
getStateFor
(
new_object
),
'validated'
)
def
test_05_testCheckHistoryForASingleTransition
(
self
):
new_object
=
self
.
getTestObject
()
self
.
doActionFor
(
new_object
,
"validate"
)
#print new_object.workflow_history
raise
NotImplementedError
(
new_object
.
workflow_history
)
def
test_06_testCheckPermissionAreWellSet
(
self
):
new_object
=
self
.
getTestObject
()
self
.
assertEqual
(
new_object
.
_View_Permission
,
(
'Assignee'
,
'Assignor'
,
'Associate'
,
'Auditor'
,
'Author'
,
'Manager'
,
'Owner'
))
self
.
doActionFor
(
new_object
,
"validate"
)
self
.
assertEqual
(
new_object
.
_View_Permission
,
(
'Assignee'
,
'Assignor'
,
'Associate'
,
'Auditor'
,
'Manager'
))
### Doesn't exist yet
def
_testUserAction
(
self
):
def
_testUserAction
(
self
):
organisation
=
self
.
getOrganisation
()
organisation
=
self
.
getOrganisation
()
self
.
doActionFor
(
organisation
,
"validate_action"
)
self
.
doActionFor
(
organisation
,
"validate_action"
)
self
.
assertEqual
(
organisation
.
getDescription
(),
"before script has been called"
)
self
.
assertEqual
(
organisation
.
getDescription
(),
"before script has been called"
)
def
checkRaiseValidationFailed
(
self
):
def
checkRaiseValidationFailed
(
self
):
pass
pass
def
_testSimpleWorklist
(
self
):
def
_testSimpleWorklist
(
self
):
pass
pass
def
_testWorklistWithAnAssignee
(
self
):
def
_testWorklistWithAnAssignee
(
self
):
pass
pass
...
@@ -61,17 +82,23 @@ class TestERP5Workflow(TestERP5WorkflowMixin):
...
@@ -61,17 +82,23 @@ class TestERP5Workflow(TestERP5WorkflowMixin):
"""
"""
def
afterSetUp
(
self
):
def
afterSetUp
(
self
):
self
.
portal
=
self
.
getPortal
()
self
.
portal
=
self
.
getPortal
()
self
.
getWorkflowTool
().
setChainForPortalTypes
([
'ERP5Workflow Test Object'
],
())
self
.
workflow_module
=
self
.
portal
.
workflow_module
self
.
workflow_module
=
self
.
portal
.
workflow_module
self
.
wf
=
self
.
workflow_module
.
_getOb
(
'erp5_validation_workflow'
)
self
.
wf
=
self
.
workflow_module
.
_getOb
(
'erp5_validation_workflow'
)
type_test_object
=
self
.
portal
.
portal_types
.
_getOb
(
'ERP5Workflow Test Object'
)
type_test_object
=
self
.
portal
.
portal_types
.
_getOb
(
'ERP5Workflow Test Object'
)
type_test_object
.
edit
(
type_base_category_list
=
(
'validation_state'
,))
type_test_object
.
edit
(
type_base_category_list
=
(
'validation_state'
,))
type_test_object
.
edit
(
type_erp5workflow_list
=
(
'erp5_validation_workflow'
,))
type_test_object
.
edit
(
type_erp5workflow_list
=
(
'erp5_validation_workflow'
,))
self
.
resetComponentTool
()
self
.
login
()
# as Manager
self
.
login
()
# as Manager
def
doActionFor
(
self
,
document
,
action
):
def
doActionFor
(
self
,
document
,
action
):
#self.wf._getOb(action).execute(document)
# check dc_test_workflow is not in use
self
.
assertFalse
(
'dc_test_workflow'
in
self
.
getWorkflowTool
().
getChainFor
(
document
.
getTypeInfo
().
getId
()))
getattr
(
document
,
convertToMixedCase
(
action
))()
getattr
(
document
,
convertToMixedCase
(
action
))()
def
getStateFor
(
self
,
document
):
return
getattr
(
document
,
'getValidationState'
)()
class
TestDCWorkflow
(
TestERP5WorkflowMixin
):
class
TestDCWorkflow
(
TestERP5WorkflowMixin
):
"""
"""
Check DC Workflow
Check DC Workflow
...
@@ -80,14 +107,24 @@ class TestDCWorkflow(TestERP5WorkflowMixin):
...
@@ -80,14 +107,24 @@ class TestDCWorkflow(TestERP5WorkflowMixin):
# make sure erp5 workflow list is empty
# make sure erp5 workflow list is empty
self
.
portal
=
self
.
getPortal
()
self
.
portal
=
self
.
getPortal
()
self
.
workflow_module
=
self
.
portal
.
portal_workflow
self
.
workflow_module
=
self
.
portal
.
portal_workflow
self
.
getWorkflowTool
().
setChainForPortalTypes
([
'ERP5Workflow Test Object'
],
(
'dc_test_workflow'
))
self
.
wf
=
self
.
workflow_module
.
_getOb
(
'dc_test_workflow'
)
self
.
wf
=
self
.
workflow_module
.
_getOb
(
'dc_test_workflow'
)
type_test_object
=
self
.
portal
.
portal_types
.
_getOb
(
'ERP5Workflow Test Object'
)
type_test_object
.
edit
(
type_base_category_list
=
())
type_test_object
.
edit
(
type_erp5workflow_list
=
())
self
.
resetComponentTool
()
self
.
login
()
self
.
login
()
def
doActionFor
(
self
,
document
,
action
):
def
doActionFor
(
self
,
document
,
action
):
#self.wf.DCWorkflowDefinition_executeTransition(document, )
self
.
assertTrue
(
self
.
wf
.
getId
()
in
self
.
getWorkflowTool
().
getChainFor
(
document
.
getTypeInfo
().
getId
()))
# check erp5workflow is not in use
self
.
assertEqual
(
document
.
getTypeInfo
().
getTypeErp5workflowList
(),
[])
user_action
=
action
+
'_action'
user_action
=
action
+
'_action'
self
.
portal
.
portal_workflow
.
doActionFor
(
document
,
user_action
,
wf_id
=
self
.
wf
.
getId
())
self
.
portal
.
portal_workflow
.
doActionFor
(
document
,
user_action
,
wf_id
=
self
.
wf
.
getId
())
#getattr(document, convertToMixedCase(action))()
def
getStateFor
(
self
,
document
):
return
self
.
wf
.
_getWorkflowStateOf
(
document
,
id_only
=
True
)
def
test_suite
():
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
=
unittest
.
TestSuite
()
...
...
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