From de24d76c9de8328917d3a39f111e181846bafc78 Mon Sep 17 00:00:00 2001 From: jasquat Date: Thu, 18 May 2023 17:16:58 -0400 Subject: [PATCH] cleaned up runner tests and rsyncd back to sample w/ burnettk --- spiffworkflow-backend/pyproject.toml | 2 +- .../process_model_test_runner_service.py | 38 ++++-- .../failing_script_task.bpmn} | 0 .../failing_script_task}/process_model.json | 0 .../test_failing_script_task.json | 3 + .../call-activity/call_activity.bpmn} | 4 +- .../call-activity/process_model.json | 9 ++ .../call-activity/test_call_activity.json} | 2 +- .../choose-your-branch-schema.json | 11 ++ .../choose-your-branch-uischema.json | 5 + .../exclusive_gateway_based_on_user_task.bpmn | 98 ++++++++++++++++ .../process_model.json | 11 ++ ..._exclusive_gateway_based_on_user_task.json | 22 ++++ .../loopback_to_user_task.bpmn | 110 ++++++++++++++++++ .../loopback-to-user-task/process_model.json | 11 ++ .../test_loopback_to_user_task.json | 13 +++ .../user-input-schema.json | 11 ++ .../user-input-uischema.json | 5 + .../expected-to-pass/loopback/loopback.bpmn | 92 +++++++++++++++ .../loopback/process_model.json | 11 ++ .../loopback/test_loopback.json | 5 + .../manual-task/manual_task.bpmn} | 4 +- .../manual-task/process_model.json | 9 ++ .../manual-task/test_manual_task.json} | 2 +- .../expected-to-pass/process_group.json | 9 ++ .../script-task}/process_model.json | 0 .../script-task/script_task.bpmn} | 0 .../script-task/test_script_task.json} | 2 +- .../service-task}/process_model.json | 0 .../service-task/service_task.bpmn} | 10 +- .../service-task/test_service_task.json} | 4 +- .../test_basic_failing_script_task.json | 3 - .../basic_call_activity/process_model.json | 9 -- .../basic_manual_task/process_model.json | 9 -- .../unit/test_process_model_test_runner.py | 21 +++- 35 files changed, 492 insertions(+), 53 deletions(-) rename spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/{failing_tests/basic_failing_script_task/basic_failing_script_task.bpmn => expected-to-fail/failing_script_task/failing_script_task.bpmn} (100%) rename spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/{failing_tests/basic_failing_script_task => expected-to-fail/failing_script_task}/process_model.json (100%) create mode 100644 spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-fail/failing_script_task/test_failing_script_task.json rename spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/{passing_tests/basic_call_activity/basic_call_activity.bpmn => expected-to-pass/call-activity/call_activity.bpmn} (95%) create mode 100644 spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/call-activity/process_model.json rename spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/{passing_tests/basic_call_activity/test_basic_call_activity.json => expected-to-pass/call-activity/test_call_activity.json} (65%) create mode 100644 spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/exclusive-gateway-based-on-user-task/choose-your-branch-schema.json create mode 100644 spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/exclusive-gateway-based-on-user-task/choose-your-branch-uischema.json create mode 100644 spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/exclusive-gateway-based-on-user-task/exclusive_gateway_based_on_user_task.bpmn create mode 100644 spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/exclusive-gateway-based-on-user-task/process_model.json create mode 100644 spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/exclusive-gateway-based-on-user-task/test_exclusive_gateway_based_on_user_task.json create mode 100644 spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/loopback-to-user-task/loopback_to_user_task.bpmn create mode 100644 spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/loopback-to-user-task/process_model.json create mode 100644 spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/loopback-to-user-task/test_loopback_to_user_task.json create mode 100644 spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/loopback-to-user-task/user-input-schema.json create mode 100644 spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/loopback-to-user-task/user-input-uischema.json create mode 100644 spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/loopback/loopback.bpmn create mode 100644 spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/loopback/process_model.json create mode 100644 spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/loopback/test_loopback.json rename spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/{passing_tests/basic_manual_task/basic_manual_task.bpmn => expected-to-pass/manual-task/manual_task.bpmn} (93%) create mode 100644 spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/manual-task/process_model.json rename spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/{passing_tests/basic_manual_task/test_basic_manual_task.json => expected-to-pass/manual-task/test_manual_task.json} (84%) create mode 100644 spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/process_group.json rename spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/{passing_tests/basic_script_task => expected-to-pass/script-task}/process_model.json (100%) rename spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/{passing_tests/basic_script_task/basic_script_task.bpmn => expected-to-pass/script-task/script_task.bpmn} (100%) rename spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/{passing_tests/basic_script_task/test_basic_script_task.json => expected-to-pass/script-task/test_script_task.json} (69%) rename spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/{passing_tests/basic_service_task => expected-to-pass/service-task}/process_model.json (100%) rename spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/{passing_tests/basic_service_task/basic_service_task.bpmn => expected-to-pass/service-task/service_task.bpmn} (89%) rename spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/{passing_tests/basic_service_task/test_basic_service_task.json => expected-to-pass/service-task/test_service_task.json} (69%) delete mode 100644 spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/failing_tests/basic_failing_script_task/test_basic_failing_script_task.json delete mode 100644 spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/passing_tests/basic_call_activity/process_model.json delete mode 100644 spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/passing_tests/basic_manual_task/process_model.json diff --git a/spiffworkflow-backend/pyproject.toml b/spiffworkflow-backend/pyproject.toml index d0f9edfe5..39c812229 100644 --- a/spiffworkflow-backend/pyproject.toml +++ b/spiffworkflow-backend/pyproject.toml @@ -115,7 +115,7 @@ sphinx-click = "^4.3.0" Pygments = "^2.10.0" pyupgrade = "^3.1.0" furo = ">=2021.11.12" -myst-parser = "^0.15.1" +# myst-parser = "^0.15.1" [tool.poetry.scripts] spiffworkflow-backend = "spiffworkflow_backend.__main__:main" 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 1e0ea82a1..47875e10a 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 @@ -39,6 +39,10 @@ class NoTestCasesFoundError(Exception): pass +class MissingInputTaskData(Exception): + pass + + @dataclass class TestCaseResult: passed: bool @@ -115,13 +119,11 @@ class ProcessModelTestRunner: def failing_tests_formatted(self) -> str: formatted_tests = ["FAILING TESTS:"] for failing_test in self.failing_tests(): - msg = '' + msg = "" if failing_test.error_messages: - msg = '\n\t\t'.join(failing_test.error_messages) - formatted_tests.append( - f'\t{failing_test.bpmn_file}: {failing_test.test_case_name}: {msg}' - ) - return '\n'.join(formatted_tests) + msg = "\n\t\t".join(failing_test.error_messages) + formatted_tests.append(f"\t{failing_test.bpmn_file}: {failing_test.test_case_name}: {msg}") + return "\n".join(formatted_tests) def run(self) -> None: if len(self.test_mappings.items()) < 1: @@ -133,10 +135,11 @@ class ProcessModelTestRunner: json_file_contents = json.loads(f.read()) for test_case_name, test_case_contents in json_file_contents.items(): + self.task_data_index = {} try: self.run_test_case(bpmn_file, test_case_name, test_case_contents) except Exception as ex: - ex_as_array = str(ex).split('\n') + ex_as_array = str(ex).split("\n") self._add_test_result(False, bpmn_file, test_case_name, ex_as_array) def run_test_case(self, bpmn_file: str, test_case_name: str, test_case_contents: dict) -> None: @@ -224,7 +227,9 @@ class ProcessModelTestRunner: bpmn_process_identifier = bpmn_process_element.attrib["id"] self.bpmn_processes_to_file_mappings[bpmn_process_identifier] = file_norm - def _execute_task(self, spiff_task: SpiffTask, test_case_task_key: str, test_case_task_properties: Optional[dict]) -> None: + def _execute_task( + self, spiff_task: SpiffTask, test_case_task_key: str, test_case_task_properties: Optional[dict] + ) -> None: if self.execute_task_callback: self.execute_task_callback(spiff_task, test_case_task_key, test_case_task_properties) self._default_execute_task(spiff_task, test_case_task_key, test_case_task_properties) @@ -245,12 +250,21 @@ class ProcessModelTestRunner: return ready_tasks[0] return None - def _default_execute_task(self, spiff_task: SpiffTask, test_case_task_key: str, test_case_task_properties: Optional[dict]) -> None: + def _default_execute_task( + self, spiff_task: SpiffTask, test_case_task_key: str, test_case_task_properties: Optional[dict] + ) -> None: if spiff_task.task_spec.manual or spiff_task.task_spec.__class__.__name__ == "ServiceTask": if test_case_task_properties and "data" in test_case_task_properties: if test_case_task_key not in self.task_data_index: self.task_data_index[test_case_task_key] = 0 - spiff_task.update_data(test_case_task_properties["data"][self.task_data_index[test_case_task_key]]) + task_data_length = len(test_case_task_properties["data"]) + test_case_index = self.task_data_index[test_case_task_key] + if task_data_length <= test_case_index: + raise MissingInputTaskData( + f"Missing input task data for task: {test_case_task_key}. " + f"Only {task_data_length} given in the json but task was called {test_case_index + 1} times" + ) + spiff_task.update_data(test_case_task_properties["data"][test_case_index]) self.task_data_index[test_case_task_key] += 1 spiff_task.complete() else: @@ -297,7 +311,9 @@ class ProcessModelTestRunner: def _get_relative_path_of_bpmn_file(self, bpmn_file: str) -> str: return os.path.relpath(bpmn_file, start=self.process_model_directory_path) - def _add_test_result(self, passed: bool, bpmn_file: str, test_case_name: str, error_messages: Optional[list[str]] = None) -> None: + def _add_test_result( + self, passed: bool, bpmn_file: str, test_case_name: str, error_messages: Optional[list[str]] = None + ) -> None: bpmn_file_relative = self._get_relative_path_of_bpmn_file(bpmn_file) test_result = TestCaseResult( passed=passed, diff --git a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/failing_tests/basic_failing_script_task/basic_failing_script_task.bpmn b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-fail/failing_script_task/failing_script_task.bpmn similarity index 100% rename from spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/failing_tests/basic_failing_script_task/basic_failing_script_task.bpmn rename to spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-fail/failing_script_task/failing_script_task.bpmn diff --git a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/failing_tests/basic_failing_script_task/process_model.json b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-fail/failing_script_task/process_model.json similarity index 100% rename from spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/failing_tests/basic_failing_script_task/process_model.json rename to spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-fail/failing_script_task/process_model.json diff --git a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-fail/failing_script_task/test_failing_script_task.json b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-fail/failing_script_task/test_failing_script_task.json new file mode 100644 index 000000000..0c81e0724 --- /dev/null +++ b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-fail/failing_script_task/test_failing_script_task.json @@ -0,0 +1,3 @@ +{ + "test_case_2": {} +} diff --git a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/passing_tests/basic_call_activity/basic_call_activity.bpmn b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/call-activity/call_activity.bpmn similarity index 95% rename from spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/passing_tests/basic_call_activity/basic_call_activity.bpmn rename to spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/call-activity/call_activity.bpmn index f837163f5..68a05f280 100644 --- a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/passing_tests/basic_call_activity/basic_call_activity.bpmn +++ b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/call-activity/call_activity.bpmn @@ -1,6 +1,6 @@ - + Flow_0ext5lt @@ -9,7 +9,7 @@ Flow_1hzwssi - + Flow_0ext5lt Flow_1hzwssi diff --git a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/call-activity/process_model.json b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/call-activity/process_model.json new file mode 100644 index 000000000..302fa24a1 --- /dev/null +++ b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/call-activity/process_model.json @@ -0,0 +1,9 @@ +{ + "description": "", + "display_name": "Call Activity", + "exception_notification_addresses": [], + "fault_or_suspend_on_exception": "fault", + "files": [], + "primary_file_name": "call_activity.bpmn", + "primary_process_id": "CallActivityProcess" +} diff --git a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/passing_tests/basic_call_activity/test_basic_call_activity.json b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/call-activity/test_call_activity.json similarity index 65% rename from spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/passing_tests/basic_call_activity/test_basic_call_activity.json rename to spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/call-activity/test_call_activity.json index 0a7f76929..60e638a97 100644 --- a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/passing_tests/basic_call_activity/test_basic_call_activity.json +++ b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/call-activity/test_call_activity.json @@ -1,5 +1,5 @@ { - "test_case_one": { + "test_case_1": { "expected_output_json": {} } } diff --git a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/exclusive-gateway-based-on-user-task/choose-your-branch-schema.json b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/exclusive-gateway-based-on-user-task/choose-your-branch-schema.json new file mode 100644 index 000000000..0bfee44cb --- /dev/null +++ b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/exclusive-gateway-based-on-user-task/choose-your-branch-schema.json @@ -0,0 +1,11 @@ +{ + "title": "Choose Your Branch", + "description": "", + "properties": { + "branch": { + "type": "string", + "title": "branch" + } + }, + "required": [] +} \ No newline at end of file diff --git a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/exclusive-gateway-based-on-user-task/choose-your-branch-uischema.json b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/exclusive-gateway-based-on-user-task/choose-your-branch-uischema.json new file mode 100644 index 000000000..42449285d --- /dev/null +++ b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/exclusive-gateway-based-on-user-task/choose-your-branch-uischema.json @@ -0,0 +1,5 @@ +{ + "ui:order": [ + "branch" + ] +} \ No newline at end of file diff --git a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/exclusive-gateway-based-on-user-task/exclusive_gateway_based_on_user_task.bpmn b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/exclusive-gateway-based-on-user-task/exclusive_gateway_based_on_user_task.bpmn new file mode 100644 index 000000000..63bafd46c --- /dev/null +++ b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/exclusive-gateway-based-on-user-task/exclusive_gateway_based_on_user_task.bpmn @@ -0,0 +1,98 @@ + + + + + Flow_19j3jcx + + + + Flow_0qa66xz + Flow_1ww41l3 + Flow_10m4g0q + + + + branch == 'a' + + + + Flow_1oxbb75 + Flow_1ck9lfk + + + + + + + + + + + Flow_19j3jcx + Flow_0qa66xz + + + Flow_1ww41l3 + Flow_1ck9lfk + chosen_branch = 'A' + + + Flow_10m4g0q + Flow_1oxbb75 + chosen_branch = 'B' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/exclusive-gateway-based-on-user-task/process_model.json b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/exclusive-gateway-based-on-user-task/process_model.json new file mode 100644 index 000000000..448105102 --- /dev/null +++ b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/exclusive-gateway-based-on-user-task/process_model.json @@ -0,0 +1,11 @@ +{ + "description": "", + "display_name": "Exclusive Gateway Based on User Task", + "display_order": 0, + "exception_notification_addresses": [], + "fault_or_suspend_on_exception": "fault", + "files": [], + "metadata_extraction_paths": null, + "primary_file_name": "exclusive_gateway_based_on_user_task.bpmn", + "primary_process_id": "exclusive_gateway_based_on_user_task_process" +} \ No newline at end of file diff --git a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/exclusive-gateway-based-on-user-task/test_exclusive_gateway_based_on_user_task.json b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/exclusive-gateway-based-on-user-task/test_exclusive_gateway_based_on_user_task.json new file mode 100644 index 000000000..e5d86ba05 --- /dev/null +++ b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/exclusive-gateway-based-on-user-task/test_exclusive_gateway_based_on_user_task.json @@ -0,0 +1,22 @@ +{ + "test_case_one": { + "tasks": { + "user_task_choose_branch": { + "data": [ + { "branch": "a" } + ] + } + }, + "expected_output_json": { "branch": "a", "chosen_branch": "A"} + }, + "test_case_two": { + "tasks": { + "user_task_choose_branch": { + "data": [ + { "branch": "b" } + ] + } + }, + "expected_output_json": { "branch": "b", "chosen_branch": "B"} + } +} diff --git a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/loopback-to-user-task/loopback_to_user_task.bpmn b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/loopback-to-user-task/loopback_to_user_task.bpmn new file mode 100644 index 000000000..0298a1d65 --- /dev/null +++ b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/loopback-to-user-task/loopback_to_user_task.bpmn @@ -0,0 +1,110 @@ + + + + + Flow_12xxe7w + + + + Flow_1s3znr2 + Flow_0utss6p + Flow_1sg0c65 + + + + Flow_0utss6p + + + counter == 3 + + + Flow_12xxe7w + Flow_08tc3r7 + counter = 1 +the_var = 0 + + + + + + + + + + + + Flow_08tc3r7 + Flow_1sg0c65 + Flow_0wnc5ju + + + + Flow_0wnc5ju + Flow_1s3znr2 + the_var = user_input_variable + the_var +counter += 1 + + + loop back if a < 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/loopback-to-user-task/process_model.json b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/loopback-to-user-task/process_model.json new file mode 100644 index 000000000..06e8d935d --- /dev/null +++ b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/loopback-to-user-task/process_model.json @@ -0,0 +1,11 @@ +{ + "description": "", + "display_name": "Loopback to User Task", + "display_order": 0, + "exception_notification_addresses": [], + "fault_or_suspend_on_exception": "fault", + "files": [], + "metadata_extraction_paths": null, + "primary_file_name": "loopback_to_user_task.bpmn", + "primary_process_id": "loopback_to_user_task_process" +} \ No newline at end of file diff --git a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/loopback-to-user-task/test_loopback_to_user_task.json b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/loopback-to-user-task/test_loopback_to_user_task.json new file mode 100644 index 000000000..b78fc373d --- /dev/null +++ b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/loopback-to-user-task/test_loopback_to_user_task.json @@ -0,0 +1,13 @@ +{ + "test_case_one": { + "tasks": { + "user_task_enter_increment": { + "data": [ + { "user_input_variable": 7 }, + { "user_input_variable": 8 } + ] + } + }, + "expected_output_json": { "the_var": 15, "counter": 3, "user_input_variable": 8 } + } +} diff --git a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/loopback-to-user-task/user-input-schema.json b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/loopback-to-user-task/user-input-schema.json new file mode 100644 index 000000000..b85521a4f --- /dev/null +++ b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/loopback-to-user-task/user-input-schema.json @@ -0,0 +1,11 @@ +{ + "title": "User Input", + "description": "", + "properties": { + "user_input_variable": { + "type": "integer", + "title": "user_input_variable" + } + }, + "required": [] +} \ No newline at end of file diff --git a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/loopback-to-user-task/user-input-uischema.json b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/loopback-to-user-task/user-input-uischema.json new file mode 100644 index 000000000..5015ba504 --- /dev/null +++ b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/loopback-to-user-task/user-input-uischema.json @@ -0,0 +1,5 @@ +{ + "ui:order": [ + "user_input_variable" + ] +} \ No newline at end of file diff --git a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/loopback/loopback.bpmn b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/loopback/loopback.bpmn new file mode 100644 index 000000000..0d742ca72 --- /dev/null +++ b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/loopback/loopback.bpmn @@ -0,0 +1,92 @@ + + + + + Flow_12xxe7w + + + + Flow_0wnc5ju + Flow_0utss6p + Flow_1sg0c65 + + + + Flow_0utss6p + + + a == 3 + + + Flow_12xxe7w + Flow_08tc3r7 + a = 1 + + + + + + + Flow_08tc3r7 + Flow_1sg0c65 + Flow_0wnc5ju + a += 1 + + + + loop back if a < 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/loopback/process_model.json b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/loopback/process_model.json new file mode 100644 index 000000000..389bfeb4d --- /dev/null +++ b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/loopback/process_model.json @@ -0,0 +1,11 @@ +{ + "description": "", + "display_name": "Loopback", + "display_order": 0, + "exception_notification_addresses": [], + "fault_or_suspend_on_exception": "fault", + "files": [], + "metadata_extraction_paths": null, + "primary_file_name": "loopback.bpmn", + "primary_process_id": "loopback_process" +} \ No newline at end of file diff --git a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/loopback/test_loopback.json b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/loopback/test_loopback.json new file mode 100644 index 000000000..336551376 --- /dev/null +++ b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/loopback/test_loopback.json @@ -0,0 +1,5 @@ +{ + "test_case_1": { + "expected_output_json": { "a": 3 } + } +} diff --git a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/passing_tests/basic_manual_task/basic_manual_task.bpmn b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/manual-task/manual_task.bpmn similarity index 93% rename from spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/passing_tests/basic_manual_task/basic_manual_task.bpmn rename to spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/manual-task/manual_task.bpmn index 5d0bf395a..3ee85d4fc 100644 --- a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/passing_tests/basic_manual_task/basic_manual_task.bpmn +++ b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/manual-task/manual_task.bpmn @@ -1,6 +1,6 @@ - + Flow_0gz6i84 @@ -15,7 +15,7 @@ - + diff --git a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/manual-task/process_model.json b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/manual-task/process_model.json new file mode 100644 index 000000000..f843745dd --- /dev/null +++ b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/manual-task/process_model.json @@ -0,0 +1,9 @@ +{ + "description": "Manual Task", + "display_name": "Manual Task", + "exception_notification_addresses": [], + "fault_or_suspend_on_exception": "fault", + "files": [], + "primary_file_name": "manual_task.bpmn", + "primary_process_id": "ManualTaskProcess" +} diff --git a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/passing_tests/basic_manual_task/test_basic_manual_task.json b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/manual-task/test_manual_task.json similarity index 84% rename from spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/passing_tests/basic_manual_task/test_basic_manual_task.json rename to spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/manual-task/test_manual_task.json index fab44ab7b..889af9374 100644 --- a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/passing_tests/basic_manual_task/test_basic_manual_task.json +++ b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/manual-task/test_manual_task.json @@ -1,5 +1,5 @@ { - "test_case_one": { + "test_case_1": { "tasks": { "manual_task_one": { "data": [{}] diff --git a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/process_group.json b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/process_group.json new file mode 100644 index 000000000..9f562085c --- /dev/null +++ b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/process_group.json @@ -0,0 +1,9 @@ +{ + "admin": false, + "description": "", + "display_name": "Expected To Pass", + "display_order": 0, + "parent_groups": null, + "process_groups": [], + "process_models": [] +} \ No newline at end of file diff --git a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/passing_tests/basic_script_task/process_model.json b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/script-task/process_model.json similarity index 100% rename from spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/passing_tests/basic_script_task/process_model.json rename to spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/script-task/process_model.json diff --git a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/passing_tests/basic_script_task/basic_script_task.bpmn b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/script-task/script_task.bpmn similarity index 100% rename from spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/passing_tests/basic_script_task/basic_script_task.bpmn rename to spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/script-task/script_task.bpmn diff --git a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/passing_tests/basic_script_task/test_basic_script_task.json b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/script-task/test_script_task.json similarity index 69% rename from spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/passing_tests/basic_script_task/test_basic_script_task.json rename to spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/script-task/test_script_task.json index 8eb2df13d..98ff465b1 100644 --- a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/passing_tests/basic_script_task/test_basic_script_task.json +++ b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/script-task/test_script_task.json @@ -1,5 +1,5 @@ { - "test_case_one": { + "test_case_1": { "expected_output_json": { "a": 1 } } } diff --git a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/passing_tests/basic_service_task/process_model.json b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/service-task/process_model.json similarity index 100% rename from spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/passing_tests/basic_service_task/process_model.json rename to spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/service-task/process_model.json diff --git a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/passing_tests/basic_service_task/basic_service_task.bpmn b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/service-task/service_task.bpmn similarity index 89% rename from spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/passing_tests/basic_service_task/basic_service_task.bpmn rename to spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/service-task/service_task.bpmn index 8675d5910..178c16dae 100644 --- a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/passing_tests/basic_service_task/basic_service_task.bpmn +++ b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/service-task/service_task.bpmn @@ -1,6 +1,6 @@ - + Flow_19ephzh @@ -14,10 +14,10 @@ - + - - + + This is the Service Task Unit Test Screen. @@ -28,7 +28,7 @@ - + diff --git a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/passing_tests/basic_service_task/test_basic_service_task.json b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/service-task/test_service_task.json similarity index 69% rename from spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/passing_tests/basic_service_task/test_basic_service_task.json rename to spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/service-task/test_service_task.json index da0b47a11..7b5aae53a 100644 --- a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/passing_tests/basic_service_task/test_basic_service_task.json +++ b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/expected-to-pass/service-task/test_service_task.json @@ -1,7 +1,7 @@ { - "test_case_one": { + "test_case_1": { "tasks": { - "BasicServiceTaskProcess:service_task_one": { + "ServiceTaskProcess:service_task_one": { "data": [{ "the_result": "result_from_service" }] } }, diff --git a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/failing_tests/basic_failing_script_task/test_basic_failing_script_task.json b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/failing_tests/basic_failing_script_task/test_basic_failing_script_task.json deleted file mode 100644 index 553606003..000000000 --- a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/failing_tests/basic_failing_script_task/test_basic_failing_script_task.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "test_case_two": {} -} diff --git a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/passing_tests/basic_call_activity/process_model.json b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/passing_tests/basic_call_activity/process_model.json deleted file mode 100644 index 8f4e4a044..000000000 --- a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/passing_tests/basic_call_activity/process_model.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "description": "", - "display_name": "Basic Call Activity", - "exception_notification_addresses": [], - "fault_or_suspend_on_exception": "fault", - "files": [], - "primary_file_name": "basic_call_activity.bpmn", - "primary_process_id": "BasicCallActivityProcess" -} diff --git a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/passing_tests/basic_manual_task/process_model.json b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/passing_tests/basic_manual_task/process_model.json deleted file mode 100644 index 743dd104d..000000000 --- a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/passing_tests/basic_manual_task/process_model.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "description": "Baisc Manual Task", - "display_name": "Baisc Manual Task", - "exception_notification_addresses": [], - "fault_or_suspend_on_exception": "fault", - "files": [], - "primary_file_name": "baisc_manual_task.bpmn", - "primary_process_id": "BasicManualTaskProcess" -} diff --git a/spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_process_model_test_runner.py b/spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_process_model_test_runner.py index 80db51916..53abc61c7 100644 --- a/spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_process_model_test_runner.py +++ b/spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_process_model_test_runner.py @@ -21,7 +21,7 @@ class TestProcessModelTestRunner(BaseTest): with_db_and_bpmn_file_cleanup: None, with_mocked_root_path: Any, ) -> None: - process_model_test_runner = self._run_model_tests("basic_script_task") + process_model_test_runner = self._run_model_tests("script-task") assert len(process_model_test_runner.test_case_results) == 1 def test_will_raise_if_no_tests_found( @@ -50,7 +50,7 @@ class TestProcessModelTestRunner(BaseTest): with_db_and_bpmn_file_cleanup: None, with_mocked_root_path: Any, ) -> None: - process_model_test_runner = self._run_model_tests(parent_directory="failing_tests") + process_model_test_runner = self._run_model_tests(parent_directory="expected-to-fail") assert len(process_model_test_runner.test_case_results) == 1 def test_can_test_process_model_call_activity( @@ -59,7 +59,7 @@ class TestProcessModelTestRunner(BaseTest): with_db_and_bpmn_file_cleanup: None, with_mocked_root_path: Any, ) -> None: - process_model_test_runner = self._run_model_tests(bpmn_process_directory_name="basic_call_activity") + process_model_test_runner = self._run_model_tests(bpmn_process_directory_name="call-activity") assert len(process_model_test_runner.test_case_results) == 1 def test_can_test_process_model_with_service_task( @@ -68,11 +68,20 @@ class TestProcessModelTestRunner(BaseTest): with_db_and_bpmn_file_cleanup: None, with_mocked_root_path: Any, ) -> None: - process_model_test_runner = self._run_model_tests(bpmn_process_directory_name="basic_service_task") + process_model_test_runner = self._run_model_tests(bpmn_process_directory_name="service-task") + assert len(process_model_test_runner.test_case_results) == 1 + + def test_can_test_process_model_with_loopback_to_user_task( + self, + app: Flask, + with_db_and_bpmn_file_cleanup: None, + with_mocked_root_path: Any, + ) -> None: + process_model_test_runner = self._run_model_tests(bpmn_process_directory_name="loopback-to-user-task") assert len(process_model_test_runner.test_case_results) == 1 def _run_model_tests( - self, bpmn_process_directory_name: Optional[str] = None, parent_directory: str = "passing_tests" + self, bpmn_process_directory_name: Optional[str] = None, parent_directory: str = "expected-to-pass" ) -> ProcessModelTestRunner: base_process_model_dir_path_segments = [FileSystemService.root_path(), parent_directory] path_segments = base_process_model_dir_path_segments @@ -84,7 +93,7 @@ class TestProcessModelTestRunner(BaseTest): ) process_model_test_runner.run() - all_tests_expected_to_pass = parent_directory == "passing_tests" + all_tests_expected_to_pass = parent_directory == "expected-to-pass" assert ( process_model_test_runner.all_test_cases_passed() is all_tests_expected_to_pass ), process_model_test_runner.failing_tests_formatted()