Skip to content

Commit 9b50630

Browse files
authored
Merge pull request #439 from sartography/feature/init-data-objects-with-workflow
initialize data objects on workflow creation
2 parents c1e89e3 + 51678c0 commit 9b50630

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

SpiffWorkflow/bpmn/workflow.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ def __init__(self, spec, subprocess_specs=None, script_engine=None, **kwargs):
5353
self.correlations = {}
5454
super(BpmnWorkflow, self).__init__(spec, **kwargs)
5555

56+
for obj in self.spec.data_objects:
57+
self.data['data_objects'][obj] = None
5658
self.__script_engine = script_engine or PythonScriptEngine()
5759

5860
@property

tests/SpiffWorkflow/bpmn/DataObjectTest.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,16 @@ def testMissingDataOutput(self):
4343
def actual_test(self, save_restore):
4444

4545
self.workflow = BpmnWorkflow(self.spec, self.subprocesses)
46+
# Test that the data object has been created
47+
self.assertEqual(self.workflow.data['data_objects']['obj_1'], None)
4648
self.workflow.do_engine_steps()
4749

4850
# Set up the data
4951
ready_tasks = self.get_ready_user_tasks()
5052
ready_tasks[0].data = { 'obj_1': 'hello' }
5153
ready_tasks[0].run()
5254
# After task completion, obj_1 should be copied out of the task into the workflow
53-
self.assertNotIn('obj_1', ready_tasks[0].data)
55+
self.assertEqual(self.workflow.data['data_objects']['obj_1'], 'hello')
5456
self.assertIn('obj_1', self.workflow.data_objects)
5557

5658
if save_restore:

tests/SpiffWorkflow/bpmn/events/ConditionalEventTest.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ class ConditionalEventTest(BpmnWorkflowTestCase):
88
def testIntermediateEvent(self):
99
spec, subprocesses = self.load_workflow_spec('conditional_event.bpmn', 'intermediate')
1010
self.workflow = BpmnWorkflow(spec, subprocesses)
11-
# I don't want to complicate the diagram with extra tasks just for initializing this value
12-
self.workflow.data_objects['task_a_done'] = False
1311
self.workflow.do_engine_steps()
1412
b = self.workflow.get_next_task(spec_name='task_b')
1513
b.run()
@@ -29,7 +27,6 @@ def testIntermediateEvent(self):
2927
def testBoundaryEvent(self):
3028
spec, subprocesses = self.load_workflow_spec('conditional_event.bpmn', 'boundary')
3129
self.workflow = BpmnWorkflow(spec, subprocesses)
32-
self.workflow.data_objects['task_c_done'] = False
3330
self.workflow.do_engine_steps()
3431
c = self.workflow.get_next_task(spec_name='task_c')
3532
c.data['task_c_done'] = True

0 commit comments

Comments
 (0)