mirror of
https://github.com/sartography/spiffworkflow-backend.git
synced 2025-02-23 21:08:18 +00:00
run pre-commit
This commit is contained in:
parent
8831f122eb
commit
0afd8e11b5
@ -49,6 +49,7 @@ class Script:
|
||||
We may be able to remove the task for each of these calls if we are not using it other than potentially
|
||||
updating the task data.
|
||||
"""
|
||||
|
||||
def make_closure(subclass, task, workflow_id):
|
||||
"""Yes - this is black magic.
|
||||
|
||||
@ -84,6 +85,7 @@ class Script:
|
||||
We may be able to remove the task for each of these calls if we are not using it other than potentially
|
||||
updating the task data.
|
||||
"""
|
||||
|
||||
def make_closure_validate(subclass, task, workflow_id):
|
||||
"""Make_closure_validate."""
|
||||
instance = subclass()
|
||||
|
@ -45,10 +45,13 @@ class ProcessModelService(FileSystemService):
|
||||
def process_model_delete(self, process_model_id: str):
|
||||
"""Delete Procecss Model."""
|
||||
instances = ProcessInstanceModel.query.filter(
|
||||
ProcessInstanceModel.process_model_identifier == process_model_id).all()
|
||||
ProcessInstanceModel.process_model_identifier == process_model_id
|
||||
).all()
|
||||
if len(instances) > 0:
|
||||
raise ApiError(code='existing_instances',
|
||||
message=f'We cannot delete the model `{process_model_id}`, there are existing instances that depend on it.')
|
||||
raise ApiError(
|
||||
code="existing_instances",
|
||||
message=f"We cannot delete the model `{process_model_id}`, there are existing instances that depend on it.",
|
||||
)
|
||||
spec = self.get_spec(process_model_id)
|
||||
if not spec:
|
||||
return
|
||||
|
@ -15,6 +15,7 @@ from flask_bpmn.models.db import db
|
||||
from tests.spiffworkflow_backend.helpers.test_data import find_or_create_user
|
||||
from tests.spiffworkflow_backend.helpers.test_data import load_test_spec
|
||||
from tests.spiffworkflow_backend.helpers.test_data import logged_in_headers
|
||||
from werkzeug.test import TestResponse
|
||||
|
||||
from spiffworkflow_backend.models.file import FileType
|
||||
from spiffworkflow_backend.models.process_group import ProcessGroup
|
||||
@ -24,8 +25,6 @@ from spiffworkflow_backend.models.process_model import ProcessModelInfo
|
||||
from spiffworkflow_backend.models.process_model import ProcessModelInfoSchema
|
||||
from spiffworkflow_backend.services.process_model_service import ProcessModelService
|
||||
|
||||
from werkzeug.test import TestResponse
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def with_bpmn_file_cleanup() -> Iterator[None]:
|
||||
@ -84,11 +83,13 @@ def test_process_model_delete_with_instances(
|
||||
user = find_or_create_user()
|
||||
headers = logged_in_headers(user)
|
||||
# create an instance from a model
|
||||
response = create_process_instance(app, client, test_process_group_id, test_process_model_id, headers)
|
||||
response = create_process_instance(
|
||||
app, client, test_process_group_id, test_process_model_id, headers
|
||||
)
|
||||
|
||||
data = json.loads(response.get_data(as_text=True))
|
||||
# make sure the instance has the correct model
|
||||
assert data['process_model_identifier'] == test_process_model_id
|
||||
assert data["process_model_identifier"] == test_process_model_id
|
||||
|
||||
# try to delete the model
|
||||
response = client.delete(
|
||||
@ -99,8 +100,11 @@ def test_process_model_delete_with_instances(
|
||||
# make sure we get an error in the response
|
||||
assert response.status_code == 400
|
||||
data = json.loads(response.get_data(as_text=True))
|
||||
assert data['code'] == 'existing_instances'
|
||||
assert data['message'] == 'We cannot delete the model `sample`, there are existing instances that depend on it.'
|
||||
assert data["code"] == "existing_instances"
|
||||
assert (
|
||||
data["message"]
|
||||
== "We cannot delete the model `sample`, there are existing instances that depend on it."
|
||||
)
|
||||
|
||||
|
||||
def test_process_model_update(
|
||||
@ -382,12 +386,14 @@ def test_process_instance_create(
|
||||
app: Flask, client: FlaskClient, with_bpmn_file_cleanup: None
|
||||
) -> None:
|
||||
"""Test_process_instance_create."""
|
||||
print('test_process_instance_create: ')
|
||||
print("test_process_instance_create: ")
|
||||
test_process_group_id = "runs_without_input"
|
||||
test_process_model_id = "sample"
|
||||
user = find_or_create_user()
|
||||
headers = logged_in_headers(user)
|
||||
response = create_process_instance(app, client, test_process_group_id, test_process_model_id, headers)
|
||||
response = create_process_instance(
|
||||
app, client, test_process_group_id, test_process_model_id, headers
|
||||
)
|
||||
assert response.json["status"] == "complete"
|
||||
assert response.json["process_model_identifier"] == test_process_model_id
|
||||
assert response.json["data"]["current_user"]["username"] == "test_user1"
|
||||
|
@ -1,5 +1,4 @@
|
||||
"""Test_file."""
|
||||
|
||||
from spiffworkflow_backend.models.file import File
|
||||
|
||||
|
||||
@ -16,4 +15,11 @@ def test_files_can_be_sorted() -> None:
|
||||
|
||||
def create_test_file(type: str, name: str):
|
||||
"""Create_test_file."""
|
||||
return File(type=type, name=name, content_type=type, document={}, last_modified="Tuesday", size="1")
|
||||
return File(
|
||||
type=type,
|
||||
name=name,
|
||||
content_type=type,
|
||||
document={},
|
||||
last_modified="Tuesday",
|
||||
size="1",
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user