From 3e0c503119eae7ab7b5ed743d68bbd1978c6d556 Mon Sep 17 00:00:00 2001 From: jasquat Date: Mon, 25 Sep 2023 12:19:35 -0400 Subject: [PATCH] support dmn files in process model unit test w/ burnettk --- .../services/process_model_test_runner_service.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_model_test_runner_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_model_test_runner_service.py index ef03dde67..6ceb962d2 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_model_test_runner_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_model_test_runner_service.py @@ -94,12 +94,10 @@ class ProcessModelTestRunnerMostlyPureSpiffDelegate(ProcessModelTestRunnerDelega def instantiate_executer(self, bpmn_file: str) -> BpmnWorkflow: parser = MyCustomParser() - bpmn_file_etree = self._get_etree_from_bpmn_file(bpmn_file) - parser.add_bpmn_xml(bpmn_file_etree, filename=os.path.basename(bpmn_file)) + self._add_bpmn_file_to_parser(parser, bpmn_file) all_related = self._find_related_bpmn_files(bpmn_file) for related_file in all_related: - related_file_etree = self._get_etree_from_bpmn_file(related_file) - parser.add_bpmn_xml(related_file_etree, filename=os.path.basename(related_file)) + self._add_bpmn_file_to_parser(parser, related_file) sub_parsers = list(parser.process_parsers.values()) executable_process = None for sub_parser in sub_parsers: @@ -131,6 +129,12 @@ class ProcessModelTestRunnerMostlyPureSpiffDelegate(ProcessModelTestRunnerDelega return ready_tasks[0] return None + def _add_bpmn_file_to_parser(self, parser: MyCustomParser, bpmn_file: str) -> None: + related_file_etree = self._get_etree_from_bpmn_file(bpmn_file) + parser.add_bpmn_xml(related_file_etree, filename=os.path.basename(bpmn_file)) + dmn_file_glob = os.path.join(os.path.dirname(bpmn_file), "*.dmn") + parser.add_dmn_files_by_glob(dmn_file_glob) + def _get_etree_from_bpmn_file(self, bpmn_file: str) -> etree._Element: data = None with open(bpmn_file, "rb") as f_handle: