53 |
53 |
|
54 |
54 |
def test_empty(pub):
|
55 |
55 |
wf = Workflow(name='empty')
|
56 |
|
assert_import_export_works(wf)
|
|
56 |
assert_xml_import_export_works(wf)
|
57 |
57 |
|
58 |
58 |
def test_status(pub):
|
59 |
59 |
wf = Workflow(name='status')
|
60 |
60 |
st1 = wf.add_status('Status1', 'st1')
|
61 |
61 |
st2 = wf.add_status('Status2', 'st2')
|
62 |
|
assert_import_export_works(wf)
|
|
62 |
assert_xml_import_export_works(wf)
|
63 |
63 |
|
64 |
64 |
def test_status_actions(pub):
|
65 |
65 |
wf = Workflow(name='status')
|
... | ... | |
72 |
72 |
st1.items.append(commentable)
|
73 |
73 |
commentable.parent = st1
|
74 |
74 |
|
75 |
|
assert_import_export_works(wf)
|
|
75 |
assert_xml_import_export_works(wf)
|
76 |
76 |
|
77 |
77 |
def test_status_colour_css_class(pub):
|
78 |
78 |
wf = Workflow(name='status')
|
... | ... | |
80 |
80 |
st1.extra_css_class = 'hello'
|
81 |
81 |
st1.colour = 'FF0000'
|
82 |
82 |
st2 = wf.add_status('Status2', 'st2')
|
83 |
|
assert_import_export_works(wf)
|
|
83 |
assert_xml_import_export_works(wf)
|
84 |
84 |
|
85 |
85 |
def test_status_forced_endpoint(pub):
|
86 |
86 |
wf = Workflow(name='status')
|
87 |
87 |
st1 = wf.add_status('Status1', 'st1')
|
88 |
88 |
st1.forced_endpoint = True
|
89 |
89 |
st2 = wf.add_status('Status2', 'st2')
|
90 |
|
wf2 = assert_import_export_works(wf)
|
|
90 |
wf2 = assert_xml_import_export_works(wf)
|
91 |
91 |
assert wf2.possible_status[0].forced_endpoint is True
|
92 |
92 |
assert wf2.possible_status[1].forced_endpoint is False
|
93 |
93 |
|
94 |
94 |
def test_default_wf(pub):
|
95 |
95 |
wf = Workflow.get_default_workflow()
|
96 |
|
assert_import_export_works(wf)
|
|
96 |
assert_xml_import_export_works(wf)
|
97 |
97 |
|
98 |
98 |
|
99 |
99 |
def test_action_dispatch(pub):
|
... | ... | |
115 |
115 |
st1.items.append(dispatch)
|
116 |
116 |
dispatch.parent = st1
|
117 |
117 |
|
118 |
|
wf2 = assert_import_export_works(wf)
|
|
118 |
wf2 = assert_xml_import_export_works(wf)
|
119 |
119 |
|
120 |
120 |
# checks role id is imported as integer
|
121 |
121 |
assert(wf2.possible_status[0].items[0].role_id == '5')
|
... | ... | |
124 |
124 |
# now roles are managed: cannot create them
|
125 |
125 |
dispatch.role_id = 'unknown'
|
126 |
126 |
with pytest.raises(WorkflowImportError, match=r'.*Unknown referenced role.*'):
|
127 |
|
wf2 = assert_import_export_works(wf)
|
|
127 |
wf2 = assert_xml_import_export_works(wf)
|
128 |
128 |
# but allow computed roles
|
129 |
129 |
dispatch.role_id = '=form_var_bar'
|
130 |
|
wf2 = assert_import_export_works(wf)
|
|
130 |
wf2 = assert_xml_import_export_works(wf)
|
131 |
131 |
assert(wf2.possible_status[0].items[0].role_id == '=form_var_bar')
|
132 |
132 |
dispatch.role_id = 'Role {{ form_var_foo }}'
|
133 |
|
wf2 = assert_import_export_works(wf)
|
|
133 |
wf2 = assert_xml_import_export_works(wf)
|
134 |
134 |
assert(wf2.possible_status[0].items[0].role_id == 'Role {{ form_var_foo }}')
|
135 |
135 |
dispatch.role_id = 'Role [form_var_foo]'
|
136 |
|
wf2 = assert_import_export_works(wf)
|
|
136 |
wf2 = assert_xml_import_export_works(wf)
|
137 |
137 |
assert(wf2.possible_status[0].items[0].role_id == 'Role [form_var_foo]')
|
138 |
138 |
|
139 |
139 |
dispatch.role_id = 'Rolé [form_var_foo]'
|
140 |
|
wf2 = assert_import_export_works(wf, include_id=False)
|
|
140 |
wf2 = assert_xml_import_export_works(wf, include_id=False)
|
141 |
141 |
assert wf2.possible_status[0].items[0].role_id == 'Rolé [form_var_foo]'
|
142 |
142 |
|
143 |
143 |
dispatch.role_id = 'Rolé [form_var_foo]'
|
144 |
|
wf2 = assert_import_export_works(wf, include_id=True)
|
|
144 |
wf2 = assert_xml_import_export_works(wf, include_id=True)
|
145 |
145 |
assert wf2.possible_status[0].items[0].role_id == 'Rolé [form_var_foo]'
|
146 |
146 |
|
147 |
147 |
def test_status_actions_named_role(pub):
|
... | ... | |
155 |
155 |
st1.items.append(commentable)
|
156 |
156 |
commentable.parent = st1
|
157 |
157 |
|
158 |
|
assert_import_export_works(wf)
|
|
158 |
assert_xml_import_export_works(wf)
|
159 |
159 |
|
160 |
160 |
|
161 |
161 |
def test_status_actions_named_existing_role(pub):
|
... | ... | |
174 |
174 |
st1.items.append(commentable)
|
175 |
175 |
commentable.parent = st1
|
176 |
176 |
|
177 |
|
wf2 = assert_import_export_works(wf)
|
|
177 |
wf2 = assert_xml_import_export_works(wf)
|
178 |
178 |
assert '<item role_id="2">Test Role named existing role</item>' in ET.tostring(indent(wf.export_to_xml()))
|
179 |
179 |
assert wf2.possible_status[0].items[0].by == ['2']
|
180 |
180 |
|
... | ... | |
208 |
208 |
st1.items.append(commentable)
|
209 |
209 |
commentable.parent = st1
|
210 |
210 |
|
211 |
|
wf2 = assert_import_export_works(wf)
|
|
211 |
wf2 = assert_xml_import_export_works(wf)
|
212 |
212 |
|
213 |
213 |
# check that role name has precedence over id
|
214 |
214 |
xml_export_orig = ET.tostring(export_to_indented_xml(wf))
|
... | ... | |
254 |
254 |
st1.items.append(display_form)
|
255 |
255 |
display_form.parent = st1
|
256 |
256 |
|
257 |
|
wf2 = assert_import_export_works(wf)
|
|
257 |
wf2 = assert_xml_import_export_works(wf)
|
258 |
258 |
# formdef.max_field_id is recalculated when importing a FormWorkflowStatusItem
|
259 |
259 |
assert wf2.possible_status[0].items[0].formdef.max_field_id == len(display_form.formdef.fields)
|
260 |
260 |
|
... | ... | |
280 |
280 |
export_to.parent = st1
|
281 |
281 |
|
282 |
282 |
assert wf.possible_status[0].items[0].model_file.base_filename == 'bar'
|
283 |
|
wf2 = assert_import_export_works(wf)
|
|
283 |
wf2 = assert_xml_import_export_works(wf)
|
284 |
284 |
assert wf2.possible_status[0].items[0].model_file.base_filename == 'bar'
|
285 |
285 |
assert wf2.possible_status[0].items[0].model_file.get_file().read() == file_content
|
286 |
286 |
|
... | ... | |
311 |
311 |
def test_export_roles(pub):
|
312 |
312 |
wf = Workflow(name='roles')
|
313 |
313 |
wf.roles = {'foo': 'Bar'}
|
314 |
|
wf2 = assert_import_export_works(wf)
|
|
314 |
wf2 = assert_xml_import_export_works(wf)
|
315 |
315 |
assert wf2.roles == wf.roles
|
316 |
316 |
|
317 |
317 |
|
... | ... | |
331 |
331 |
st1.items.append(jump)
|
332 |
332 |
jump.parent = st1
|
333 |
333 |
|
334 |
|
wf2 = assert_import_export_works(wf)
|
|
334 |
wf2 = assert_xml_import_export_works(wf)
|
335 |
335 |
assert wf2.possible_status[0].items[0].condition == {'type': 'python', 'value': '"foo"'}
|
336 |
336 |
assert wf2.possible_status[0].items[0].trigger == 'bar'
|
337 |
337 |
assert wf2.possible_status[0].items[0].timeout == 1200
|
338 |
338 |
|
339 |
339 |
# check with a formula as timeout
|
340 |
340 |
jump.timeout = '=1200'
|
341 |
|
wf2 = assert_import_export_works(wf)
|
|
341 |
wf2 = assert_xml_import_export_works(wf)
|
342 |
342 |
assert wf2.possible_status[0].items[0].timeout == '=1200'
|
343 |
343 |
|
344 |
344 |
# legacy condition value
|
... | ... | |
362 |
362 |
st1.items.append(commentable)
|
363 |
363 |
commentable.parent = st1
|
364 |
364 |
|
365 |
|
wf2 = assert_import_export_works(wf)
|
|
365 |
wf2 = assert_xml_import_export_works(wf)
|
366 |
366 |
assert wf2.possible_status[0].items[0].button_label is None
|
367 |
367 |
assert wf2.possible_status[0].items[0].required is False
|
368 |
368 |
|
369 |
369 |
commentable.required = True
|
370 |
|
wf2 = assert_import_export_works(wf)
|
|
370 |
wf2 = assert_xml_import_export_works(wf)
|
371 |
371 |
assert wf2.possible_status[0].items[0].required is True
|
372 |
372 |
|
373 |
373 |
# import legacy comment without required attribute
|
... | ... | |
384 |
384 |
from wcs.workflows import WorkflowVariablesFieldsFormDef
|
385 |
385 |
wf.variables_formdef = WorkflowVariablesFieldsFormDef(workflow=wf)
|
386 |
386 |
wf.variables_formdef.fields.append(StringField(label='Test', type='string'))
|
387 |
|
wf2 = assert_import_export_works(wf)
|
|
387 |
wf2 = assert_xml_import_export_works(wf)
|
388 |
388 |
assert wf2.variables_formdef.fields[0].label == 'Test'
|
389 |
389 |
|
390 |
390 |
def test_wscall_action(pub):
|
... | ... | |
402 |
402 |
st1.items.append(wscall)
|
403 |
403 |
wscall.parent = st1
|
404 |
404 |
|
405 |
|
wf2 = assert_import_export_works(wf)
|
|
405 |
wf2 = assert_xml_import_export_works(wf)
|
406 |
406 |
wscall2 = wf2.possible_status[0].items[0]
|
407 |
407 |
assert wscall2.url == 'http://test/'
|
408 |
408 |
assert wscall2.varname == 'varname'
|
... | ... | |
423 |
423 |
st1.items.append(commentable)
|
424 |
424 |
commentable.parent = st1
|
425 |
425 |
|
426 |
|
wf2 = assert_import_export_works(wf)
|
|
426 |
wf2 = assert_xml_import_export_works(wf)
|
427 |
427 |
assert wf2.possible_status[0].backoffice_info_text == '<p>Foo</p>'
|
428 |
428 |
assert wf2.possible_status[0].items[0].backoffice_info_text == '<p>Bar</p>'
|
429 |
429 |
|
... | ... | |
447 |
447 |
assert trigger.key == 'manual'
|
448 |
448 |
trigger.roles = [role.id]
|
449 |
449 |
|
450 |
|
wf2 = assert_import_export_works(wf)
|
|
450 |
wf2 = assert_xml_import_export_works(wf)
|
451 |
451 |
assert wf2.global_actions[0].triggers[0].roles == [role.id]
|
452 |
452 |
|
453 |
|
wf2 = assert_import_export_works(wf, True)
|
|
453 |
wf2 = assert_xml_import_export_works(wf, True)
|
454 |
454 |
|
455 |
455 |
def test_backoffice_fields(pub):
|
456 |
456 |
wf = Workflow(name='bo fields')
|
... | ... | |
459 |
459 |
StringField(id='bo1', label='1st backoffice field',
|
460 |
460 |
type='string', varname='backoffice_blah'),
|
461 |
461 |
]
|
462 |
|
wf2 = assert_import_export_works(wf, True)
|
|
462 |
wf2 = assert_xml_import_export_works(wf, True)
|
463 |
463 |
|
464 |
464 |
def test_complex_dispatch_action(pub):
|
465 |
465 |
wf = Workflow(name='status')
|
... | ... | |
485 |
485 |
st1.items.append(dispatch)
|
486 |
486 |
dispatch.parent = st1
|
487 |
487 |
|
488 |
|
wf2 = assert_import_export_works(wf)
|
|
488 |
wf2 = assert_xml_import_export_works(wf)
|
489 |
489 |
assert wf2.possible_status[0].items[0].variable == dispatch.variable
|
490 |
490 |
assert wf2.possible_status[0].items[0].rules == dispatch.rules
|
491 |
491 |
assert wf2.possible_status[0].items[0].dispatch_type == 'automatic'
|
... | ... | |
512 |
512 |
|
513 |
513 |
# check rules are not exported with dispatch type is not automatic
|
514 |
514 |
dispatch.dispatch_type = 'manual'
|
515 |
|
wf2 = assert_import_export_works(wf)
|
|
515 |
wf2 = assert_xml_import_export_works(wf)
|
516 |
516 |
assert wf2.possible_status[0].items[0].dispatch_type == 'manual'
|
517 |
517 |
assert not wf2.possible_status[0].items[0].rules
|
518 |
518 |
xml_export = export_to_indented_xml(wf, include_id=True)
|
... | ... | |
530 |
530 |
st1.items.append(display)
|
531 |
531 |
display.parent = st1
|
532 |
532 |
|
533 |
|
wf2 = assert_import_export_works(wf)
|
|
533 |
wf2 = assert_xml_import_export_works(wf)
|
534 |
534 |
assert wf2.possible_status[0].items[0].message == display.message
|
535 |
535 |
for role_id in display.to:
|
536 |
536 |
assert role_id in wf2.possible_status[0].items[0].to
|
537 |
537 |
|
538 |
|
wf2 = assert_import_export_works(wf, include_id=True)
|
|
538 |
wf2 = assert_xml_import_export_works(wf, include_id=True)
|
539 |
539 |
|
540 |
540 |
def test_sendmail_other_destination(pub):
|
541 |
541 |
wf = Workflow(name='status')
|
... | ... | |
547 |
547 |
sendmail.parent = st1
|
548 |
548 |
|
549 |
549 |
Role.wipe()
|
550 |
|
wf2 = assert_import_export_works(wf)
|
|
550 |
wf2 = assert_xml_import_export_works(wf)
|
551 |
551 |
assert Role.count() == 0
|
552 |
552 |
|
553 |
553 |
sendmail.to = ['_submitter', '=form_var_plop', '[form_var_plop]', '{{ form_var_plop }}', 'foobar@localhost']
|
554 |
|
wf2 = assert_import_export_works(wf)
|
|
554 |
wf2 = assert_xml_import_export_works(wf)
|
555 |
555 |
assert Role.count() == 0
|
556 |
556 |
assert wf2.possible_status[0].items[0].to == sendmail.to
|
557 |
557 |
|
... | ... | |
564 |
564 |
sendmail.parent = st1
|
565 |
565 |
|
566 |
566 |
sendmail.attachments = ['form_var_file_raw', 'form_fbo1']
|
567 |
|
wf2 = assert_import_export_works(wf)
|
|
567 |
wf2 = assert_xml_import_export_works(wf)
|
568 |
568 |
assert wf2.possible_status[0].items[0].attachments == sendmail.attachments
|
569 |
569 |
|
570 |
570 |
sendmail.attachments = []
|
571 |
|
wf2 = assert_import_export_works(wf)
|
|
571 |
wf2 = assert_xml_import_export_works(wf)
|
572 |
572 |
assert wf2.possible_status[0].items[0].attachments == []
|
573 |
573 |
|
574 |
574 |
def test_sms(pub):
|
... | ... | |
594 |
594 |
WorkflowCriticalityLevel(name='red', colour='FF0000'),
|
595 |
595 |
]
|
596 |
596 |
|
597 |
|
wf2 = assert_import_export_works(wf)
|
|
597 |
wf2 = assert_xml_import_export_works(wf)
|
598 |
598 |
assert wf2.criticality_levels[0].name == 'green'
|
599 |
599 |
assert wf2.criticality_levels[1].name == 'yellow'
|
600 |
600 |
|
... | ... | |
629 |
629 |
st1.items.append(item)
|
630 |
630 |
item.parent = st1
|
631 |
631 |
|
632 |
|
wf2 = assert_import_export_works(wf)
|
|
632 |
wf2 = assert_xml_import_export_works(wf)
|
633 |
633 |
item2 = wf2.possible_status[0].items[0]
|
634 |
634 |
assert item2.fields == [{'field_id': '__email', 'value': '=form_var_foo'}]
|
635 |
635 |
|
... | ... | |
643 |
643 |
st1.items.append(item)
|
644 |
644 |
item.parent = st1
|
645 |
645 |
|
646 |
|
wf2 = assert_import_export_works(wf)
|
|
646 |
wf2 = assert_xml_import_export_works(wf)
|
647 |
647 |
item2 = wf2.possible_status[0].items[0]
|
648 |
648 |
assert item2.fields == [{'field_id': 'bo1', 'value': '=form_var_foo'}]
|
649 |
649 |
|
... | ... | |
655 |
655 |
st1.items.append(sendmail)
|
656 |
656 |
sendmail.parent = st1
|
657 |
657 |
|
658 |
|
wf2 = assert_import_export_works(wf)
|
|
658 |
wf2 = assert_xml_import_export_works(wf)
|
659 |
659 |
|
660 |
660 |
sendmail.condition = {} # should not be created any longer
|
661 |
661 |
wf2 = Workflow.import_from_xml_tree(wf.export_to_xml(False), False)
|
662 |
662 |
assert wf2.possible_status[0].items[0].condition is None
|
663 |
663 |
|
664 |
664 |
sendmail.condition = {'type': 'python', 'value': 'True'}
|
665 |
|
wf2 = assert_import_export_works(wf)
|
|
665 |
wf2 = assert_xml_import_export_works(wf)
|
666 |
|
-
|