only create the force run event if the instance was actually forced to run w/ burnettk (#1713)

Co-authored-by: jasquat <jasquat@users.noreply.github.com>
This commit is contained in:
jasquat 2024-06-11 14:40:04 -04:00 committed by GitHub
parent c674f0c157
commit 7536bc3716
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 45 additions and 1 deletions

View File

@ -670,7 +670,8 @@ def _process_instance_run(
processor = None processor = None
try: try:
ProcessInstanceTmpService.add_event_to_process_instance(process_instance, "process_instance_force_run") if force_run is True:
ProcessInstanceTmpService.add_event_to_process_instance(process_instance, "process_instance_force_run")
if not queue_process_instance_if_appropriate( if not queue_process_instance_if_appropriate(
process_instance, execution_mode=execution_mode process_instance, execution_mode=execution_mode
) and not ProcessInstanceTmpService.is_enqueued_to_run_in_the_future(process_instance): ) and not ProcessInstanceTmpService.is_enqueued_to_run_in_the_future(process_instance):

View File

@ -1150,6 +1150,49 @@ class TestProcessApi(BaseTest):
assert response.json["status"] == "complete" assert response.json["status"] == "complete"
assert response.json["process_model_identifier"] == process_model.id assert response.json["process_model_identifier"] == process_model.id
event_count = ProcessInstanceEventModel.query.filter_by(
process_instance_id=process_instance_id, event_type=ProcessInstanceEventType.process_instance_force_run.value
).count()
assert event_count == 0
def test_process_instance_run_with_force(
self,
app: Flask,
client: FlaskClient,
with_db_and_bpmn_file_cleanup: None,
with_super_admin_user: UserModel,
) -> None:
# process_model_id = "runs_without_input/sample"
process_model = self.create_group_and_model_with_bpmn(
client=client,
user=with_super_admin_user,
process_group_id="runs_without_input",
process_model_id="sample",
bpmn_file_name=None,
bpmn_file_location="sample",
)
headers = self.logged_in_headers(with_super_admin_user)
response = self.create_process_instance_from_process_model_id_with_api(client, process_model.id, headers)
assert response.json is not None
process_instance_id = response.json["id"]
response = client.post(
f"/v1.0/process-instances/{self.modify_process_identifier_for_path_param(process_model.id)}/{process_instance_id}/run?force_run=true",
headers=self.logged_in_headers(with_super_admin_user),
)
assert response.status_code == 200
assert response.json is not None
assert isinstance(response.json["updated_at_in_seconds"], int)
assert response.json["updated_at_in_seconds"] > 0
assert response.json["status"] == "complete"
assert response.json["process_model_identifier"] == process_model.id
event_count = ProcessInstanceEventModel.query.filter_by(
process_instance_id=process_instance_id, event_type=ProcessInstanceEventType.process_instance_force_run.value
).count()
assert event_count == 1
def test_process_instance_run_with_instructions( def test_process_instance_run_with_instructions(
self, self,
app: Flask, app: Flask,