Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Products.DCWorkflow
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
Products.DCWorkflow
Commits
4f787f3c
Commit
4f787f3c
authored
Sep 16, 2011
by
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- converted three more tools
parent
b584fbbe
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
90 additions
and
124 deletions
+90
-124
Products/DCWorkflow/CHANGES.txt
Products/DCWorkflow/CHANGES.txt
+2
-0
Products/DCWorkflow/Worklists.py
Products/DCWorkflow/Worklists.py
+4
-5
Products/DCWorkflow/tests/test_DCWorkflow.py
Products/DCWorkflow/tests/test_DCWorkflow.py
+18
-23
Products/DCWorkflow/tests/test_exportimport.py
Products/DCWorkflow/tests/test_exportimport.py
+52
-88
Products/DCWorkflow/tests/test_guard.py
Products/DCWorkflow/tests/test_guard.py
+14
-8
No files found.
Products/DCWorkflow/CHANGES.txt
View file @
4f787f3c
...
...
@@ -4,6 +4,8 @@ Products.DCWorkflow Changelog
2.3.0-alpha (unreleased)
------------------------
- Made sure converted tools are used as utilities.
- Don't crash worklist's ``manage_main`` if variables are Expression objects.
(https://bugs.launchpad.net/zope-cmf/+bug/731394)
...
...
Products/DCWorkflow/Worklists.py
View file @
4f787f3c
...
...
@@ -11,8 +11,6 @@
#
##############################################################################
""" Worklists in a web-configurable workflow.
$Id$
"""
import
re
...
...
@@ -24,8 +22,9 @@ from App.class_init import InitializeClass
from
App.special_dtml
import
DTMLFile
from
OFS.SimpleItem
import
SimpleItem
from
Persistence
import
PersistentMapping
from
zope.component
import
getUtility
from
Products.CMFCore.
utils
import
getToolByName
from
Products.CMFCore.
interfaces
import
ICatalogTool
from
Products.DCWorkflow.ContainerTab
import
ContainerTab
from
Products.DCWorkflow.Expression
import
createExprContext
from
Products.DCWorkflow.Expression
import
Expression
...
...
@@ -169,7 +168,6 @@ class WorklistDefinition(SimpleItem):
if info is None:
info = {}
catalog = getToolByName(self, '
portal_catalog
')
criteria = {}
for key, values in self.var_matches.items():
...
...
@@ -183,7 +181,8 @@ class WorklistDefinition(SimpleItem):
criteria.update(kw)
return catalog.searchResults(**criteria)
ctool = getUtility(ICatalogTool)
return ctool.searchResults(**criteria)
InitializeClass(WorklistDefinition)
...
...
Products/DCWorkflow/tests/test_DCWorkflow.py
View file @
4f787f3c
...
...
@@ -17,11 +17,13 @@ import unittest
import
Testing
import
transaction
from
AccessControl.SecurityManagement
import
newSecurityManager
from
zope.component
import
adapter
from
zope.component
import
getSiteManager
from
zope.component
import
provideHandler
from
zope.interface.verify
import
verifyClass
from
AccessControl.SecurityManagement
import
newSecurityManager
from
Products.CMFCore.interfaces
import
IWorkflowTool
from
Products.CMFCore.testing
import
TraversingEventZCMLLayer
from
Products.CMFCore.tests.base.dummy
import
DummyContent
from
Products.CMFCore.tests.base.dummy
import
DummySite
...
...
@@ -32,16 +34,18 @@ from Products.CMFCore.WorkflowTool import WorkflowTool
from
Products.DCWorkflow.interfaces
import
IAfterTransitionEvent
from
Products.DCWorkflow.interfaces
import
IBeforeTransitionEvent
class
DCWorkflowDefinitionTests
(
SecurityTest
):
layer
=
TraversingEventZCMLLayer
def
setUp
(
self
):
SecurityTest
.
setUp
(
self
)
self
.
root
.
_setObject
(
'site'
,
DummySite
(
'site'
)
)
self
.
site
=
self
.
root
.
_getOb
(
'site'
)
self
.
site
.
_setObject
(
'portal_types'
,
DummyTool
()
)
self
.
site
.
_setObject
(
'portal_workflow'
,
WorkflowTool
()
)
self
.
app
.
_setObject
(
'site'
,
DummySite
(
'site'
))
self
.
site
=
self
.
app
.
_getOb
(
'site'
)
self
.
site
.
_setObject
(
'portal_types'
,
DummyTool
())
self
.
wtool
=
self
.
site
.
_setObject
(
'portal_workflow'
,
WorkflowTool
())
getSiteManager
().
registerUtility
(
self
.
wtool
,
IWorkflowTool
)
self
.
_constructDummyWorkflow
()
transaction
.
savepoint
(
optimistic
=
True
)
newSecurityManager
(
None
,
OmnipotentUser
().
__of__
(
self
.
site
))
...
...
@@ -55,10 +59,10 @@ class DCWorkflowDefinitionTests(SecurityTest):
def
_constructDummyWorkflow
(
self
):
from
Products.DCWorkflow.DCWorkflow
import
DCWorkflowDefinition
w
ftool
=
self
.
site
.
portal_workflow
w
f
tool
.
_setObject
(
'wf'
,
DCWorkflowDefinition
(
'wf'
))
w
f
tool
.
setDefaultChain
(
'wf'
)
wf
=
w
f
tool
.
wf
w
tool
=
self
.
wtool
wtool
.
_setObject
(
'wf'
,
DCWorkflowDefinition
(
'wf'
))
wtool
.
setDefaultChain
(
'wf'
)
wf
=
wtool
.
wf
wf
.
states
.
addState
(
'private'
)
sdef
=
wf
.
states
[
'private'
]
...
...
@@ -79,18 +83,15 @@ class DCWorkflowDefinitionTests(SecurityTest):
wf
.
worklists
.
addWorklist
(
'published_documents'
)
def
_getDummyWorkflow
(
self
):
wftool
=
self
.
site
.
portal_workflow
return
wftool
.
wf
return
self
.
wtool
.
wf
def
test_doActionFor
(
self
):
wftool
=
self
.
site
.
portal_workflow
wtool
=
self
.
wtool
wf
=
self
.
_getDummyWorkflow
()
dummy
=
self
.
site
.
_setObject
(
'dummy'
,
DummyContent
()
)
w
f
tool
.
notifyCreated
(
dummy
)
wtool
.
notifyCreated
(
dummy
)
self
.
assertEqual
(
wf
.
_getStatusOf
(
dummy
),
{
'state'
:
'private'
,
'comments'
:
''
}
)
wf
.
doActionFor
(
dummy
,
'publish'
,
comment
=
'foo'
)
...
...
@@ -100,7 +101,6 @@ class DCWorkflowDefinitionTests(SecurityTest):
# XXX more
def
test_events
(
self
):
events
=
[]
@
adapter
(
IBeforeTransitionEvent
)
...
...
@@ -113,7 +113,6 @@ class DCWorkflowDefinitionTests(SecurityTest):
events
.
append
(
event
)
provideHandler
(
_handleAfter
)
wftool
=
self
.
site
.
portal_workflow
wf
=
self
.
_getDummyWorkflow
()
dummy
=
self
.
site
.
_setObject
(
'dummy'
,
DummyContent
()
)
...
...
@@ -158,11 +157,10 @@ class DCWorkflowDefinitionTests(SecurityTest):
self
.
assertEquals
({
'test'
:
'bar'
,
'comment'
:
'foo'
},
evt
.
kwargs
)
def
test_checkTransitionGuard
(
self
):
wftool
=
self
.
site
.
portal_workflow
wtool
=
self
.
wtool
wf
=
self
.
_getDummyWorkflow
()
dummy
=
self
.
site
.
_setObject
(
'dummy'
,
DummyContent
()
)
w
f
tool
.
notifyCreated
(
dummy
)
wtool
.
notifyCreated
(
dummy
)
self
.
assertEqual
(
wf
.
_getStatusOf
(
dummy
),
{
'state'
:
'private'
,
'comments'
:
''
}
)
...
...
@@ -175,7 +173,6 @@ class DCWorkflowDefinitionTests(SecurityTest):
dummy
,
arg1
=
1
,
arg2
=
2
))
def
test_isActionSupported
(
self
):
wf
=
self
.
_getDummyWorkflow
()
dummy
=
self
.
site
.
_setObject
(
'dummy'
,
DummyContent
()
)
...
...
@@ -186,8 +183,6 @@ class DCWorkflowDefinitionTests(SecurityTest):
self
.
assert_
(
wf
.
isActionSupported
(
dummy
,
'publish'
,
arg1
=
1
,
arg2
=
2
))
def
test_rename
(
self
):
wftool
=
self
.
site
.
portal_workflow
wf
=
self
.
_getDummyWorkflow
()
wf
.
states
.
manage_renameObject
(
'private'
,
'private_new'
)
...
...
Products/DCWorkflow/tests/test_exportimport.py
View file @
4f787f3c
...
...
@@ -70,12 +70,11 @@ class _GuardChecker:
class
_WorkflowSetup
(
WorkflowSetupBase
):
def
_initDCWorkflow
(
self
,
workflow_id
):
def
_initDCWorkflow
(
self
,
wtool
,
workflow_id
):
wtool
.
_setObject
(
workflow_id
,
DCWorkflowDefinition
(
workflow_id
))
wf_tool
=
self
.
root
.
site
.
portal_workflow
wf_tool
.
_setObject
(
workflow_id
,
DCWorkflowDefinition
(
workflow_id
)
)
return
wtool
.
_getOb
(
workflow_id
)
return
wf_tool
.
_getOb
(
workflow_id
)
def
_initVariables
(
self
,
dcworkflow
):
...
...
@@ -207,11 +206,10 @@ class WorkflowDefinitionConfiguratorTests( _WorkflowSetup, _GuardChecker ):
return
WorkflowDefinitionConfigurator
def
test_getWorkflowInfo_dcworkflow_defaults
(
self
):
WF_ID
=
'dcworkflow_defaults'
site
=
self
.
_initSite
()
dcworkflow
=
self
.
_initDCWorkflow
(
WF_ID
)
site
,
wtool
=
self
.
_initSite
()
dcworkflow
=
self
.
_initDCWorkflow
(
wtool
,
WF_ID
)
configurator
=
self
.
_makeOne
(
dcworkflow
).
__of__
(
site
)
info
=
configurator
.
getWorkflowInfo
(
WF_ID
)
...
...
@@ -229,11 +227,10 @@ class WorkflowDefinitionConfiguratorTests( _WorkflowSetup, _GuardChecker ):
self
.
assertEqual
(
len
(
info
[
'transition_info'
]
),
0
)
def
test_getWorkflowInfo_dcworkflow_permissions
(
self
):
WF_ID
=
'dcworkflow_permissions'
site
=
self
.
_initSite
()
dcworkflow
=
self
.
_initDCWorkflow
(
WF_ID
)
site
,
wtool
=
self
.
_initSite
()
dcworkflow
=
self
.
_initDCWorkflow
(
wtool
,
WF_ID
)
dcworkflow
.
permissions
=
_WF_PERMISSIONS
configurator
=
self
.
_makeOne
(
dcworkflow
).
__of__
(
site
)
...
...
@@ -246,11 +243,10 @@ class WorkflowDefinitionConfiguratorTests( _WorkflowSetup, _GuardChecker ):
self
.
failUnless
(
permission
in
permissions
)
def
test_getWorkflowInfo_dcworkflow_variables
(
self
):
WF_ID
=
'dcworkflow_variables'
site
=
self
.
_initSite
()
dcworkflow
=
self
.
_initDCWorkflow
(
WF_ID
)
site
,
wtool
=
self
.
_initSite
()
dcworkflow
=
self
.
_initDCWorkflow
(
wtool
,
WF_ID
)
self
.
_initVariables
(
dcworkflow
)
configurator
=
self
.
_makeOne
(
dcworkflow
).
__of__
(
site
)
...
...
@@ -278,12 +274,11 @@ class WorkflowDefinitionConfiguratorTests( _WorkflowSetup, _GuardChecker ):
self
.
_assertGuard
(
info
,
*
expected
[
-
4
:
]
)
def
test_getWorkflowInfo_dcworkflow_states
(
self
):
WF_ID
=
'dcworkflow_states'
WF_INITIAL_STATE
=
'closed'
site
=
self
.
_initSite
()
dcworkflow
=
self
.
_initDCWorkflow
(
WF_ID
)
site
,
wtool
=
self
.
_initSite
()
dcworkflow
=
self
.
_initDCWorkflow
(
wtool
,
WF_ID
)
dcworkflow
.
initial_state
=
WF_INITIAL_STATE
self
.
_initStates
(
dcworkflow
)
...
...
@@ -351,13 +346,12 @@ class WorkflowDefinitionConfiguratorTests( _WorkflowSetup, _GuardChecker ):
self
.
assertEqual
(
type
,
'string'
)
def
test_getWorkflowInfo_dcworkflow_transitions
(
self
):
from
Products.DCWorkflow.exportimport
import
TRIGGER_TYPES
WF_ID
=
'dcworkflow_transitions'
site
=
self
.
_initSite
()
dcworkflow
=
self
.
_initDCWorkflow
(
WF_ID
)
site
,
wtool
=
self
.
_initSite
()
dcworkflow
=
self
.
_initDCWorkflow
(
wtool
,
WF_ID
)
self
.
_initTransitions
(
dcworkflow
)
configurator
=
self
.
_makeOne
(
dcworkflow
).
__of__
(
site
)
...
...
@@ -397,11 +391,10 @@ class WorkflowDefinitionConfiguratorTests( _WorkflowSetup, _GuardChecker ):
self
.
_assertGuard
(
info
,
*
expected
[
-
4
:
]
)
def
test_getWorkflowInfo_dcworkflow_worklists
(
self
):
WF_ID
=
'dcworkflow_worklists'
site
=
self
.
_initSite
()
dcworkflow
=
self
.
_initDCWorkflow
(
WF_ID
)
site
,
wtool
=
self
.
_initSite
()
dcworkflow
=
self
.
_initDCWorkflow
(
wtool
,
WF_ID
)
self
.
_initWorklists
(
dcworkflow
)
configurator
=
self
.
_makeOne
(
dcworkflow
).
__of__
(
site
)
...
...
@@ -441,11 +434,10 @@ class WorkflowDefinitionConfiguratorTests( _WorkflowSetup, _GuardChecker ):
self
.
_assertGuard
(
info
,
*
expected
[
-
4
:
]
)
def
test_getWorkflowInfo_dcworkflow_scripts
(
self
):
WF_ID
=
'dcworkflow_scripts'
site
=
self
.
_initSite
()
dcworkflow
=
self
.
_initDCWorkflow
(
WF_ID
)
site
,
wtool
=
self
.
_initSite
()
dcworkflow
=
self
.
_initDCWorkflow
(
wtool
,
WF_ID
)
self
.
_initScripts
(
dcworkflow
)
configurator
=
self
.
_makeOne
(
dcworkflow
).
__of__
(
site
)
...
...
@@ -474,19 +466,18 @@ class WorkflowDefinitionConfiguratorTests( _WorkflowSetup, _GuardChecker ):
def
test_getWorkflowInfo_dcworkflow_creation_guard
(
self
)
:
WF_ID
=
'dcworkflow_creation_guard'
site
=
self
.
_initSite
()
dcworkflow
=
self
.
_initDCWorkflow
(
WF_ID
)
_site
,
wtool
=
self
.
_initSite
()
dcworkflow
=
self
.
_initDCWorkflow
(
wtool
,
WF_ID
)
self
.
_initCreationGuard
(
dcworkflow
)
def
test_generateXML_empty
(
self
):
WF_ID
=
'empty'
WF_TITLE
=
'Empty DCWorkflow'
WF_DESCRIPTION
=
'This is a empty workflow'
WF_INITIAL_STATE
=
'initial'
site
=
self
.
_initSite
()
dcworkflow
=
self
.
_initDCWorkflow
(
WF_ID
)
site
,
wtool
=
self
.
_initSite
()
dcworkflow
=
self
.
_initDCWorkflow
(
wtool
,
WF_ID
)
dcworkflow
.
title
=
WF_TITLE
dcworkflow
.
description
=
WF_DESCRIPTION
dcworkflow
.
initial_state
=
WF_INITIAL_STATE
...
...
@@ -501,14 +492,13 @@ class WorkflowDefinitionConfiguratorTests( _WorkflowSetup, _GuardChecker ):
)
)
def
test_generateWorkflowXML_normal
(
self
):
WF_ID
=
'normal'
WF_TITLE
=
'Normal DCWorkflow'
WF_DESCRIPTION
=
'Normal Workflow'
WF_INITIAL_STATE
=
'closed'
site
=
self
.
_initSite
()
dcworkflow
=
self
.
_initDCWorkflow
(
WF_ID
)
site
,
wtool
=
self
.
_initSite
()
dcworkflow
=
self
.
_initDCWorkflow
(
wtool
,
WF_ID
)
dcworkflow
.
title
=
WF_TITLE
dcworkflow
.
description
=
WF_DESCRIPTION
dcworkflow
.
initial_state
=
WF_INITIAL_STATE
...
...
@@ -531,7 +521,6 @@ class WorkflowDefinitionConfiguratorTests( _WorkflowSetup, _GuardChecker ):
}
)
def
test_generateWorkflowXML_multiple
(
self
):
WF_ID_1
=
'dc1'
WF_TITLE_1
=
'Normal DCWorkflow #1'
WF_DESCRIPTION_1
=
'Normal Number 1'
...
...
@@ -540,9 +529,9 @@ class WorkflowDefinitionConfiguratorTests( _WorkflowSetup, _GuardChecker ):
WF_DESCRIPTION_2
=
'Normal Numer 2'
WF_INITIAL_STATE
=
'closed'
site
=
self
.
_initSite
()
site
,
wtool
=
self
.
_initSite
()
dcworkflow_1
=
self
.
_initDCWorkflow
(
WF_ID_1
)
dcworkflow_1
=
self
.
_initDCWorkflow
(
wtool
,
WF_ID_1
)
dcworkflow_1
.
title
=
WF_TITLE_1
dcworkflow_1
.
description
=
WF_DESCRIPTION_1
dcworkflow_1
.
initial_state
=
WF_INITIAL_STATE
...
...
@@ -553,7 +542,7 @@ class WorkflowDefinitionConfiguratorTests( _WorkflowSetup, _GuardChecker ):
self
.
_initWorklists
(
dcworkflow_1
)
self
.
_initScripts
(
dcworkflow_1
)
dcworkflow_2
=
self
.
_initDCWorkflow
(
WF_ID_2
)
dcworkflow_2
=
self
.
_initDCWorkflow
(
wtool
,
WF_ID_2
)
dcworkflow_2
.
title
=
WF_TITLE_2
dcworkflow_2
.
description
=
WF_DESCRIPTION_2
dcworkflow_2
.
initial_state
=
WF_INITIAL_STATE
...
...
@@ -587,13 +576,12 @@ class WorkflowDefinitionConfiguratorTests( _WorkflowSetup, _GuardChecker ):
}
)
def
test_parseWorkflowXML_empty
(
self
):
WF_ID
=
'empty'
WF_TITLE
=
'Empty DCWorkflow'
WF_DESCRIPTION
=
'This is an empty workflow'
WF_INITIAL_STATE
=
'initial'
site
=
self
.
_initSite
()
site
,
_wtool
=
self
.
_initSite
()
configurator
=
self
.
_makeOne
(
site
).
__of__
(
site
)
...
...
@@ -626,13 +614,12 @@ class WorkflowDefinitionConfiguratorTests( _WorkflowSetup, _GuardChecker ):
self
.
assertEqual
(
len
(
scripts
),
0
)
def
test_parseWorkflowXML_normal_attribs
(
self
):
WF_ID
=
'normal'
WF_TITLE
=
'Normal DCWorkflow'
WF_DESCRIPTION
=
'This is a normal DCWorkflow'
WF_INITIAL_STATE
=
'closed'
site
=
self
.
_initSite
()
site
,
_wtool
=
self
.
_initSite
()
configurator
=
self
.
_makeOne
(
site
).
__of__
(
site
)
...
...
@@ -665,13 +652,12 @@ class WorkflowDefinitionConfiguratorTests( _WorkflowSetup, _GuardChecker ):
self
.
assertEqual
(
initial_state
,
WF_INITIAL_STATE
)
def
test_parseWorkflowXML_normal_states
(
self
):
WF_ID
=
'normal'
WF_TITLE
=
'Normal DCWorkflow'
WF_DESCRIPTION
=
'Normal workflow'
WF_INITIAL_STATE
=
'closed'
site
=
self
.
_initSite
()
site
,
_wtool
=
self
.
_initSite
()
configurator
=
self
.
_makeOne
(
site
).
__of__
(
site
)
...
...
@@ -731,13 +717,12 @@ class WorkflowDefinitionConfiguratorTests( _WorkflowSetup, _GuardChecker ):
self
.
assertEqual
(
v_info
[
'type'
],
'string'
)
def
test_parseWorkflowXML_state_w_missing_acquired
(
self
):
WF_ID
=
'missing_acquired'
WF_TITLE
=
'DCWorkflow w/o acquired on state'
WF_DESCRIPTION
=
WF_TITLE
WF_INITIAL_STATE
=
'closed'
site
=
self
.
_initSite
()
site
,
_wtool
=
self
.
_initSite
()
configurator
=
self
.
_makeOne
(
site
).
__of__
(
site
)
...
...
@@ -783,7 +768,6 @@ class WorkflowDefinitionConfiguratorTests( _WorkflowSetup, _GuardChecker ):
,
tuple
(
expected
[
4
]
)
)
def
test_parseWorkflowXML_normal_transitions
(
self
):
from
Products.DCWorkflow.exportimport
import
TRIGGER_TYPES
WF_ID
=
'normal'
...
...
@@ -791,7 +775,7 @@ class WorkflowDefinitionConfiguratorTests( _WorkflowSetup, _GuardChecker ):
WF_DESCRIPTION
=
'Normal workflow'
WF_INITIAL_STATE
=
'closed'
site
=
self
.
_initSite
()
site
,
_wtool
=
self
.
_initSite
()
configurator
=
self
.
_makeOne
(
site
).
__of__
(
site
)
...
...
@@ -856,13 +840,12 @@ class WorkflowDefinitionConfiguratorTests( _WorkflowSetup, _GuardChecker ):
self
.
assertEqual
(
guard
.
get
(
'expression'
,
''
),
expected
[
14
]
)
def
test_parseWorkflowXML_normal_variables
(
self
):
WF_ID
=
'normal'
WF_TITLE
=
'Normal DCWorkflow'
WF_DESCRIPTION
=
'Normal workflow'
WF_INITIAL_STATE
=
'closed'
site
=
self
.
_initSite
()
site
,
_wtool
=
self
.
_initSite
()
configurator
=
self
.
_makeOne
(
site
).
__of__
(
site
)
...
...
@@ -936,13 +919,12 @@ class WorkflowDefinitionConfiguratorTests( _WorkflowSetup, _GuardChecker ):
self
.
assertEqual
(
guard
.
get
(
'expression'
,
''
),
expected
[
9
]
)
def
test_parseWorkflowXML_w_variables_missing_attrs
(
self
):
WF_ID
=
'normal'
WF_TITLE
=
'DCWorkflow w/ missing attrs'
WF_DESCRIPTION
=
WF_TITLE
WF_INITIAL_STATE
=
'closed'
site
=
self
.
_initSite
()
site
,
_wtool
=
self
.
_initSite
()
configurator
=
self
.
_makeOne
(
site
).
__of__
(
site
)
...
...
@@ -1016,13 +998,12 @@ class WorkflowDefinitionConfiguratorTests( _WorkflowSetup, _GuardChecker ):
self
.
assertEqual
(
guard
.
get
(
'expression'
,
''
),
expected
[
9
]
)
def
test_parseWorkflowXML_normal_worklists
(
self
):
WF_ID
=
'normal'
WF_TITLE
=
'Normal DCWorkflow'
WF_DESCRIPTION
=
'Normal workflow'
WF_INITIAL_STATE
=
'closed'
site
=
self
.
_initSite
()
site
,
_wtool
=
self
.
_initSite
()
configurator
=
self
.
_makeOne
(
site
).
__of__
(
site
)
...
...
@@ -1081,13 +1062,12 @@ class WorkflowDefinitionConfiguratorTests( _WorkflowSetup, _GuardChecker ):
self
.
assertEqual
(
guard
.
get
(
'expression'
,
''
),
expected
[
10
]
)
def
test_parseWorkflowXML_normal_permissions
(
self
):
WF_ID
=
'normal'
WF_TITLE
=
'Normal DCWorkflow'
WF_DESCRIPTION
=
'Normal workflow'
WF_INITIAL_STATE
=
'closed'
site
=
self
.
_initSite
()
site
,
_wtool
=
self
.
_initSite
()
configurator
=
self
.
_makeOne
(
site
).
__of__
(
site
)
...
...
@@ -1120,13 +1100,12 @@ class WorkflowDefinitionConfiguratorTests( _WorkflowSetup, _GuardChecker ):
self
.
failUnless
(
permission
in
_WF_PERMISSIONS
)
def
test_parseWorkflowXML_normal_scripts
(
self
):
WF_ID
=
'normal'
WF_TITLE
=
'Normal DCWorkflow'
WF_DESCRIPTION
=
'Normal workflow'
WF_INITIAL_STATE
=
'closed'
site
=
self
.
_initSite
()
site
,
_wtool
=
self
.
_initSite
()
configurator
=
self
.
_makeOne
(
site
).
__of__
(
site
)
...
...
@@ -2544,7 +2523,7 @@ class Test_exportWorkflow(_WorkflowSetup, _GuardChecker):
def
test_empty
(
self
):
from
Products.CMFCore.exportimport.workflow
import
exportWorkflowTool
site
=
self
.
_initSite
()
site
,
_wtool
=
self
.
_initSite
()
context
=
DummyExportContext
(
site
)
exportWorkflowTool
(
context
)
...
...
@@ -2565,15 +2544,14 @@ class Test_exportWorkflow(_WorkflowSetup, _GuardChecker):
WF_DESCRIPTION_DC
=
'I am a DCWorkflow'
WF_INITIAL_STATE
=
'closed'
site
=
self
.
_initSite
()
site
,
wtool
=
self
.
_initSite
()
wf_tool
=
site
.
portal_workflow
nondcworkflow
=
DummyWorkflow
(
WF_TITLE_NON
)
nondcworkflow
.
title
=
WF_TITLE_NON
nondcworkflow
.
description
=
WF_DESCRIPTION_NON
w
f_tool
.
_setObject
(
WF_ID_NON
,
nondcworkflow
)
w
tool
.
_setObject
(
WF_ID_NON
,
nondcworkflow
)
dcworkflow
=
self
.
_initDCWorkflow
(
WF_ID_DC
)
dcworkflow
=
self
.
_initDCWorkflow
(
wtool
,
WF_ID_DC
)
dcworkflow
.
title
=
WF_TITLE_DC
dcworkflow
.
description
=
WF_DESCRIPTION_DC
dcworkflow
.
initial_state
=
WF_INITIAL_STATE
...
...
@@ -2621,9 +2599,8 @@ class Test_exportWorkflow(_WorkflowSetup, _GuardChecker):
WF_DESCRIPTION_DC
=
'Workflow w/spaces'
WF_INITIAL_STATE
=
'closed'
site
=
self
.
_initSite
()
dcworkflow
=
self
.
_initDCWorkflow
(
WF_ID_DC
)
site
,
wtool
=
self
.
_initSite
()
dcworkflow
=
self
.
_initDCWorkflow
(
wtool
,
WF_ID_DC
)
dcworkflow
.
title
=
WF_TITLE_DC
dcworkflow
.
description
=
WF_DESCRIPTION_DC
dcworkflow
.
initial_state
=
WF_INITIAL_STATE
...
...
@@ -2674,17 +2651,18 @@ class Test_importWorkflow(_WorkflowSetup, _GuardChecker):
wf_description
,
wf_initial_state
):
from
Products.CMFCore.exportimport.workflow
import
importWorkflowTool
site
,
context
=
self
.
_prepareImportNormalWorkflow
(
_
site
,
context
=
self
.
_prepareImportNormalWorkflow
(
wf_id
,
wf_title
,
wf_description
,
wf_initial_state
)
importWorkflowTool
(
context
)
return
s
ite
.
portal_workflow
return
s
elf
.
wtool
def
_prepareImportNormalWorkflow
(
self
,
wf_id
,
wf_title
,
wf_description
,
wf_initial_state
,
site
=
None
,
purge
=
True
):
if
site
is
None
:
site
=
self
.
_initSite
()
site
,
wtool
=
self
.
_initSite
()
self
.
wtool
=
wtool
workflow_filename
=
wf_id
.
replace
(
' '
,
'_'
)
context
=
DummyImportContext
(
site
,
purge
=
purge
)
...
...
@@ -2719,8 +2697,7 @@ class Test_importWorkflow(_WorkflowSetup, _GuardChecker):
def
_importOldWorkflow
(
self
,
wf_id
,
wf_title
,
wf_initial_state
):
from
Products.CMFCore.exportimport.workflow
import
importWorkflowTool
site
=
self
.
_initSite
()
wf_tool
=
site
.
portal_workflow
site
,
wf_tool
=
self
.
_initSite
()
workflow_filename
=
wf_id
.
replace
(
' '
,
'_'
)
context
=
DummyImportContext
(
site
)
...
...
@@ -2758,8 +2735,7 @@ class Test_importWorkflow(_WorkflowSetup, _GuardChecker):
WF_ID_NON
=
'non_dcworkflow_%s'
WF_TITLE_NON
=
'Non-DCWorkflow #%s'
site
=
self
.
_initSite
()
wf_tool
=
site
.
portal_workflow
site
,
wf_tool
=
self
.
_initSite
()
for
i
in
range
(
4
):
nondcworkflow
=
DummyWorkflow
(
WF_TITLE_NON
%
i
)
...
...
@@ -2784,8 +2760,7 @@ class Test_importWorkflow(_WorkflowSetup, _GuardChecker):
WF_ID_NON
=
'non_dcworkflow_%s'
WF_TITLE_NON
=
'Non-DCWorkflow #%s'
site
=
self
.
_initSite
()
wf_tool
=
site
.
portal_workflow
site
,
wf_tool
=
self
.
_initSite
()
for
i
in
range
(
4
):
nondcworkflow
=
DummyWorkflow
(
WF_TITLE_NON
%
i
)
...
...
@@ -2810,8 +2785,7 @@ class Test_importWorkflow(_WorkflowSetup, _GuardChecker):
WF_ID_NON
=
'non_dcworkflow_%s'
WF_TITLE_NON
=
'Non-DCWorkflow #%s'
site
=
self
.
_initSite
()
wf_tool
=
site
.
portal_workflow
site
,
wf_tool
=
self
.
_initSite
()
for
i
in
range
(
4
):
nondcworkflow
=
DummyWorkflow
(
WF_TITLE_NON
%
i
)
...
...
@@ -2840,8 +2814,7 @@ class Test_importWorkflow(_WorkflowSetup, _GuardChecker):
WF_ID_NON
=
'non_dcworkflow_%s'
WF_TITLE_NON
=
'Non-DCWorkflow #%s'
site
=
self
.
_initSite
()
wf_tool
=
site
.
portal_workflow
site
,
wf_tool
=
self
.
_initSite
()
for
i
in
range
(
4
):
nondcworkflow
=
DummyWorkflow
(
WF_TITLE_NON
%
i
)
...
...
@@ -2886,7 +2859,7 @@ class Test_importWorkflow(_WorkflowSetup, _GuardChecker):
WF_ID
,
WF_TITLE
,
WF_DESCRIPTION
,
WF_INITIAL_STATE
,
site
=
site
,
purge
=
False
)
importWorkflowTool
(
context
)
workflow
=
s
ite
.
portal_workflow
.
objectValues
()[
1
]
workflow
=
s
elf
.
wtool
.
objectValues
()[
1
]
self
.
assertEqual
(
workflow
.
getId
(),
WF_ID
)
self
.
assertEqual
(
workflow
.
meta_type
,
DCWorkflowDefinition
.
meta_type
)
...
...
@@ -2908,7 +2881,6 @@ class Test_importWorkflow(_WorkflowSetup, _GuardChecker):
def
test_from_empty_dcworkflow_top_level
(
self
):
WF_ID
=
'dcworkflow_tool'
WF_TITLE
=
'DC Workflow testing tool'
WF_DESCRIPTION
=
'Testing Tool'
...
...
@@ -2921,7 +2893,6 @@ class Test_importWorkflow(_WorkflowSetup, _GuardChecker):
self
.
assertEqual
(
tool
.
objectIds
()[
1
],
WF_ID
)
def
test_from_empty_dcworkflow_workflow_attrs
(
self
):
WF_ID
=
'dcworkflow_attrs'
WF_TITLE
=
'DC Workflow testing attrs'
WF_DESCRIPTION
=
'Testing Attributes'
...
...
@@ -2937,7 +2908,6 @@ class Test_importWorkflow(_WorkflowSetup, _GuardChecker):
self
.
assertEqual
(
workflow
.
initial_state
,
WF_INITIAL_STATE
)
def
test_from_empty_dcworkflow_workflow_permissions
(
self
):
WF_ID
=
'dcworkflow_permissions'
WF_TITLE
=
'DC Workflow testing permissions'
WF_DESCRIPTION
=
'Testing Permissions'
...
...
@@ -2955,7 +2925,6 @@ class Test_importWorkflow(_WorkflowSetup, _GuardChecker):
self
.
failUnless
(
permission
in
_WF_PERMISSIONS
)
def
test_from_empty_dcworkflow_workflow_variables
(
self
):
WF_ID
=
'dcworkflow_variables'
WF_TITLE
=
'DC Workflow testing variables'
WF_DESCRIPTION
=
'Testing Variables'
...
...
@@ -2989,7 +2958,6 @@ class Test_importWorkflow(_WorkflowSetup, _GuardChecker):
self
.
assertEqual
(
guard
.
getExprText
(),
expected
[
9
]
)
def
test_from_empty_dcworkflow_workflow_states
(
self
):
WF_ID
=
'dcworkflow_states'
WF_TITLE
=
'DC Workflow testing states'
WF_DESCRIPTION
=
'Testing States'
...
...
@@ -3048,7 +3016,6 @@ class Test_importWorkflow(_WorkflowSetup, _GuardChecker):
self
.
assertEqual
(
value
,
expected
[
5
][
var_id
]
)
def
test_from_empty_dcworkflow_workflow_transitions
(
self
):
WF_ID
=
'dcworkflow_transitions'
WF_TITLE
=
'DC Workflow testing transitions'
WF_DESCRIPTION
=
'Testing Transitions'
...
...
@@ -3093,7 +3060,6 @@ class Test_importWorkflow(_WorkflowSetup, _GuardChecker):
self
.
assertEqual
(
guard
.
getExprText
(),
expected
[
14
]
)
def
test_from_empty_dcworkflow_workflow_worklists
(
self
):
WF_ID
=
'dcworkflow_worklists'
WF_TITLE
=
'DC Workflow testing worklists'
WF_DESCRIPTION
=
'Testing Worklists'
...
...
@@ -3138,7 +3104,6 @@ class Test_importWorkflow(_WorkflowSetup, _GuardChecker):
self
.
assertEqual
(
guard
.
getExprText
(),
expected
[
10
]
)
def
test_from_old_dcworkflow_workflow_scripts
(
self
):
WF_ID
=
'old_dcworkflow_scripts'
WF_TITLE
=
'Old DC Workflow testing scripts'
WF_INITIAL_STATE
=
'closed'
...
...
@@ -3162,7 +3127,6 @@ class Test_importWorkflow(_WorkflowSetup, _GuardChecker):
self
.
assertEqual
(
script
.
manage_FTPget
(),
expected
[
1
]
)
def
test_from_empty_dcworkflow_workflow_scripts
(
self
):
WF_ID
=
'dcworkflow_scripts'
WF_TITLE
=
'DC Workflow testing scripts'
WF_DESCRIPTION
=
'Testing Scripts'
...
...
Products/DCWorkflow/tests/test_guard.py
View file @
4f787f3c
...
...
@@ -17,29 +17,35 @@ import unittest
import
Testing
from
AccessControl
import
getSecurityManager
from
zope.component
import
getSiteManager
from
zope.testing.cleanup
import
cleanUp
from
Products.CMFCore.interfaces
import
IWorkflowTool
from
Products.CMFCore.tests.base.dummy
import
DummyContent
from
Products.CMFCore.tests.base.dummy
import
DummySite
from
Products.CMFCore.tests.base.dummy
import
DummyTool
from
Products.CMFCore.WorkflowTool
import
WorkflowTool
from
Products.DCWorkflow.Guard
import
Guard
from
Products.DCWorkflow.DCWorkflow
import
DCWorkflowDefinition
from
Products.DCWorkflow.Guard
import
Guard
class
TestGuard
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
site
=
DummySite
(
'site'
)
self
.
site
.
_setObject
(
'portal_types'
,
DummyTool
()
)
self
.
site
.
_setObject
(
'portal_workflow'
,
WorkflowTool
()
)
self
.
site
.
_setObject
(
'portal_types'
,
DummyTool
())
# Construct a workflow
wftool
=
self
.
site
.
portal_workflow
wftool
.
_setObject
(
'wf'
,
DCWorkflowDefinition
(
'wf'
))
wftool
.
setDefaultChain
(
'wf'
)
self
.
wtool
=
WorkflowTool
()
self
.
wtool
.
_setObject
(
'wf'
,
DCWorkflowDefinition
(
'wf'
))
self
.
wtool
.
setDefaultChain
(
'wf'
)
getSiteManager
().
registerUtility
(
self
.
wtool
,
IWorkflowTool
)
def
tearDown
(
self
):
cleanUp
()
def
_getDummyWorkflow
(
self
):
return
self
.
site
.
portal_workflow
[
'wf'
]
return
self
.
wtool
.
wf
def
test_BaseGuardAPI
(
self
):
from
zope.tales.tales
import
CompilerError
...
...
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