From 2f98891489a55b8db7edb54ef07dcac6c83c2f78 Mon Sep 17 00:00:00 2001 From: jasquat Date: Tue, 16 May 2023 17:32:53 -0400 Subject: [PATCH] added test for failing test and multiple at once w/ burnettk --- .../process_model_test_runner_service.py | 6 +++ .../basic_failing_script_task.bpmn | 41 +++++++++++++++++++ .../process_model.json | 11 +++++ .../test_basic_failing_script_task.json | 3 ++ .../test_process_model_test_runner_service.py | 10 +++++ 5 files changed, 71 insertions(+) create mode 100644 spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/basic_failing_script_task/basic_failing_script_task.bpmn create mode 100644 spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/basic_failing_script_task/process_model.json create mode 100644 spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/basic_failing_script_task/test_basic_failing_script_task.json 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 a6ae27fda..a615dc5a3 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 @@ -30,6 +30,10 @@ class UnrunnableTestCaseError(Exception): pass +class MissingBpmnFileForTestCaseError(Exception): + pass + + @dataclass class TestCaseResult: passed: bool @@ -122,6 +126,8 @@ class ProcessModelTestRunner: bpmn_file_path = os.path.join(file_dir, bpmn_file_name) if os.path.isfile(bpmn_file_path): test_mappings[file] = bpmn_file_path + else: + raise MissingBpmnFileForTestCaseError(f"Cannot find a matching bpmn file for test case json file: '{file}'") return test_mappings diff --git a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/basic_failing_script_task/basic_failing_script_task.bpmn b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/basic_failing_script_task/basic_failing_script_task.bpmn new file mode 100644 index 000000000..4b0463358 --- /dev/null +++ b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/basic_failing_script_task/basic_failing_script_task.bpmn @@ -0,0 +1,41 @@ + + + + + Flow_1xkc1ru + + + + Flow_0tkkq9s + + + + Flow_1xkc1ru + Flow_0tkkq9s + a = 1 +b = a + 'two' + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/basic_failing_script_task/process_model.json b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/basic_failing_script_task/process_model.json new file mode 100644 index 000000000..26f25510d --- /dev/null +++ b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/basic_failing_script_task/process_model.json @@ -0,0 +1,11 @@ +{ + "description": "Process that raises an exception", + "display_name": "Failing Process", + "display_order": 0, + "exception_notification_addresses": [], + "fault_or_suspend_on_exception": "fault", + "files": [], + "metadata_extraction_paths": null, + "primary_file_name": "failing_task.bpmn", + "primary_process_id": "Process_FailingProcess" +} \ No newline at end of file diff --git a/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/basic_failing_script_task/test_basic_failing_script_task.json b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/basic_failing_script_task/test_basic_failing_script_task.json new file mode 100644 index 000000000..553606003 --- /dev/null +++ b/spiffworkflow-backend/tests/data/bpmn_unit_test_process_models/basic_failing_script_task/test_basic_failing_script_task.json @@ -0,0 +1,3 @@ +{ + "test_case_two": {} +} diff --git a/spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_process_model_test_runner_service.py b/spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_process_model_test_runner_service.py index b09322352..d202a35c5 100644 --- a/spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_process_model_test_runner_service.py +++ b/spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_process_model_test_runner_service.py @@ -29,6 +29,16 @@ class TestProcessModelTestRunnerService(BaseTest): test_runner_service.run() assert test_runner_service.process_model_test_runner.all_test_cases_passed() + def test_can_test_multiple_process_models( + self, + app: Flask, + with_db_and_bpmn_file_cleanup: None, + with_mocked_root_path: any, + ) -> None: + test_runner_service = ProcessModelTestRunnerService(FileSystemService.root_path()) + test_runner_service.run() + assert test_runner_service.process_model_test_runner.all_test_cases_passed() is False + @pytest.fixture() def with_mocked_root_path(self, mocker: MockerFixture) -> None: path = os.path.join(