Skip to content

Commit

Permalink
Merge pull request #382 from sartography/bugfix/raise-exception-when-…
Browse files Browse the repository at this point in the history
…creating-non-executable-spec

Bugfix/raise exception when creating non executable spec
  • Loading branch information
essweine authored Feb 1, 2024
2 parents 633de80 + b69a1ff commit ae8648f
Show file tree
Hide file tree
Showing 36 changed files with 2,792 additions and 3,045 deletions.
6 changes: 3 additions & 3 deletions SpiffWorkflow/bpmn/parser/BpmnParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def get_process_parser(self, process_id):

def get_process_ids(self):
"""Returns a list of process IDs"""
return list(self.process_parsers.keys())
return list(proc_id for proc_id, parser in self.process_parsers.items() if parser.process_executable)

def add_bpmn_file(self, filename):
"""
Expand Down Expand Up @@ -344,8 +344,8 @@ def find_all_specs(self):
# This is a little convoluted, but we might add more processes as we generate
# the dictionary if something refers to another subprocess that we haven't seen.
processes = dict((id, self.get_spec(id)) for id in self.get_process_ids())
while sorted(processes.keys()) != sorted(self.process_parsers.keys()):
for process_id in tuple(self.process_parsers.keys()):
while sorted(processes.keys()) != sorted(self.get_process_ids()):
for process_id in self.get_process_ids():
processes[process_id] = self.get_spec(process_id)
return processes

Expand Down
7 changes: 3 additions & 4 deletions SpiffWorkflow/bpmn/parser/ProcessParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __init__(self, p, node, nsmap, data_stores, filename=None, lane=None):
self.parser = p
self.lane = lane
self.spec = None
self.process_executable = self.is_executable()
self.process_executable = node.get('isExecutable', 'true') == 'true'
self.data_stores = data_stores
self.inherited_data_objects = {}

Expand All @@ -64,9 +64,6 @@ def has_lanes(self) -> bool:
return True
return False

def is_executable(self) -> bool:
return self.node.get('isExecutable', 'true') == 'true'

def start_messages(self):
""" This returns a list of message names that would cause this
process to start. """
Expand Down Expand Up @@ -117,6 +114,8 @@ def _parse(self):
start_node_list = self.xpath('./bpmn:startEvent')
if not start_node_list and self.process_executable:
raise ValidationException("No start event found", node=self.node, file_name=self.filename)
if not self.process_executable:
raise ValidationException(f"Process {self.bpmn_id} is not executable.", node=self.node, file_name=self.filename)
self.spec = BpmnProcessSpec(name=self.bpmn_id, description=self.get_name(), filename=self.filename)

self.spec.data_objects.update(self.inherited_data_objects)
Expand Down
8 changes: 8 additions & 0 deletions tests/SpiffWorkflow/bpmn/ParserTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,11 @@ def testBoundaryEvent(self):
self.assertIn(split_task, gw1.outputs)
self.assertNotIn(task, gw2.outputs)
self.assertIn(split_task, gw2.outputs)

def testNonExecutableProcessRaisesException(self):
bpmn_file = os.path.join(os.path.dirname(__file__), 'data/Invalid-Workflows', 'non-executable-process.bpmn')
self.parser.add_bpmn_file(bpmn_file)
self.assertRaisesRegex(
ValidationException, "Process \w+ is not executable.",
self.parser.get_spec, 'Process_14di7kj'
)

This file was deleted.

6 changes: 0 additions & 6 deletions tests/SpiffWorkflow/bpmn/data/Invalid-Workflows/README.txt

This file was deleted.

Loading

0 comments on commit ae8648f

Please sign in to comment.