workflows: make sure anchor expression is imported as a string (#39360)

This commit is contained in:
Frédéric Péters 2020-01-29 10:36:29 +01:00
parent 674ca5b687
commit 8b51e62e1e
2 changed files with 16 additions and 2 deletions

View File

@ -628,6 +628,19 @@ def test_global_timeout_trigger(pub):
assert wf2.global_actions[0].triggers[-1].anchor == trigger.anchor
def test_global_anchor_expression_trigger(pub):
wf = Workflow(name='global actions')
ac1 = wf.add_global_action('Action', 'ac1')
trigger = ac1.append_trigger('timeout')
trigger.anchor_expression = 'False'
trigger.anchor = 'python'
wf2 = assert_import_export_works(wf, include_id=True)
assert wf2.global_actions[0].triggers[-1].id == trigger.id
assert wf2.global_actions[0].triggers[-1].anchor == trigger.anchor
assert wf2.global_actions[0].triggers[-1].anchor_expression == trigger.anchor_expression
def test_global_webservice_trigger(pub):
wf = Workflow(name='global actions')
ac1 = wf.add_global_action('Action', 'ac1')

View File

@ -889,7 +889,8 @@ class XmlSerialisable(object):
else:
if el.text is None:
setattr(self, attribute, None)
elif el.text in ('False', 'True'): # bools
elif el.text in ('False', 'True') and not isinstance(getattr(self, attribute), six.string_types):
# booleans
setattr(self, attribute, el.text == 'True')
elif type(getattr(self, attribute)) is int:
setattr(self, attribute, int(el.text))
@ -1041,7 +1042,7 @@ class WorkflowGlobalActionTimeoutTriggerMarker(object):
class WorkflowGlobalActionTimeoutTrigger(WorkflowGlobalActionTrigger):
key = 'timeout'
anchor = None
anchor_expression = None
anchor_expression = ''
anchor_status_first = None
anchor_status_latest = None
timeout = None