mirror of
https://github.com/status-im/spiff-arena.git
synced 2025-01-29 19:25:50 +00:00
save all spiff tasks to the db after terminating a process instance w/ burnettk
This commit is contained in:
parent
f49c4d879f
commit
57fcadbd62
@ -1891,8 +1891,17 @@ class ProcessInstanceProcessor:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def terminate(self) -> None:
|
def terminate(self) -> None:
|
||||||
"""Terminate."""
|
start_time = time.time()
|
||||||
self.bpmn_process_instance.cancel()
|
deleted_tasks = self.bpmn_process_instance.cancel() or []
|
||||||
|
spiff_tasks = self.bpmn_process_instance.get_tasks()
|
||||||
|
|
||||||
|
task_service = TaskService(
|
||||||
|
process_instance=self.process_instance_model,
|
||||||
|
serializer=self._serializer,
|
||||||
|
bpmn_definition_to_task_definitions_mappings=self.bpmn_definition_to_task_definitions_mappings,
|
||||||
|
)
|
||||||
|
task_service.update_all_tasks_from_spiff_tasks(spiff_tasks, deleted_tasks, start_time)
|
||||||
|
|
||||||
self.save()
|
self.save()
|
||||||
self.process_instance_model.status = "terminated"
|
self.process_instance_model.status = "terminated"
|
||||||
db.session.add(self.process_instance_model)
|
db.session.add(self.process_instance_model)
|
||||||
|
@ -1607,6 +1607,10 @@ class TestProcessApi(BaseTest):
|
|||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
assert response.json is not None
|
assert response.json is not None
|
||||||
|
|
||||||
|
ready_tasks = TaskModel.query.filter_by(process_instance_id=process_instance_id, state="READY").all()
|
||||||
|
assert len(ready_tasks) == 1
|
||||||
|
ready_task = ready_tasks[0]
|
||||||
|
|
||||||
response = client.post(
|
response = client.post(
|
||||||
f"/v1.0/process-instance-terminate/{self.modify_process_identifier_for_path_param(process_model_identifier)}/{process_instance_id}",
|
f"/v1.0/process-instance-terminate/{self.modify_process_identifier_for_path_param(process_model_identifier)}/{process_instance_id}",
|
||||||
headers=self.logged_in_headers(with_super_admin_user),
|
headers=self.logged_in_headers(with_super_admin_user),
|
||||||
@ -1617,6 +1621,7 @@ class TestProcessApi(BaseTest):
|
|||||||
process_instance = ProcessInstanceModel.query.filter_by(id=process_instance_id).first()
|
process_instance = ProcessInstanceModel.query.filter_by(id=process_instance_id).first()
|
||||||
assert process_instance
|
assert process_instance
|
||||||
assert process_instance.status == "terminated"
|
assert process_instance.status == "terminated"
|
||||||
|
assert ready_task.state == "CANCELLED"
|
||||||
|
|
||||||
def test_process_instance_delete(
|
def test_process_instance_delete(
|
||||||
self,
|
self,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user