Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data obj show use params #1160

Merged
merged 7 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions spiffworkflow-backend/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions spiffworkflow-backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ flask-mail = "*"
flask-marshmallow = "*"
flask-migrate = "*"
flask-restful = "*"
SpiffWorkflow = {git = "https://github.com/sartography/SpiffWorkflow", rev = "633de80a722cf28f4a79df9de7be911130f1f5ad"}
SpiffWorkflow = {git = "https://github.com/sartography/SpiffWorkflow", rev = "main"}
# SpiffWorkflow = {develop = true, path = "../../spiffworkflow/" }
# SpiffWorkflow = {develop = true, path = "../../SpiffWorkflow/" }
sentry-sdk = "^1.10"
Expand Down Expand Up @@ -100,7 +100,11 @@ ruff = "^0.1.7"
pytest-random-order = "^1.1.0"
pytest-flask = "^1.2.0"
pytest-flask-sqlalchemy = "^1.1.0"
pytest-xdist = "^3.3.1"

# 3.4+ broke existfirst option which we use
# https://stackoverflow.com/questions/77667559/pytest-xdist-3-40-and-higher-not-honoring-exitfirst
# https://github.com/pytest-dev/pytest-xdist/issues/1034
pytest-xdist = "3.3.1"

# 1.7.3 broke us. https://github.com/PyCQA/bandit/issues/841
bandit = "1.7.7"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def payload_matches_expected_values(
if expected_value is None: # This key is not required for this instance to match.
continue
try:
result = expression_engine._evaluate(correlation_key.retrieval_expression, payload)
result = expression_engine.environment.evaluate(correlation_key.retrieval_expression, payload)
except Exception as e:
# the failure of a payload evaluation may not mean that matches for these
# message instances can't happen with other messages. So don't error up.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,29 +347,14 @@ def __get_augment_methods(self, task: SpiffTask | None) -> dict[str, Callable]:
)
return Script.generate_augmented_list(script_attributes_context)

def evaluate(
self,
task: SpiffTask,
expression: str,
external_context: dict[str, Any] | None = None,
) -> Any:
return self._evaluate(expression, task.data, task, external_context)

def _evaluate(
self,
expression: str,
context: dict[str, Any],
task: SpiffTask | None = None,
external_context: dict[str, Any] | None = None,
) -> Any:
def evaluate(self, task: SpiffTask, expression: str, external_context: dict[str, Any] | None = None) -> Any:
"""Evaluate the given expression, within the context of the given task and return the result."""

methods = self.__get_augment_methods(task)
if external_context:
methods.update(external_context)

try:
return super()._evaluate(expression, context, external_context=methods)
return super().evaluate(task, expression, external_context=methods)
jasquat marked this conversation as resolved.
Show resolved Hide resolved
except Exception as exception:
if task is None:
raise WorkflowException(
jasquat marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def run_with_script_and_pre_post_contexts(

try:
cls._script_engine.environment.clear_state()
cls._script_engine._execute(context=context, script=script)
external_context = None
cls._script_engine.environment.execute(script, context, external_context)
jasquat marked this conversation as resolved.
Show resolved Hide resolved
except SyntaxError as ex:
return ScriptUnitTestResult(
result=False,
Expand Down
200 changes: 0 additions & 200 deletions spiffworkflow-backend/tests/data/random_fact/random_fact2.bpmn

This file was deleted.

51 changes: 51 additions & 0 deletions spiffworkflow-backend/tests/data/random_fact/random_fact_set.bpmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1gjhqt9" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.7.0">
<bpmn:process id="Process_SecondFact" isExecutable="true">
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>Flow_1ctusgn</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:scriptTask id="Task_Get_Fact_From_API" name="Display Fact">
<bpmn:documentation />
<bpmn:extensionElements>
<camunda:inputOutput>
<camunda:inputParameter name="Fact.type" />
</camunda:inputOutput>
</bpmn:extensionElements>
<bpmn:incoming>Flow_1ctusgn</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_0t29gjo</bpmn:outgoing>
<bpmn:script>FactService = fact_service(type='norris')</bpmn:script>
</bpmn:scriptTask>
<bpmn:endEvent id="EndEvent_0u1cgrf">
<bpmn:documentation># Great Job!
You have completed the random fact generator.
You chose to receive a random fact of the type: "{{type}}"

Your random fact is:
{{details}}</bpmn:documentation>
<bpmn:incoming>SequenceFlow_0t29gjo</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="SequenceFlow_0t29gjo" sourceRef="Task_Get_Fact_From_API" targetRef="EndEvent_0u1cgrf" />
<bpmn:sequenceFlow id="Flow_1ctusgn" sourceRef="StartEvent_1" targetRef="Task_Get_Fact_From_API" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_SecondFact">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="152" y="232" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="ScriptTask_10keafb_di" bpmnElement="Task_Get_Fact_From_API">
<dc:Bounds x="350" y="210" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="EndEvent_0u1cgrf_di" bpmnElement="EndEvent_0u1cgrf">
<dc:Bounds x="582" y="232" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_0t29gjo_di" bpmnElement="SequenceFlow_0t29gjo">
<di:waypoint x="450" y="250" />
<di:waypoint x="582" y="250" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1ctusgn_di" bpmnElement="Flow_1ctusgn">
<di:waypoint x="188" y="250" />
<di:waypoint x="350" y="250" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from tests.spiffworkflow_backend.helpers.test_data import load_test_spec


class TestJSONFileDataStore(BaseTest):
class TestJsonFileDataStore(BaseTest):
def test_can_execute_diagram(
self,
app: Flask,
Expand Down
Loading
Loading