save all spiff tasks to the db after terminating a process instance w/ burnettk

This commit is contained in:
jasquat 2023-05-10 12:02:48 -04:00
parent f49c4d879f
commit 57fcadbd62
2 changed files with 16 additions and 2 deletions

View File

@ -1891,8 +1891,17 @@ class ProcessInstanceProcessor:
return None
def terminate(self) -> None:
"""Terminate."""
self.bpmn_process_instance.cancel()
start_time = time.time()
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.process_instance_model.status = "terminated"
db.session.add(self.process_instance_model)

View File

@ -1607,6 +1607,10 @@ class TestProcessApi(BaseTest):
assert response.status_code == 200
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(
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),
@ -1617,6 +1621,7 @@ class TestProcessApi(BaseTest):
process_instance = ProcessInstanceModel.query.filter_by(id=process_instance_id).first()
assert process_instance
assert process_instance.status == "terminated"
assert ready_task.state == "CANCELLED"
def test_process_instance_delete(
self,