add process model file delete api
This commit is contained in:
parent
76ae0a3dcf
commit
191faf2a17
|
@ -204,7 +204,7 @@ paths:
|
||||||
tags:
|
tags:
|
||||||
- Process Groups
|
- Process Groups
|
||||||
responses:
|
responses:
|
||||||
"204":
|
"200":
|
||||||
description: The process group was deleted.
|
description: The process group was deleted.
|
||||||
put:
|
put:
|
||||||
operationId: spiffworkflow_backend.routes.process_api_blueprint.process_group_update
|
operationId: spiffworkflow_backend.routes.process_api_blueprint.process_group_update
|
||||||
|
@ -299,7 +299,7 @@ paths:
|
||||||
operationId: spiffworkflow_backend.routes.process_api_blueprint.add_file
|
operationId: spiffworkflow_backend.routes.process_api_blueprint.add_file
|
||||||
summary: Add a new workflow spec file
|
summary: Add a new workflow spec file
|
||||||
tags:
|
tags:
|
||||||
- Spec Files
|
- Process Model Files
|
||||||
requestBody:
|
requestBody:
|
||||||
content:
|
content:
|
||||||
multipart/form-data:
|
multipart/form-data:
|
||||||
|
@ -320,7 +320,7 @@ paths:
|
||||||
# operationId: spiffworkflow_backend.api.process_api_blueprint.get_files
|
# operationId: spiffworkflow_backend.api.process_api_blueprint.get_files
|
||||||
# summary: Provide a list of workflow spec files for the given workflow_spec_id. IMPORTANT, only includes metadata, not the file content.
|
# summary: Provide a list of workflow spec files for the given workflow_spec_id. IMPORTANT, only includes metadata, not the file content.
|
||||||
# tags:
|
# tags:
|
||||||
# - Spec Files
|
# - Process Model Files
|
||||||
# responses:
|
# responses:
|
||||||
# '200':
|
# '200':
|
||||||
# description: An array of file descriptions (not the file content)
|
# description: An array of file descriptions (not the file content)
|
||||||
|
@ -366,7 +366,7 @@ paths:
|
||||||
- Process Models
|
- Process Models
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: The workflow specification has been removed.
|
description: The process model has been removed.
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
|
@ -743,7 +743,7 @@ paths:
|
||||||
operationId: spiffworkflow_backend.routes.process_api_blueprint.get_file
|
operationId: spiffworkflow_backend.routes.process_api_blueprint.get_file
|
||||||
summary: Returns metadata about the file
|
summary: Returns metadata about the file
|
||||||
tags:
|
tags:
|
||||||
- Spec Files
|
- Process Model Files
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: Returns the file information requested.
|
description: Returns the file information requested.
|
||||||
|
@ -756,7 +756,7 @@ paths:
|
||||||
operationId: spiffworkflow_backend.routes.process_api_blueprint.process_model_file_update
|
operationId: spiffworkflow_backend.routes.process_api_blueprint.process_model_file_update
|
||||||
summary: save the contents to the given file
|
summary: save the contents to the given file
|
||||||
tags:
|
tags:
|
||||||
- Spec Files
|
- Process Model Files
|
||||||
requestBody:
|
requestBody:
|
||||||
description: Log Pagination Request
|
description: Log Pagination Request
|
||||||
required: false
|
required: false
|
||||||
|
@ -775,14 +775,18 @@ paths:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#components/schemas/OkTrue"
|
$ref: "#components/schemas/OkTrue"
|
||||||
# delete:
|
delete:
|
||||||
# operationId: crc.api.spec_file.delete
|
operationId: spiffworkflow_backend.routes.process_api_blueprint.process_model_file_delete
|
||||||
# summary: Removes an existing workflow spec file.
|
summary: Removes an existing process model file
|
||||||
# tags:
|
tags:
|
||||||
# - Spec Files
|
- Process Model Files
|
||||||
# responses:
|
responses:
|
||||||
# '204':
|
"200":
|
||||||
# description: The file was removed.
|
description: The process model has been removed.
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#components/schemas/OkTrue"
|
||||||
|
|
||||||
/tasks:
|
/tasks:
|
||||||
parameters:
|
parameters:
|
||||||
|
|
|
@ -256,6 +256,25 @@ def process_model_file_update(
|
||||||
return Response(json.dumps({"ok": True}), status=200, mimetype="application/json")
|
return Response(json.dumps({"ok": True}), status=200, mimetype="application/json")
|
||||||
|
|
||||||
|
|
||||||
|
def process_model_file_delete(
|
||||||
|
process_group_id: str, process_model_id: str, file_name: str
|
||||||
|
) -> flask.wrappers.Response:
|
||||||
|
"""Process_model_file_delete."""
|
||||||
|
process_model = get_process_model(process_model_id, process_group_id)
|
||||||
|
try:
|
||||||
|
SpecFileService.delete_file(process_model, file_name)
|
||||||
|
except FileNotFoundError as exception:
|
||||||
|
raise (
|
||||||
|
ApiError(
|
||||||
|
code="process_model_file_cannot_be_found",
|
||||||
|
message=f"Process model file cannot be found: {file_name}",
|
||||||
|
status_code=400,
|
||||||
|
)
|
||||||
|
) from exception
|
||||||
|
|
||||||
|
return Response(json.dumps({"ok": True}), status=200, mimetype="application/json")
|
||||||
|
|
||||||
|
|
||||||
def add_file(process_group_id: str, process_model_id: str) -> flask.wrappers.Response:
|
def add_file(process_group_id: str, process_model_id: str) -> flask.wrappers.Response:
|
||||||
"""Add_file."""
|
"""Add_file."""
|
||||||
process_model_service = ProcessModelService()
|
process_model_service = ProcessModelService()
|
||||||
|
|
|
@ -446,6 +446,66 @@ class TestProcessApi(BaseTest):
|
||||||
assert original_file != updated_file
|
assert original_file != updated_file
|
||||||
assert updated_file["file_contents"] == new_file_contents.decode()
|
assert updated_file["file_contents"] == new_file_contents.decode()
|
||||||
|
|
||||||
|
def test_process_model_file_delete_when_bad_process_model(
|
||||||
|
self, app: Flask, client: FlaskClient, with_db_and_bpmn_file_cleanup: None
|
||||||
|
) -> None:
|
||||||
|
"""Test_process_model_file_update."""
|
||||||
|
self.create_spec_file(client)
|
||||||
|
|
||||||
|
spec = load_test_spec("random_fact")
|
||||||
|
user = self.find_or_create_user()
|
||||||
|
response = client.delete(
|
||||||
|
f"/v1.0/process-models/INCORRECT-NON-EXISTENT-GROUP/{spec.id}/file/random_fact.svg",
|
||||||
|
follow_redirects=True,
|
||||||
|
headers=logged_in_headers(user),
|
||||||
|
)
|
||||||
|
|
||||||
|
assert response.status_code == 400
|
||||||
|
assert response.json is not None
|
||||||
|
assert response.json["code"] == "process_model_cannot_be_found"
|
||||||
|
|
||||||
|
def test_process_model_file_delete_when_bad_file(
|
||||||
|
self, app: Flask, client: FlaskClient, with_db_and_bpmn_file_cleanup: None
|
||||||
|
) -> None:
|
||||||
|
"""Test_process_model_file_update."""
|
||||||
|
self.create_spec_file(client)
|
||||||
|
|
||||||
|
spec = load_test_spec("random_fact")
|
||||||
|
user = self.find_or_create_user()
|
||||||
|
response = client.delete(
|
||||||
|
f"/v1.0/process-models/{spec.process_group_id}/{spec.id}/file/random_fact_DOES_NOT_EXIST.svg",
|
||||||
|
follow_redirects=True,
|
||||||
|
headers=logged_in_headers(user),
|
||||||
|
)
|
||||||
|
|
||||||
|
assert response.status_code == 400
|
||||||
|
assert response.json is not None
|
||||||
|
assert response.json["code"] == "process_model_file_cannot_be_found"
|
||||||
|
|
||||||
|
def test_process_model_file_delete(
|
||||||
|
self, app: Flask, client: FlaskClient, with_db_and_bpmn_file_cleanup: None
|
||||||
|
) -> None:
|
||||||
|
"""Test_process_model_file_update."""
|
||||||
|
self.create_spec_file(client)
|
||||||
|
|
||||||
|
spec = load_test_spec("random_fact")
|
||||||
|
user = self.find_or_create_user()
|
||||||
|
response = client.delete(
|
||||||
|
f"/v1.0/process-models/{spec.process_group_id}/{spec.id}/file/random_fact.svg",
|
||||||
|
follow_redirects=True,
|
||||||
|
headers=logged_in_headers(user),
|
||||||
|
)
|
||||||
|
|
||||||
|
assert response.status_code == 200
|
||||||
|
assert response.json is not None
|
||||||
|
assert response.json["ok"]
|
||||||
|
|
||||||
|
response = client.get(
|
||||||
|
f"/v1.0/process-models/{spec.process_group_id}/{spec.id}/file/random_fact.svg",
|
||||||
|
headers=logged_in_headers(user),
|
||||||
|
)
|
||||||
|
assert response.status_code == 404
|
||||||
|
|
||||||
def test_get_file(
|
def test_get_file(
|
||||||
self, app: Flask, client: FlaskClient, with_db_and_bpmn_file_cleanup: None
|
self, app: Flask, client: FlaskClient, with_db_and_bpmn_file_cleanup: None
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
Loading…
Reference in New Issue