Make list available to script tasks (#86)

This commit is contained in:
jbirddog 2022-12-28 17:04:47 -05:00 committed by GitHub
parent 3a7a80ded1
commit 0aaf503c3f
4 changed files with 8 additions and 7 deletions

View File

@ -1,5 +1,3 @@
from __future__ import with_statement
import logging import logging
from logging.config import fileConfig from logging.config import fileConfig

View File

@ -152,6 +152,7 @@ class CustomBpmnScriptEngine(PythonScriptEngine): # type: ignore
"decimal": decimal, "decimal": decimal,
"_strptime": _strptime, "_strptime": _strptime,
"enumerate": enumerate, "enumerate": enumerate,
"list": list,
} }
# This will overwrite the standard builtins # This will overwrite the standard builtins

View File

@ -1,6 +1,5 @@
"""Test Process Api Blueprint.""" """Test Process Api Blueprint."""
import io import io
from flask_bpmn.api.api_error import ApiError
import json import json
import os import os
import time import time
@ -2049,6 +2048,7 @@ class TestProcessApi(BaseTest):
with_db_and_bpmn_file_cleanup: None, with_db_and_bpmn_file_cleanup: None,
with_super_admin_user: UserModel, with_super_admin_user: UserModel,
) -> None: ) -> None:
"""Test_task_data_is_set_even_if_process_instance_errors."""
process_model = load_test_spec( process_model = load_test_spec(
process_model_id="group/error_with_task_data", process_model_id="group/error_with_task_data",
bpmn_file_name="script_error_with_task_data.bpmn", bpmn_file_name="script_error_with_task_data.bpmn",
@ -2063,9 +2063,11 @@ class TestProcessApi(BaseTest):
headers=self.logged_in_headers(with_super_admin_user), headers=self.logged_in_headers(with_super_admin_user),
) )
assert response.status_code == 400 assert response.status_code == 400
assert process_instance.status == 'error' assert process_instance.status == "error"
processor = ProcessInstanceProcessor(process_instance) processor = ProcessInstanceProcessor(process_instance)
spiff_task = processor.get_task_by_bpmn_identifier('script_task_one', processor.bpmn_process_instance) spiff_task = processor.get_task_by_bpmn_identifier(
"script_task_one", processor.bpmn_process_instance
)
assert spiff_task is not None assert spiff_task is not None
assert spiff_task.data != {} assert spiff_task.data != {}

View File

@ -31,7 +31,7 @@ class TestProcessInstanceProcessor(BaseTest):
with_db_and_bpmn_file_cleanup: None, with_db_and_bpmn_file_cleanup: None,
) -> None: ) -> None:
"""Test_script_engine_takes_data_and_returns_expected_results.""" """Test_script_engine_takes_data_and_returns_expected_results."""
app.config["THREAD_LOCAL_DATA"].process_model_identifier = 'hey' app.config["THREAD_LOCAL_DATA"].process_model_identifier = "hey"
app.config["THREAD_LOCAL_DATA"].process_instance_id = 0 app.config["THREAD_LOCAL_DATA"].process_instance_id = 0
script_engine = ProcessInstanceProcessor._script_engine script_engine = ProcessInstanceProcessor._script_engine
@ -46,7 +46,7 @@ class TestProcessInstanceProcessor(BaseTest):
with_db_and_bpmn_file_cleanup: None, with_db_and_bpmn_file_cleanup: None,
) -> None: ) -> None:
"""Test_script_engine_takes_data_and_returns_expected_results.""" """Test_script_engine_takes_data_and_returns_expected_results."""
app.config["THREAD_LOCAL_DATA"].process_model_identifier = 'hey' app.config["THREAD_LOCAL_DATA"].process_model_identifier = "hey"
app.config["THREAD_LOCAL_DATA"].process_instance_id = 0 app.config["THREAD_LOCAL_DATA"].process_instance_id = 0
script_engine = ProcessInstanceProcessor._script_engine script_engine = ProcessInstanceProcessor._script_engine
result = script_engine._evaluate("fact_service(type='norris')", {}) result = script_engine._evaluate("fact_service(type='norris')", {})