mirror of
https://github.com/sartography/spiff-arena.git
synced 2025-02-22 22:28:15 +00:00
Merge remote-tracking branch 'origin/main' into newui-all-in
This commit is contained in:
commit
f97bdd8f12
2
.github/workflows/constraints.txt
vendored
2
.github/workflows/constraints.txt
vendored
@ -1,2 +1,2 @@
|
||||
pip==25.0
|
||||
pip==25.0.1
|
||||
poetry==2.0.1
|
||||
|
@ -5,6 +5,7 @@ from flask import g
|
||||
from SpiffWorkflow.bpmn import BpmnEvent # type: ignore
|
||||
from SpiffWorkflow.bpmn.specs.event_definitions.message import CorrelationProperty # type: ignore
|
||||
from SpiffWorkflow.bpmn.specs.mixins import StartEventMixin # type: ignore
|
||||
from SpiffWorkflow.exceptions import SpiffWorkflowException # type: ignore
|
||||
from SpiffWorkflow.spiff.specs.event_definitions import MessageEventDefinition # type: ignore
|
||||
|
||||
from spiffworkflow_backend.background_processing.celery_tasks.process_instance_task_producer import (
|
||||
@ -148,7 +149,7 @@ class MessageService:
|
||||
return None
|
||||
|
||||
except Exception as exception:
|
||||
db.session.rollback()
|
||||
# db.session.rollback() # don't try to roll this back. The message failed, and we need to know why.
|
||||
message_instance_send.status = "failed"
|
||||
message_instance_send.failure_cause = str(exception)
|
||||
db.session.add(message_instance_send)
|
||||
@ -160,6 +161,8 @@ class MessageService:
|
||||
processor_receive.save()
|
||||
else:
|
||||
db.session.commit()
|
||||
if isinstance(exception, SpiffWorkflowException):
|
||||
exception.add_note("The process instance encountered an error and failed after starting.")
|
||||
raise exception
|
||||
|
||||
@classmethod
|
||||
|
@ -0,0 +1,45 @@
|
||||
<?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:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_96f6665" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.0.0-dev">
|
||||
<bpmn:process id="MJE_Process_test" name="MJE Process" isExecutable="true" rootElements="[object Object]">
|
||||
<bpmn:startEvent id="Event_0szizt1">
|
||||
<bpmn:outgoing>Flow_0eqkmd7</bpmn:outgoing>
|
||||
<bpmn:messageEventDefinition id="MessageEventDefinition_04747ms" messageRef="test_bad_process">
|
||||
<bpmn:extensionElements />
|
||||
</bpmn:messageEventDefinition>
|
||||
</bpmn:startEvent>
|
||||
<bpmn:sequenceFlow id="Flow_0eqkmd7" sourceRef="Event_0szizt1" targetRef="Activity_0lfckkj" />
|
||||
<bpmn:endEvent id="Event_00kg1t1">
|
||||
<bpmn:incoming>Flow_0ur3sgf</bpmn:incoming>
|
||||
</bpmn:endEvent>
|
||||
<bpmn:sequenceFlow id="Flow_0ur3sgf" sourceRef="Activity_0lfckkj" targetRef="Event_00kg1t1" />
|
||||
<bpmn:scriptTask id="Activity_0lfckkj">
|
||||
<bpmn:incoming>Flow_0eqkmd7</bpmn:incoming>
|
||||
<bpmn:outgoing>Flow_0ur3sgf</bpmn:outgoing>
|
||||
<bpmn:script>x = 1 '123'asdfasdf;lkj #$!@#$$$#@#@</bpmn:script>
|
||||
</bpmn:scriptTask>
|
||||
</bpmn:process>
|
||||
<bpmn:message id="mje-process-receive-manual-entry-response" name="mje-process-receive-manual-entry-response" />
|
||||
<bpmn:message id="test_bad_process" name="test_bad_process" />
|
||||
<bpmn:correlationKey id="CorrelationKey_0d47qex" name="MainCorrelationKey" />
|
||||
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="MJE_Process_test">
|
||||
<bpmndi:BPMNShape id="Event_1gvyi5c_di" bpmnElement="Event_0szizt1">
|
||||
<dc:Bounds x="472" y="252" width="36" height="36" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Event_00kg1t1_di" bpmnElement="Event_00kg1t1">
|
||||
<dc:Bounds x="712" y="252" width="36" height="36" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Activity_0lpjds5_di" bpmnElement="Activity_0lfckkj">
|
||||
<dc:Bounds x="560" y="230" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNEdge id="Flow_0eqkmd7_di" bpmnElement="Flow_0eqkmd7">
|
||||
<di:waypoint x="508" y="270" />
|
||||
<di:waypoint x="560" y="270" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge id="Flow_0ur3sgf_di" bpmnElement="Flow_0ur3sgf">
|
||||
<di:waypoint x="660" y="270" />
|
||||
<di:waypoint x="712" y="270" />
|
||||
</bpmndi:BPMNEdge>
|
||||
</bpmndi:BPMNPlane>
|
||||
</bpmndi:BPMNDiagram>
|
||||
</bpmn:definitions>
|
@ -1,7 +1,9 @@
|
||||
import time
|
||||
|
||||
from flask import Flask
|
||||
from flask import g
|
||||
from flask.testing import FlaskClient
|
||||
from spiffworkflow_backend.helpers.spiff_enum import ProcessInstanceExecutionMode
|
||||
from spiffworkflow_backend.models.db import db
|
||||
from spiffworkflow_backend.models.message_instance import MessageInstanceModel
|
||||
from spiffworkflow_backend.models.message_triggerable_process_model import MessageTriggerableProcessModel
|
||||
@ -12,6 +14,7 @@ from spiffworkflow_backend.services.message_service import MessageService
|
||||
from spiffworkflow_backend.services.process_instance_processor import ProcessInstanceProcessor
|
||||
from spiffworkflow_backend.services.process_instance_service import ProcessInstanceService
|
||||
from spiffworkflow_backend.services.spec_file_service import SpecFileService
|
||||
from spiffworkflow_backend.services.workflow_execution_service import WorkflowExecutionServiceError
|
||||
|
||||
from tests.spiffworkflow_backend.helpers.base_test import BaseTest
|
||||
from tests.spiffworkflow_backend.helpers.test_data import load_test_spec
|
||||
@ -94,6 +97,42 @@ class TestMessageService(BaseTest):
|
||||
for message_instance in message_instances:
|
||||
assert message_instance.correlation_keys == {"invoice": {"po_number": 1001, "customer_id": "Sartography"}}
|
||||
|
||||
def test_start_process_with_message_when_failure(
|
||||
self,
|
||||
app: Flask,
|
||||
client: FlaskClient,
|
||||
with_db_and_bpmn_file_cleanup: None,
|
||||
) -> None:
|
||||
"""Assure we get a valid error when trying to start a process, and that process fails for some reason."""
|
||||
|
||||
# Load up the definition for the receiving process
|
||||
# It has a message start event that should cause it to fire when a unique message comes through
|
||||
# Fire up the first process
|
||||
load_test_spec(
|
||||
"test_group/message-start-with-error",
|
||||
process_model_source_directory="message-start-with-error",
|
||||
bpmn_file_name="message-start-with-error.bpmn",
|
||||
)
|
||||
|
||||
# Now send in the message
|
||||
user = self.find_or_create_user()
|
||||
message_triggerable_process_model = MessageTriggerableProcessModel.query.filter_by(
|
||||
message_name="test_bad_process"
|
||||
).first()
|
||||
assert message_triggerable_process_model is not None
|
||||
|
||||
MessageInstanceModel(
|
||||
message_type="send",
|
||||
name="test_bad_process",
|
||||
payload={},
|
||||
user_id=user.id,
|
||||
)
|
||||
g.user = user
|
||||
try:
|
||||
MessageService.run_process_model_from_message("test_bad_process", {}, ProcessInstanceExecutionMode.synchronous.value)
|
||||
except WorkflowExecutionServiceError as e:
|
||||
assert "The process instance encountered an error and failed after starting." in e.notes
|
||||
|
||||
def test_can_send_message_to_multiple_process_models(
|
||||
self,
|
||||
app: Flask,
|
||||
|
Loading…
x
Reference in New Issue
Block a user