pre-commit, let all tests pass, remove test json
This commit is contained in:
parent
7fde291c14
commit
4829ff1e0e
|
@ -1,3 +1,5 @@
|
|||
from __future__ import with_statement
|
||||
|
||||
import logging
|
||||
from logging.config import fileConfig
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
"""empty message
|
||||
|
||||
Revision ID: 1c5de31868b3
|
||||
Revision ID: 68f9de219015
|
||||
Revises:
|
||||
Create Date: 2022-06-03 10:47:53.001354
|
||||
Create Date: 2022-06-08 18:46:43.860709
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
|
@ -10,7 +10,7 @@ import sqlalchemy as sa
|
|||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '1c5de31868b3'
|
||||
revision = '68f9de219015'
|
||||
down_revision = None
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
@ -41,6 +41,15 @@ def upgrade():
|
|||
sa.UniqueConstraint('uid'),
|
||||
sa.UniqueConstraint('username')
|
||||
)
|
||||
op.create_table('principal',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('user_id', sa.Integer(), nullable=True),
|
||||
sa.Column('group_id', sa.Integer(), nullable=True),
|
||||
sa.CheckConstraint('NOT(user_id IS NULL AND group_id IS NULL)'),
|
||||
sa.ForeignKeyConstraint(['group_id'], ['group.id'], ),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('process_instance',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('process_model_identifier', sa.String(length=50), nullable=False),
|
||||
|
@ -127,6 +136,7 @@ def downgrade():
|
|||
op.drop_table('user_group_assignment')
|
||||
op.drop_index(op.f('ix_process_instance_process_model_identifier'), table_name='process_instance')
|
||||
op.drop_table('process_instance')
|
||||
op.drop_table('principal')
|
||||
op.drop_table('user')
|
||||
op.drop_table('group')
|
||||
op.drop_table('admin_session')
|
|
@ -1 +1,2 @@
|
|||
BPMN_SPEC_ABSOLUTE_DIR = 'BPMN_SPECS_DEV'
|
||||
"""config."""
|
||||
BPMN_SPEC_ABSOLUTE_DIR = "BPMN_SPECS_DEV"
|
||||
|
|
|
@ -166,7 +166,7 @@ paths:
|
|||
tags:
|
||||
- Process Models
|
||||
responses:
|
||||
'204':
|
||||
"204":
|
||||
description: The workflow specification has been removed.
|
||||
# put:
|
||||
# operationId: crc.api.workflow.update_workflow_specification
|
||||
|
|
|
@ -14,6 +14,7 @@ from spiffworkflow_backend.models.process_group import ProcessGroupSchema
|
|||
from spiffworkflow_backend.models.process_instance import ProcessInstanceApiSchema
|
||||
from spiffworkflow_backend.models.process_instance import ProcessInstanceModel
|
||||
from spiffworkflow_backend.models.process_model import ProcessModelInfoSchema
|
||||
from spiffworkflow_backend.models.principal import PrincipalModel
|
||||
from spiffworkflow_backend.services.process_instance_processor import (
|
||||
ProcessInstanceProcessor,
|
||||
)
|
||||
|
@ -29,8 +30,12 @@ from spiffworkflow_backend.services.spec_file_service import SpecFileService
|
|||
|
||||
process_api_blueprint = Blueprint("process_api", __name__)
|
||||
|
||||
|
||||
def process_group_add(body):
|
||||
"""Add_process_group."""
|
||||
# just so the import is used. oh, and it's imported because spiffworkflow_backend/unit/test_permissions.py depends on it, and otherwise flask migrations won't include it in the list of database tables.
|
||||
PrincipalModel()
|
||||
|
||||
process_model_service = ProcessModelService()
|
||||
process_group = ProcessGroupSchema().load(body)
|
||||
process_model_service.add_process_group(process_group)
|
||||
|
@ -40,24 +45,31 @@ def process_group_add(body):
|
|||
mimetype="application/json",
|
||||
)
|
||||
|
||||
|
||||
def process_group_delete(process_group_id):
|
||||
"""Process_groups_delete."""
|
||||
...
|
||||
|
||||
|
||||
def process_groups_list():
|
||||
"""Process_groups_list."""
|
||||
process_groups = ProcessModelService().get_process_groups()
|
||||
return ProcessGroupSchema(many=True).dump(process_groups)
|
||||
|
||||
|
||||
def process_group_show(process_group_id):
|
||||
"""Process_group_show."""
|
||||
process_group = ProcessModelService().get_process_group(process_group_id)
|
||||
return ProcessGroupSchema().dump(process_group)
|
||||
|
||||
|
||||
def process_model_add(body):
|
||||
"""Add_process_model."""
|
||||
process_model_info = ProcessModelInfoSchema().load(body)
|
||||
process_model_service = ProcessModelService()
|
||||
process_group = process_model_service.get_process_group(process_model_info.process_group_id)
|
||||
process_group = process_model_service.get_process_group(
|
||||
process_model_info.process_group_id
|
||||
)
|
||||
process_model_info.process_group = process_group
|
||||
workflows = process_model_service.cleanup_workflow_spec_display_order(process_group)
|
||||
size = len(workflows)
|
||||
|
@ -69,8 +81,10 @@ def process_model_add(body):
|
|||
mimetype="application/json",
|
||||
)
|
||||
|
||||
|
||||
def process_model_delete(process_model_id):
|
||||
result = ProcessModelService().process_model_delete(process_model_id)
|
||||
"""Process_model_delete."""
|
||||
ProcessModelService().process_model_delete(process_model_id)
|
||||
|
||||
|
||||
def process_model_show(process_model_id):
|
||||
|
@ -90,6 +104,7 @@ def process_model_show(process_model_id):
|
|||
process_model_json = ProcessModelInfoSchema().dump(process_model)
|
||||
return process_model_json
|
||||
|
||||
|
||||
def get_file(process_model_id, file_name):
|
||||
"""Get_file."""
|
||||
process_model = ProcessModelService().get_spec(process_model_id)
|
||||
|
@ -109,12 +124,14 @@ def get_file(process_model_id, file_name):
|
|||
file.process_group_id = process_model.process_group_id
|
||||
return FileSchema().dump(file)
|
||||
|
||||
|
||||
def process_model_file_save(process_model_id, file_name):
|
||||
"""Process_model_file_save."""
|
||||
process_model = ProcessModelService().get_spec(process_model_id)
|
||||
SpecFileService.update_file(process_model, file_name, request.get_data())
|
||||
return Response(json.dumps({"ok": True}), status=200, mimetype="application/json")
|
||||
|
||||
|
||||
def add_file(process_model_id):
|
||||
"""Add_file."""
|
||||
process_model_service = ProcessModelService()
|
||||
|
@ -134,6 +151,7 @@ def add_file(process_model_id):
|
|||
json.dumps(FileSchema().dump(file)), status=201, mimetype="application/json"
|
||||
)
|
||||
|
||||
|
||||
def process_instance_create(process_model_id):
|
||||
"""Create_process_instance."""
|
||||
process_instance = ProcessInstanceService.create_process_instance(
|
||||
|
@ -155,6 +173,7 @@ def process_instance_create(process_model_id):
|
|||
json.dumps(process_instance_metadata), status=201, mimetype="application/json"
|
||||
)
|
||||
|
||||
|
||||
def process_instance_list(process_model_id, page=1, per_page=100):
|
||||
"""Process_instance_list."""
|
||||
process_model = ProcessModelService().get_spec(process_model_id)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_0ixyfs0" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.5.0">
|
||||
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_0ixyfs0" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.0.0">
|
||||
<bpmn:process id="Process_HelloWorld" name="Hello World Process" isExecutable="true">
|
||||
<bpmn:documentation>This workflow asks for a name and says hello</bpmn:documentation>
|
||||
<bpmn:startEvent id="StartEvent_1">
|
||||
|
@ -10,7 +10,7 @@
|
|||
<bpmn:documentation>Hello</bpmn:documentation>
|
||||
<bpmn:extensionElements>
|
||||
<camunda:formData>
|
||||
<camunda:formField id="name" label="'Name'" type="string" defaultValue="World" />
|
||||
<camunda:formField id="name" label="'Name'" type="string" defaultValue="World" />
|
||||
</camunda:formData>
|
||||
</bpmn:extensionElements>
|
||||
<bpmn:incoming>SequenceFlow_0qyd2b7</bpmn:incoming>
|
||||
|
@ -26,33 +26,46 @@
|
|||
<bpmn:incoming>SequenceFlow_0lqrc6e</bpmn:incoming>
|
||||
</bpmn:endEvent>
|
||||
<bpmn:sequenceFlow id="SequenceFlow_0lqrc6e" sourceRef="Task_SayHello" targetRef="EndEvent_1l03lqw" />
|
||||
<bpmn:subProcess id="Activity_0uv5ubt">
|
||||
<bpmn:startEvent id="Event_0jubmia" />
|
||||
</bpmn:subProcess>
|
||||
</bpmn:process>
|
||||
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_HelloWorld">
|
||||
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
|
||||
<dc:Bounds x="179" y="99" width="36" height="36" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNEdge id="SequenceFlow_0qyd2b7_di" bpmnElement="SequenceFlow_0qyd2b7">
|
||||
<di:waypoint x="215" y="117" />
|
||||
<di:waypoint x="270" y="117" />
|
||||
<bpmndi:BPMNEdge id="SequenceFlow_0lqrc6e_di" bpmnElement="SequenceFlow_0lqrc6e">
|
||||
<di:waypoint x="530" y="117" />
|
||||
<di:waypoint x="592" y="117" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNShape id="UserTask_0fbucz7_di" bpmnElement="Task_GetName">
|
||||
<dc:Bounds x="270" y="77" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNEdge id="SequenceFlow_1h46b40_di" bpmnElement="SequenceFlow_1h46b40">
|
||||
<di:waypoint x="370" y="117" />
|
||||
<di:waypoint x="430" y="117" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge id="SequenceFlow_0qyd2b7_di" bpmnElement="SequenceFlow_0qyd2b7">
|
||||
<di:waypoint x="215" y="117" />
|
||||
<di:waypoint x="270" y="117" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
|
||||
<dc:Bounds x="179" y="99" width="36" height="36" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="UserTask_0fbucz7_di" bpmnElement="Task_GetName">
|
||||
<dc:Bounds x="270" y="77" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="ManualTask_1tia2zr_di" bpmnElement="Task_SayHello">
|
||||
<dc:Bounds x="430" y="77" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="EndEvent_1l03lqw_di" bpmnElement="EndEvent_1l03lqw">
|
||||
<dc:Bounds x="592" y="99" width="36" height="36" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNEdge id="SequenceFlow_0lqrc6e_di" bpmnElement="SequenceFlow_0lqrc6e">
|
||||
<di:waypoint x="530" y="117" />
|
||||
<di:waypoint x="592" y="117" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNShape id="Activity_0uv5ubt_di" bpmnElement="Activity_0uv5ubt" isExpanded="false">
|
||||
<dc:Bounds x="365" y="200" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
</bpmndi:BPMNPlane>
|
||||
</bpmndi:BPMNDiagram>
|
||||
<bpmndi:BPMNDiagram id="BPMNDiagram_04r6k7u">
|
||||
<bpmndi:BPMNPlane id="BPMNPlane_15oexby" bpmnElement="Activity_0uv5ubt">
|
||||
<bpmndi:BPMNShape id="Event_0jubmia_di" bpmnElement="Event_0jubmia">
|
||||
<dc:Bounds x="180" y="80" width="36" height="36" />
|
||||
</bpmndi:BPMNShape>
|
||||
</bpmndi:BPMNPlane>
|
||||
</bpmndi:BPMNDiagram>
|
||||
</bpmn:definitions>
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -39,22 +39,23 @@ def test_add_new_process_model(app, client: FlaskClient, with_bpmn_file_cleanup)
|
|||
|
||||
|
||||
def test_process_model_delete(app, client: FlaskClient, with_bpmn_file_cleanup):
|
||||
"""Test_process_model_delete."""
|
||||
create_process_model(app, client)
|
||||
|
||||
# assert we have a model
|
||||
process_model = ProcessModelService().get_spec('make_cookies')
|
||||
process_model = ProcessModelService().get_spec("make_cookies")
|
||||
assert process_model is not None
|
||||
assert process_model.id == 'make_cookies'
|
||||
assert process_model.id == "make_cookies"
|
||||
|
||||
# delete the model
|
||||
user = find_or_create_user()
|
||||
response = client.delete(f"/v1.0/process-models/{process_model.id}",
|
||||
headers=logged_in_headers(user)
|
||||
)
|
||||
response = client.delete(
|
||||
f"/v1.0/process-models/{process_model.id}", headers=logged_in_headers(user)
|
||||
)
|
||||
assert response.status_code == 204
|
||||
|
||||
# assert we no longer have a model
|
||||
process_model = ProcessModelService().get_spec('make_cookies')
|
||||
process_model = ProcessModelService().get_spec("make_cookies")
|
||||
assert process_model is None
|
||||
|
||||
|
||||
|
@ -80,10 +81,11 @@ def test_process_group_add(app, client: FlaskClient, with_bpmn_file_cleanup):
|
|||
# Check what is persisted
|
||||
persisted = ProcessModelService().get_process_group("test")
|
||||
assert persisted.display_name == "Another Test Category"
|
||||
assert persisted.id == 'test'
|
||||
assert persisted.id == "test"
|
||||
|
||||
|
||||
def test_process_group_delete(app, client: FlaskClient, with_bpmn_file_cleanup):
|
||||
"""Test_process_group_delete."""
|
||||
process_group_id = "test"
|
||||
process_group_display_name = "My Process Group"
|
||||
# process_group = ProcessGroup(
|
||||
|
@ -99,14 +101,17 @@ def test_process_group_delete(app, client: FlaskClient, with_bpmn_file_cleanup):
|
|||
# content_type="application/json",
|
||||
# data=json.dumps(ProcessGroupSchema().dump(process_group)),
|
||||
# )
|
||||
response = create_process_group(client, user, process_group_id, display_name=process_group_display_name)
|
||||
create_process_group(
|
||||
client, user, process_group_id, display_name=process_group_display_name
|
||||
)
|
||||
persisted = ProcessModelService().get_process_group(process_group_id)
|
||||
assert persisted is not None
|
||||
assert persisted.id == process_group_id
|
||||
|
||||
client.delete(f"/v1.0/process-models/{process_group_id}")
|
||||
|
||||
print(f'test_process_group_delete: {__name__}')
|
||||
print(f"test_process_group_delete: {__name__}")
|
||||
|
||||
|
||||
# def test_get_process_model(self):
|
||||
#
|
||||
|
@ -164,7 +169,9 @@ def test_get_file(app, client: FlaskClient, with_bpmn_file_cleanup):
|
|||
assert response.json["process_model_id"] == "hello_world"
|
||||
|
||||
|
||||
def test_get_workflow_from_workflow_spec(app, client: FlaskClient, with_bpmn_file_cleanup):
|
||||
def test_get_workflow_from_workflow_spec(
|
||||
app, client: FlaskClient, with_bpmn_file_cleanup
|
||||
):
|
||||
"""Test_get_workflow_from_workflow_spec."""
|
||||
user = find_or_create_user()
|
||||
spec = load_test_spec(app, "hello_world")
|
||||
|
@ -184,7 +191,9 @@ def test_get_process_groups_when_none(app, client: FlaskClient, with_bpmn_file_c
|
|||
assert response.json == []
|
||||
|
||||
|
||||
def test_get_process_groups_when_there_are_some(app, client: FlaskClient, with_bpmn_file_cleanup):
|
||||
def test_get_process_groups_when_there_are_some(
|
||||
app, client: FlaskClient, with_bpmn_file_cleanup
|
||||
):
|
||||
"""Test_get_process_groups_when_there_are_some."""
|
||||
user = find_or_create_user()
|
||||
load_test_spec(app, "hello_world")
|
||||
|
@ -274,9 +283,6 @@ def test_process_instance_list_with_default_list(
|
|||
assert response.json["pagination"]["total"] == 1
|
||||
|
||||
process_instance_dict = response.json["results"][0]
|
||||
f = open("bpmn.json", "w")
|
||||
f.write(process_instance_dict["bpmn_json"])
|
||||
f.close()
|
||||
assert type(process_instance_dict["id"]) is int
|
||||
assert process_instance_dict["process_model_identifier"] == process_model_dir_name
|
||||
assert process_instance_dict["process_group_id"] == test_process_group_id
|
||||
|
@ -421,12 +427,10 @@ def create_spec_file(app, client: FlaskClient):
|
|||
return file
|
||||
|
||||
|
||||
def create_process_group(client, user, process_group_id, display_name=''):
|
||||
def create_process_group(client, user, process_group_id, display_name=""):
|
||||
"""Create_process_group."""
|
||||
process_group = ProcessGroup(
|
||||
id=process_group_id,
|
||||
display_name=display_name,
|
||||
display_order=0,
|
||||
admin=False
|
||||
id=process_group_id, display_name=display_name, display_order=0, admin=False
|
||||
)
|
||||
response = client.post(
|
||||
"/v1.0/process-groups",
|
||||
|
@ -435,5 +439,5 @@ def create_process_group(client, user, process_group_id, display_name=''):
|
|||
data=json.dumps(ProcessGroupSchema().dump(process_group)),
|
||||
)
|
||||
assert response.status_code == 201
|
||||
assert response.json['id'] == process_group_id
|
||||
assert response.json["id"] == process_group_id
|
||||
return response
|
||||
|
|
Loading…
Reference in New Issue