added test to ensure the primary process id is properly udpated on save w/ burnettk
This commit is contained in:
parent
d8c5e99ac3
commit
b4c9acfa4c
|
@ -241,7 +241,7 @@ def get_file(process_group_id: str, process_model_id: str, file_name: str) -> An
|
|||
def process_model_file_update(
|
||||
process_group_id: str, process_model_id: str, file_name: str
|
||||
) -> flask.wrappers.Response:
|
||||
"""Process_model_file_save."""
|
||||
"""Process_model_file_update."""
|
||||
process_model = get_process_model(process_model_id, process_group_id)
|
||||
|
||||
request_file = get_file_from_request()
|
||||
|
|
|
@ -3,6 +3,7 @@ import io
|
|||
import json
|
||||
import time
|
||||
from typing import Any
|
||||
from conftest import with_db_and_bpmn_file_cleanup
|
||||
|
||||
import pytest
|
||||
from flask.app import Flask
|
||||
|
@ -39,16 +40,16 @@ class TestProcessApi(BaseTest):
|
|||
self, app: Flask, client: FlaskClient, with_db_and_bpmn_file_cleanup: None
|
||||
) -> None:
|
||||
"""Test_add_new_process_model."""
|
||||
model_id = "sample"
|
||||
process_model_identifier = "sample"
|
||||
model_display_name = "Sample"
|
||||
model_description = "The sample"
|
||||
self.create_process_model_with_api(
|
||||
client,
|
||||
process_model_id=model_id,
|
||||
process_model_id=process_model_identifier,
|
||||
process_model_display_name=model_display_name,
|
||||
process_model_description=model_description,
|
||||
)
|
||||
process_model = ProcessModelService().get_process_model(model_id)
|
||||
process_model = ProcessModelService().get_process_model(process_model_identifier)
|
||||
assert model_display_name == process_model.display_name
|
||||
assert 0 == process_model.display_order
|
||||
assert 1 == len(ProcessModelService().get_process_groups())
|
||||
|
@ -63,10 +64,43 @@ class TestProcessApi(BaseTest):
|
|||
file_data=bpmn_file_data_bytes,
|
||||
process_model=process_model,
|
||||
)
|
||||
process_model = ProcessModelService().get_process_model(model_id)
|
||||
process_model = ProcessModelService().get_process_model(process_model_identifier)
|
||||
assert process_model.primary_file_name == bpmn_file_name
|
||||
assert process_model.primary_process_id == "sample"
|
||||
|
||||
def test_primary_process_id_updates_via_xml(self, app: Flask, client: FlaskClient, with_db_and_bpmn_file_cleanup: None) -> None:
|
||||
process_model_identifier = "sample"
|
||||
initial_primary_process_id = "sample"
|
||||
terminal_primary_process_id = "new_process_id"
|
||||
|
||||
process_model = load_test_spec(process_model_id=process_model_identifier)
|
||||
assert process_model.primary_process_id == initial_primary_process_id
|
||||
|
||||
bpmn_file_name = "sample.bpmn"
|
||||
bpmn_file_data_bytes = self.get_test_data_file_contents(
|
||||
bpmn_file_name, "sample"
|
||||
)
|
||||
bpmn_file_data_string = bpmn_file_data_bytes.decode('utf-8')
|
||||
old_string = f'bpmn:process id="{initial_primary_process_id}"'
|
||||
new_string = f'bpmn:process id="{terminal_primary_process_id}"'
|
||||
updated_bpmn_file_data_string = bpmn_file_data_string.replace(old_string, new_string)
|
||||
updated_bpmn_file_data_bytes = bytearray(updated_bpmn_file_data_string, 'utf-8')
|
||||
data = {"file": (io.BytesIO(updated_bpmn_file_data_bytes), bpmn_file_name)}
|
||||
|
||||
user = self.find_or_create_user()
|
||||
response = client.put(
|
||||
f"/v1.0/process-models/{process_model.process_group_id}/{process_model.id}/files/{bpmn_file_name}",
|
||||
data=data,
|
||||
follow_redirects=True,
|
||||
content_type="multipart/form-data",
|
||||
headers=logged_in_headers(user),
|
||||
)
|
||||
assert response.status_code == 200
|
||||
process_model = ProcessModelService().get_process_model(process_model_identifier)
|
||||
assert process_model.primary_file_name == bpmn_file_name
|
||||
assert process_model.primary_process_id == terminal_primary_process_id
|
||||
|
||||
|
||||
def test_process_model_delete(
|
||||
self, app: Flask, client: FlaskClient, with_db_and_bpmn_file_cleanup: None
|
||||
) -> None:
|
||||
|
@ -160,11 +194,11 @@ class TestProcessApi(BaseTest):
|
|||
|
||||
# add 5 models to the group
|
||||
for i in range(5):
|
||||
model_id = f"test_model_{i}"
|
||||
process_model_identifier = f"test_model_{i}"
|
||||
model_display_name = f"Test Model {i}"
|
||||
model_description = f"Test Model {i} Description"
|
||||
self.create_process_model_with_api(
|
||||
client, group_id, model_id, model_display_name, model_description
|
||||
client, group_id, process_model_identifier, model_display_name, model_description
|
||||
)
|
||||
|
||||
# get all models
|
||||
|
|
Loading…
Reference in New Issue