test for move model

This commit is contained in:
mike cullerton 2022-11-19 14:47:50 -05:00
parent d07114593f
commit 9717fb112c
1 changed files with 60 additions and 9 deletions

View File

@ -2370,15 +2370,8 @@ class TestProcessApi(BaseTest):
print("test_script_unit_test_run") print("test_script_unit_test_run")
def test_move_model(self): def setup_initial_groups_for_move_tests(
... self, client: FlaskClient, with_super_admin_user: UserModel
def test_move_group(
self,
app: Flask,
client: FlaskClient,
with_db_and_bpmn_file_cleanup: None,
with_super_admin_user: UserModel,
) -> None: ) -> None:
groups = [ groups = [
'group_a', 'group_b', 'group_b/group_bb' 'group_a', 'group_b', 'group_b/group_bb'
@ -2397,6 +2390,64 @@ class TestProcessApi(BaseTest):
assert persisted is not None assert persisted is not None
assert persisted.id == group assert persisted.id == group
def test_move_model(
self,
app: Flask,
client: FlaskClient,
with_db_and_bpmn_file_cleanup: None,
with_super_admin_user: UserModel,
):
"""test_move_model."""
self.setup_initial_groups_for_move_tests(client, with_super_admin_user)
process_model_id = 'test_model'
original_location = "group_a"
original_process_model_path = f"{original_location}/{process_model_id}"
# add model to `group_a`
self.create_process_model_with_api(
client,
original_process_model_path,
user=with_super_admin_user,
process_model_display_name=process_model_id,
process_model_description=process_model_id
)
persisted = ProcessModelService().get_process_model(original_process_model_path)
assert persisted is not None
assert persisted.id == original_process_model_path
# move model to `group_b/group_bb`
new_location = 'group_b/group_bb'
new_process_model_path = f"{new_location}/{process_model_id}"
modified_original_process_model_id = original_process_model_path.replace("/", ":")
response = client.put(
f"/v1.0/process-models/{modified_original_process_model_id}/move?new_location={new_location}",
headers=self.logged_in_headers(with_super_admin_user),
)
assert response.status_code == 201
assert response.json['id'] == new_process_model_path
# make sure the original model does not exist
with pytest.raises(ProcessEntityNotFoundError) as e:
ProcessModelService().get_process_model(original_process_model_path)
assert e.value.args[0] == 'process_model_not_found'
# make sure the new model does exist
new_process_model = ProcessModelService().get_process_model(new_process_model_path)
assert new_process_model is not None
assert new_process_model.id == new_process_model_path
def test_move_group(
self,
app: Flask,
client: FlaskClient,
with_db_and_bpmn_file_cleanup: None,
with_super_admin_user: UserModel,
) -> None:
"""test_move_group."""
self.setup_initial_groups_for_move_tests(client, with_super_admin_user)
# add sub group to `group_a` # add sub group to `group_a`
sub_group_id = 'sub_group' sub_group_id = 'sub_group'
original_location = 'group_a' original_location = 'group_a'