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 fb20d89459
commit b1046d29ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 7 deletions

View File

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

View File

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

View File

@ -1,6 +1,5 @@
"""Test Process Api Blueprint."""
import io
from flask_bpmn.api.api_error import ApiError
import json
import os
import time
@ -2049,6 +2048,7 @@ class TestProcessApi(BaseTest):
with_db_and_bpmn_file_cleanup: None,
with_super_admin_user: UserModel,
) -> None:
"""Test_task_data_is_set_even_if_process_instance_errors."""
process_model = load_test_spec(
process_model_id="group/error_with_task_data",
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),
)
assert response.status_code == 400
assert process_instance.status == 'error'
assert process_instance.status == "error"
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.data != {}

View File

@ -31,7 +31,7 @@ class TestProcessInstanceProcessor(BaseTest):
with_db_and_bpmn_file_cleanup: None,
) -> None:
"""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
script_engine = ProcessInstanceProcessor._script_engine
@ -46,7 +46,7 @@ class TestProcessInstanceProcessor(BaseTest):
with_db_and_bpmn_file_cleanup: None,
) -> None:
"""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
script_engine = ProcessInstanceProcessor._script_engine
result = script_engine._evaluate("fact_service(type='norris')", {})