test removing an approver from a list while user lane_owners dict w/ burnettk

This commit is contained in:
jasquat 2022-10-25 17:35:17 -04:00
parent 2f3332040f
commit d19477e390
3 changed files with 61 additions and 12 deletions

View File

@ -0,0 +1,26 @@
"""Get_env."""
from typing import Any
from flask import g
from typing import Optional
from SpiffWorkflow.task import Task as SpiffTask # type: ignore
from spiffworkflow_backend.scripts.script import Script
class GetUser(Script):
"""GetUser."""
def get_description(self) -> str:
"""Get_description."""
return """Return the current user."""
def run(
self,
task: Optional[SpiffTask],
environment_identifier: str,
*_args: Any,
**kwargs: Any
) -> Any:
"""Run."""
return g.user.username

View File

@ -14,6 +14,7 @@
<bpmn:lane id="finance_team" name="Finance Team">
<bpmn:flowNodeRef>finance_approval_one</bpmn:flowNodeRef>
<bpmn:flowNodeRef>finance_approval_two</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Activity_1s1855p</bpmn:flowNodeRef>
</bpmn:lane>
<bpmn:lane id="bigwig" name="Bigwig">
<bpmn:flowNodeRef>Event_0nsh6vv</bpmn:flowNodeRef>
@ -58,22 +59,31 @@
"Process Initiator": ['testadmin1']
}</bpmn:script>
</bpmn:scriptTask>
<bpmn:sequenceFlow id="Flow_1i3fkto" sourceRef="finance_approval_one" targetRef="finance_approval_two" />
<bpmn:sequenceFlow id="Flow_1aluose" sourceRef="finance_approval_two" targetRef="initiator_two" />
<bpmn:manualTask id="finance_approval_one" name="Finance Approval One">
<bpmn:extensionElements>
<spiffworkflow:instructionsForEndUser>This is finance user one?</spiffworkflow:instructionsForEndUser>
<spiffworkflow:postScript />
<spiffworkflow:preScript />
</bpmn:extensionElements>
<bpmn:incoming>Flow_13ejjwk</bpmn:incoming>
<bpmn:outgoing>Flow_1i3fkto</bpmn:outgoing>
<bpmn:outgoing>Flow_0bgkfue</bpmn:outgoing>
</bpmn:manualTask>
<bpmn:manualTask id="finance_approval_two" name="Finance Approval Two">
<bpmn:extensionElements>
<spiffworkflow:instructionsForEndUser>This is finance user two?</spiffworkflow:instructionsForEndUser>
<spiffworkflow:instructionsForEndUser>This is finance user two? {{approver}}</spiffworkflow:instructionsForEndUser>
</bpmn:extensionElements>
<bpmn:incoming>Flow_1i3fkto</bpmn:incoming>
<bpmn:incoming>Flow_1ivhu7x</bpmn:incoming>
<bpmn:outgoing>Flow_1aluose</bpmn:outgoing>
</bpmn:manualTask>
<bpmn:sequenceFlow id="Flow_0bgkfue" sourceRef="finance_approval_one" targetRef="Activity_1s1855p" />
<bpmn:sequenceFlow id="Flow_1ivhu7x" sourceRef="Activity_1s1855p" targetRef="finance_approval_two" />
<bpmn:scriptTask id="Activity_1s1855p" scriptFormat="python">
<bpmn:incoming>Flow_0bgkfue</bpmn:incoming>
<bpmn:outgoing>Flow_1ivhu7x</bpmn:outgoing>
<bpmn:script>approver = get_user()
lane_owners["Finance Team"].remove(approver)</bpmn:script>
</bpmn:scriptTask>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_0iyw0q7">
@ -115,11 +125,14 @@
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1y566d5_di" bpmnElement="finance_approval_one">
<dc:Bounds x="420" y="320" width="100" height="80" />
<dc:Bounds x="340" y="320" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1rq1fsj_di" bpmnElement="finance_approval_two">
<dc:Bounds x="550" y="320" width="100" height="80" />
<dc:Bounds x="600" y="320" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0g8uv6m_di" bpmnElement="Activity_1s1855p">
<dc:Bounds x="470" y="320" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_1tbyols_di" bpmnElement="Flow_1tbyols">
<di:waypoint x="215" y="177" />
@ -139,16 +152,24 @@
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_13ejjwk_di" bpmnElement="Flow_13ejjwk">
<di:waypoint x="460" y="220" />
<di:waypoint x="460" y="320" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1i3fkto_di" bpmnElement="Flow_1i3fkto">
<di:waypoint x="520" y="360" />
<di:waypoint x="550" y="360" />
<di:waypoint x="460" y="270" />
<di:waypoint x="380" y="270" />
<di:waypoint x="380" y="320" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1aluose_di" bpmnElement="Flow_1aluose">
<di:waypoint x="600" y="320" />
<di:waypoint x="650" y="320" />
<di:waypoint x="650" y="269" />
<di:waypoint x="600" y="269" />
<di:waypoint x="600" y="217" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0bgkfue_di" bpmnElement="Flow_0bgkfue">
<di:waypoint x="440" y="360" />
<di:waypoint x="470" y="360" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1ivhu7x_di" bpmnElement="Flow_1ivhu7x">
<di:waypoint x="570" y="360" />
<di:waypoint x="600" y="360" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>

View File

@ -1,5 +1,6 @@
"""Test_process_instance_processor."""
import pytest
from flask import g
from flask.app import Flask
from tests.spiffworkflow_backend.helpers.base_test import BaseTest
from tests.spiffworkflow_backend.helpers.test_data import load_test_spec
@ -177,6 +178,7 @@ class TestProcessInstanceProcessor(BaseTest):
processor, spiff_task, {}, initiator_user
)
g.user = finance_user_three
ProcessInstanceService.complete_form_task(
processor, spiff_task, {}, finance_user_three
)