From 4829ff1e0e20f604f301d37bb177f91c6116c94c Mon Sep 17 00:00:00 2001 From: burnettk Date: Wed, 8 Jun 2022 18:47:38 -0400 Subject: [PATCH] pre-commit, let all tests pass, remove test json --- bpmn.json | 1 - migrations/env.py | 2 + .../{1c5de31868b3_.py => 68f9de219015_.py} | 16 +- src/instance/config.py | 3 +- src/spiffworkflow_backend/api.yml | 2 +- .../routes/process_api_blueprint.py | 23 +- tests/data/hello_world/hello_world.bpmn | 43 +- .../integration/bpmn.json | 431 +++++++++++++++++- .../integration/test_process_api.py | 44 +- 9 files changed, 521 insertions(+), 44 deletions(-) delete mode 100644 bpmn.json rename migrations/versions/{1c5de31868b3_.py => 68f9de219015_.py} (91%) diff --git a/bpmn.json b/bpmn.json deleted file mode 100644 index d63fcd31..00000000 --- a/bpmn.json +++ /dev/null @@ -1 +0,0 @@ -{"spec": {"name": "sample", "description": "sample", "file": "sample.bpmn", "task_specs": {"Start": {"id": "sample_1", "name": "Start", "description": "", "manual": false, "internal": false, "position": {"x": 0, "y": 0}, "lookahead": 2, "inputs": [], "outputs": ["StartEvent_1"], "typename": "StartTask"}, "sample.EndJoin": {"id": "sample_2", "name": "sample.EndJoin", "description": "", "manual": false, "internal": false, "position": {"x": 0, "y": 0}, "lookahead": 2, "inputs": ["Event_1qb1u6a"], "outputs": ["End"], "typename": "_EndJoin"}, "End": {"id": "sample_3", "name": "End", "description": "", "manual": false, "internal": false, "position": {"x": 0, "y": 0}, "lookahead": 2, "inputs": ["sample.EndJoin"], "outputs": [], "typename": "Simple"}, "StartEvent_1": {"id": "sample_4", "name": "StartEvent_1", "description": null, "manual": false, "internal": false, "position": {"x": 152.0, "y": 102.0}, "lookahead": 2, "inputs": ["Start"], "outputs": ["Activity_0pxf6g1"], "lane": null, "documentation": null, "loopTask": false, "outgoing_sequence_flows": {"Activity_0pxf6g1": {"id": "Flow_10jwwqy", "name": null, "documentation": null, "target_task_spec": "Activity_0pxf6g1", "typename": "SequenceFlow"}}, "outgoing_sequence_flows_by_id": {"Flow_10jwwqy": {"id": "Flow_10jwwqy", "name": null, "documentation": null, "target_task_spec": "Activity_0pxf6g1", "typename": "SequenceFlow"}}, "event_definition": {"internal": false, "external": false, "typename": "NoneEventDefinition"}, "typename": "StartEvent", "extensions": {}}, "Activity_0pxf6g1": {"id": "sample_5", "name": "Activity_0pxf6g1", "description": "My Script", "manual": false, "internal": false, "position": {"x": 240.0, "y": 80.0}, "lookahead": 2, "inputs": ["StartEvent_1"], "outputs": ["Activity_0a21ntf"], "lane": null, "documentation": null, "loopTask": false, "outgoing_sequence_flows": {"Activity_0a21ntf": {"id": "Flow_0htxke7", "name": null, "documentation": null, "target_task_spec": "Activity_0a21ntf", "typename": "SequenceFlow"}}, "outgoing_sequence_flows_by_id": {"Flow_0htxke7": {"id": "Flow_0htxke7", "name": null, "documentation": null, "target_task_spec": "Activity_0a21ntf", "typename": "SequenceFlow"}}, "script": "my_var = \"Hello World\"\nMike = \"Awesome\"\nperson = \"Kevin\"", "typename": "ScriptTask", "extensions": {}}, "Activity_0a21ntf": {"id": "sample_6", "name": "Activity_0a21ntf", "description": "is wonderful?", "manual": false, "internal": false, "position": {"x": 0, "y": 0}, "lookahead": 2, "inputs": ["Activity_0pxf6g1"], "outputs": ["Event_1qb1u6a"], "lane": null, "documentation": null, "loopTask": false, "outgoing_sequence_flows": {"Event_1qb1u6a": {"id": "Flow_1hd6o66", "name": null, "documentation": null, "target_task_spec": "Event_1qb1u6a", "typename": "SequenceFlow"}}, "outgoing_sequence_flows_by_id": {"Flow_1hd6o66": {"id": "Flow_1hd6o66", "name": null, "documentation": null, "target_task_spec": "Event_1qb1u6a", "typename": "SequenceFlow"}}, "decision_table": {"id": "DecisionTable_02m334z", "name": "", "inputs": [{"id": "Input_1", "label": "", "name": "", "expression": "person", "typeRef": "string"}], "outputs": [{"id": "Output_1", "label": "", "name": "wonderfulness", "typeRef": "string"}], "rules": [{"id": "DecisionRule_1hnzjl8", "description": "", "input_entries": [{"id": "UnaryTests_1pb0ou0", "input_id": "Input_1", "description": "", "lhs": ["\"Dan\""]}], "output_entries": [{"id": "LiteralExpression_0rtsxgu", "output_id": "Output_1", "description": "", "text": "\"pretty wonderful\""}]}, {"id": "DecisionRule_1cc73tk", "description": "", "input_entries": [{"id": "UnaryTests_1fbj1wn", "input_id": "Input_1", "description": "", "lhs": ["\"Kevin\""]}], "output_entries": [{"id": "LiteralExpression_1d9nsnp", "output_id": "Output_1", "description": "", "text": "\"Very wonderful\""}]}, {"id": "DecisionRule_09y32t9", "description": "", "input_entries": [{"id": "UnaryTests_05h3qcx", "input_id": "Input_1", "description": "", "lhs": ["\"Mike\""]}], "output_entries": [{"id": "LiteralExpression_15b83d9", "output_id": "Output_1", "description": "", "text": "\"Powerful wonderful\""}]}]}, "typename": "BusinessRuleTask", "extensions": {}}, "Event_1qb1u6a": {"id": "sample_7", "name": "Event_1qb1u6a", "description": null, "manual": false, "internal": false, "position": {"x": 802.0, "y": 92.0}, "lookahead": 2, "inputs": ["Activity_0a21ntf"], "outputs": ["sample.EndJoin"], "lane": null, "documentation": null, "loopTask": false, "outgoing_sequence_flows": {"sample.EndJoin": {"id": "Event_1qb1u6a.ToEndJoin", "name": null, "documentation": null, "target_task_spec": "sample.EndJoin", "typename": "SequenceFlow"}}, "outgoing_sequence_flows_by_id": {"Event_1qb1u6a.ToEndJoin": {"id": "Event_1qb1u6a.ToEndJoin", "name": null, "documentation": null, "target_task_spec": "sample.EndJoin", "typename": "SequenceFlow"}}, "event_definition": {"internal": false, "external": false, "typename": "NoneEventDefinition"}, "typename": "EndEvent", "extensions": {}}, "Root": {"id": "sample_8", "name": "Root", "description": "", "manual": false, "internal": false, "position": {"x": 0, "y": 0}, "lookahead": 2, "inputs": [], "outputs": [], "typename": "Simple"}}, "typename": "BpmnProcessSpec"}, "data": {"validate_only": false, "process_instance_id": 2, "current_user": {"id": "1", "username": "test_user1"}, "my_var": "Hello World", "Mike": "Awesome", "person": "Kevin", "wonderfulness": "Very wonderful"}, "last_task": "84ef3400-c33f-43e1-83bb-bc566a1afa46", "success": true, "tasks": {"cc2faa0a-b8fa-42f4-a88f-cdfc978305a7": {"id": "cc2faa0a-b8fa-42f4-a88f-cdfc978305a7", "parent": null, "children": ["6e7577a5-569e-4057-9ba4-c1d922a83df9"], "last_state_change": 1654706714.31301, "state": 32, "task_spec": "Root", "triggered": false, "workflow_name": "sample", "internal_data": {}, "data": {}}, "6e7577a5-569e-4057-9ba4-c1d922a83df9": {"id": "6e7577a5-569e-4057-9ba4-c1d922a83df9", "parent": "cc2faa0a-b8fa-42f4-a88f-cdfc978305a7", "children": ["9f599db1-bb4b-4142-90ac-1b40096ebbaa"], "last_state_change": 1654706714.3216362, "state": 32, "task_spec": "Start", "triggered": false, "workflow_name": "sample", "internal_data": {}, "data": {"current_user": {"id": "1", "username": "test_user1"}}}, "9f599db1-bb4b-4142-90ac-1b40096ebbaa": {"id": "9f599db1-bb4b-4142-90ac-1b40096ebbaa", "parent": "6e7577a5-569e-4057-9ba4-c1d922a83df9", "children": ["7863bc11-1abb-452a-9d48-160d1120c39e"], "last_state_change": 1654706714.322082, "state": 32, "task_spec": "StartEvent_1", "triggered": false, "workflow_name": "sample", "internal_data": {"event_fired": true}, "data": {"current_user": {"id": "1", "username": "test_user1"}}}, "7863bc11-1abb-452a-9d48-160d1120c39e": {"id": "7863bc11-1abb-452a-9d48-160d1120c39e", "parent": "9f599db1-bb4b-4142-90ac-1b40096ebbaa", "children": ["364c7f1c-0fa8-4b79-9ebd-142a0ce6b408"], "last_state_change": 1654706714.3224819, "state": 32, "task_spec": "Activity_0pxf6g1", "triggered": false, "workflow_name": "sample", "internal_data": {}, "data": {"current_user": {"id": "1", "username": "test_user1"}, "my_var": "Hello World", "Mike": "Awesome", "person": "Kevin"}}, "364c7f1c-0fa8-4b79-9ebd-142a0ce6b408": {"id": "364c7f1c-0fa8-4b79-9ebd-142a0ce6b408", "parent": "7863bc11-1abb-452a-9d48-160d1120c39e", "children": ["2bb08a37-c0e0-4992-ba62-6f0cd4653d7f"], "last_state_change": 1654706714.322956, "state": 32, "task_spec": "Activity_0a21ntf", "triggered": false, "workflow_name": "sample", "internal_data": {}, "data": {"current_user": {"id": "1", "username": "test_user1"}, "my_var": "Hello World", "Mike": "Awesome", "person": "Kevin", "wonderfulness": "Very wonderful"}}, "2bb08a37-c0e0-4992-ba62-6f0cd4653d7f": {"id": "2bb08a37-c0e0-4992-ba62-6f0cd4653d7f", "parent": "364c7f1c-0fa8-4b79-9ebd-142a0ce6b408", "children": ["003f4eb1-14b0-4653-8a6d-9b95f7ae4d1c"], "last_state_change": 1654706714.323554, "state": 32, "task_spec": "Event_1qb1u6a", "triggered": false, "workflow_name": "sample", "internal_data": {}, "data": {"current_user": {"id": "1", "username": "test_user1"}, "my_var": "Hello World", "Mike": "Awesome", "person": "Kevin", "wonderfulness": "Very wonderful"}}, "003f4eb1-14b0-4653-8a6d-9b95f7ae4d1c": {"id": "003f4eb1-14b0-4653-8a6d-9b95f7ae4d1c", "parent": "2bb08a37-c0e0-4992-ba62-6f0cd4653d7f", "children": ["84ef3400-c33f-43e1-83bb-bc566a1afa46"], "last_state_change": 1654706714.3241432, "state": 32, "task_spec": "sample.EndJoin", "triggered": false, "workflow_name": "sample", "internal_data": {}, "data": {"current_user": {"id": "1", "username": "test_user1"}, "my_var": "Hello World", "Mike": "Awesome", "person": "Kevin", "wonderfulness": "Very wonderful"}}, "84ef3400-c33f-43e1-83bb-bc566a1afa46": {"id": "84ef3400-c33f-43e1-83bb-bc566a1afa46", "parent": "003f4eb1-14b0-4653-8a6d-9b95f7ae4d1c", "children": [], "last_state_change": 1654706714.32453, "state": 32, "task_spec": "End", "triggered": false, "workflow_name": "sample", "internal_data": {}, "data": {"current_user": {"id": "1", "username": "test_user1"}, "my_var": "Hello World", "Mike": "Awesome", "person": "Kevin", "wonderfulness": "Very wonderful"}}}, "root": "cc2faa0a-b8fa-42f4-a88f-cdfc978305a7", "subprocess_specs": {}, "subprocesses": {}, "serializer_version": "1.0-CRC"} \ No newline at end of file diff --git a/migrations/env.py b/migrations/env.py index 630e381a..68feded2 100644 --- a/migrations/env.py +++ b/migrations/env.py @@ -1,3 +1,5 @@ +from __future__ import with_statement + import logging from logging.config import fileConfig diff --git a/migrations/versions/1c5de31868b3_.py b/migrations/versions/68f9de219015_.py similarity index 91% rename from migrations/versions/1c5de31868b3_.py rename to migrations/versions/68f9de219015_.py index d7bc2a12..a334736c 100644 --- a/migrations/versions/1c5de31868b3_.py +++ b/migrations/versions/68f9de219015_.py @@ -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') diff --git a/src/instance/config.py b/src/instance/config.py index 39816aa3..3c7a6af9 100644 --- a/src/instance/config.py +++ b/src/instance/config.py @@ -1 +1,2 @@ -BPMN_SPEC_ABSOLUTE_DIR = 'BPMN_SPECS_DEV' +"""config.""" +BPMN_SPEC_ABSOLUTE_DIR = "BPMN_SPECS_DEV" diff --git a/src/spiffworkflow_backend/api.yml b/src/spiffworkflow_backend/api.yml index 0d184e3c..cee504fa 100755 --- a/src/spiffworkflow_backend/api.yml +++ b/src/spiffworkflow_backend/api.yml @@ -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 diff --git a/src/spiffworkflow_backend/routes/process_api_blueprint.py b/src/spiffworkflow_backend/routes/process_api_blueprint.py index 64f4c22d..8132b10a 100644 --- a/src/spiffworkflow_backend/routes/process_api_blueprint.py +++ b/src/spiffworkflow_backend/routes/process_api_blueprint.py @@ -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) diff --git a/tests/data/hello_world/hello_world.bpmn b/tests/data/hello_world/hello_world.bpmn index 9d6b7071..3c80916e 100644 --- a/tests/data/hello_world/hello_world.bpmn +++ b/tests/data/hello_world/hello_world.bpmn @@ -1,5 +1,5 @@ - + This workflow asks for a name and says hello @@ -10,7 +10,7 @@ Hello - + SequenceFlow_0qyd2b7 @@ -26,33 +26,46 @@ SequenceFlow_0lqrc6e + + + - - - - - - + + + - - - + + + + + + + + + + - - - - + + + + + + + + + + diff --git a/tests/spiffworkflow_backend/integration/bpmn.json b/tests/spiffworkflow_backend/integration/bpmn.json index 4d15a34c..65ea9d21 100644 --- a/tests/spiffworkflow_backend/integration/bpmn.json +++ b/tests/spiffworkflow_backend/integration/bpmn.json @@ -1 +1,430 @@ -{"spec": {"name": "sample", "description": "sample", "file": "sample.bpmn", "task_specs": {"Start": {"id": "sample_1", "name": "Start", "description": "", "manual": false, "internal": false, "position": {"x": 0, "y": 0}, "lookahead": 2, "inputs": [], "outputs": ["StartEvent_1"], "typename": "StartTask"}, "sample.EndJoin": {"id": "sample_2", "name": "sample.EndJoin", "description": "", "manual": false, "internal": false, "position": {"x": 0, "y": 0}, "lookahead": 2, "inputs": ["Event_1qb1u6a"], "outputs": ["End"], "typename": "_EndJoin"}, "End": {"id": "sample_3", "name": "End", "description": "", "manual": false, "internal": false, "position": {"x": 0, "y": 0}, "lookahead": 2, "inputs": ["sample.EndJoin"], "outputs": [], "typename": "Simple"}, "StartEvent_1": {"id": "sample_4", "name": "StartEvent_1", "description": null, "manual": false, "internal": false, "position": {"x": 152.0, "y": 102.0}, "lookahead": 2, "inputs": ["Start"], "outputs": ["Activity_0pxf6g1"], "lane": null, "documentation": null, "loopTask": false, "outgoing_sequence_flows": {"Activity_0pxf6g1": {"id": "Flow_10jwwqy", "name": null, "documentation": null, "target_task_spec": "Activity_0pxf6g1", "typename": "SequenceFlow"}}, "outgoing_sequence_flows_by_id": {"Flow_10jwwqy": {"id": "Flow_10jwwqy", "name": null, "documentation": null, "target_task_spec": "Activity_0pxf6g1", "typename": "SequenceFlow"}}, "event_definition": {"internal": false, "external": false, "typename": "NoneEventDefinition"}, "typename": "StartEvent", "extensions": {}}, "Activity_0pxf6g1": {"id": "sample_5", "name": "Activity_0pxf6g1", "description": "My Script", "manual": false, "internal": false, "position": {"x": 240.0, "y": 80.0}, "lookahead": 2, "inputs": ["StartEvent_1"], "outputs": ["Activity_0a21ntf"], "lane": null, "documentation": null, "loopTask": false, "outgoing_sequence_flows": {"Activity_0a21ntf": {"id": "Flow_0htxke7", "name": null, "documentation": null, "target_task_spec": "Activity_0a21ntf", "typename": "SequenceFlow"}}, "outgoing_sequence_flows_by_id": {"Flow_0htxke7": {"id": "Flow_0htxke7", "name": null, "documentation": null, "target_task_spec": "Activity_0a21ntf", "typename": "SequenceFlow"}}, "script": "my_var = \"Hello World\"\nMike = \"Awesome\"\nperson = \"Kevin\"", "typename": "ScriptTask", "extensions": {}}, "Activity_0a21ntf": {"id": "sample_6", "name": "Activity_0a21ntf", "description": "is wonderful?", "manual": false, "internal": false, "position": {"x": 0, "y": 0}, "lookahead": 2, "inputs": ["Activity_0pxf6g1"], "outputs": ["Event_1qb1u6a"], "lane": null, "documentation": null, "loopTask": false, "outgoing_sequence_flows": {"Event_1qb1u6a": {"id": "Flow_1hd6o66", "name": null, "documentation": null, "target_task_spec": "Event_1qb1u6a", "typename": "SequenceFlow"}}, "outgoing_sequence_flows_by_id": {"Flow_1hd6o66": {"id": "Flow_1hd6o66", "name": null, "documentation": null, "target_task_spec": "Event_1qb1u6a", "typename": "SequenceFlow"}}, "decision_table": {"id": "DecisionTable_02m334z", "name": "", "inputs": [{"id": "Input_1", "label": "", "name": "", "expression": "person", "typeRef": "string"}], "outputs": [{"id": "Output_1", "label": "", "name": "wonderfulness", "typeRef": "string"}], "rules": [{"id": "DecisionRule_1hnzjl8", "description": "", "input_entries": [{"id": "UnaryTests_1pb0ou0", "input_id": "Input_1", "description": "", "lhs": ["\"Dan\""]}], "output_entries": [{"id": "LiteralExpression_0rtsxgu", "output_id": "Output_1", "description": "", "text": "\"pretty wonderful\""}]}, {"id": "DecisionRule_1cc73tk", "description": "", "input_entries": [{"id": "UnaryTests_1fbj1wn", "input_id": "Input_1", "description": "", "lhs": ["\"Kevin\""]}], "output_entries": [{"id": "LiteralExpression_1d9nsnp", "output_id": "Output_1", "description": "", "text": "\"Very wonderful\""}]}, {"id": "DecisionRule_09y32t9", "description": "", "input_entries": [{"id": "UnaryTests_05h3qcx", "input_id": "Input_1", "description": "", "lhs": ["\"Mike\""]}], "output_entries": [{"id": "LiteralExpression_15b83d9", "output_id": "Output_1", "description": "", "text": "\"Powerful wonderful\""}]}]}, "typename": "BusinessRuleTask", "extensions": {}}, "Event_1qb1u6a": {"id": "sample_7", "name": "Event_1qb1u6a", "description": null, "manual": false, "internal": false, "position": {"x": 802.0, "y": 92.0}, "lookahead": 2, "inputs": ["Activity_0a21ntf"], "outputs": ["sample.EndJoin"], "lane": null, "documentation": null, "loopTask": false, "outgoing_sequence_flows": {"sample.EndJoin": {"id": "Event_1qb1u6a.ToEndJoin", "name": null, "documentation": null, "target_task_spec": "sample.EndJoin", "typename": "SequenceFlow"}}, "outgoing_sequence_flows_by_id": {"Event_1qb1u6a.ToEndJoin": {"id": "Event_1qb1u6a.ToEndJoin", "name": null, "documentation": null, "target_task_spec": "sample.EndJoin", "typename": "SequenceFlow"}}, "event_definition": {"internal": false, "external": false, "typename": "NoneEventDefinition"}, "typename": "EndEvent", "extensions": {}}, "Root": {"id": "sample_8", "name": "Root", "description": "", "manual": false, "internal": false, "position": {"x": 0, "y": 0}, "lookahead": 2, "inputs": [], "outputs": [], "typename": "Simple"}}, "typename": "BpmnProcessSpec"}, "data": {"validate_only": false, "process_instance_id": 63, "current_user": {"username": "test_user1", "id": "1"}, "my_var": "Hello World", "Mike": "Awesome", "person": "Kevin", "wonderfulness": "Very wonderful"}, "last_task": "11314c29-ab0c-447d-82c0-48d824b017ec", "success": true, "tasks": {"4e227637-6ded-431a-ad6a-dd57d7b87b38": {"id": "4e227637-6ded-431a-ad6a-dd57d7b87b38", "parent": null, "children": ["69a8b231-43fd-4faa-8343-de37d7985824"], "last_state_change": 1654725001.792306, "state": 32, "task_spec": "Root", "triggered": false, "workflow_name": "sample", "internal_data": {}, "data": {}}, "69a8b231-43fd-4faa-8343-de37d7985824": {"id": "69a8b231-43fd-4faa-8343-de37d7985824", "parent": "4e227637-6ded-431a-ad6a-dd57d7b87b38", "children": ["348a4290-c626-4a3d-9bf0-c25f09c5e448"], "last_state_change": 1654725001.7997818, "state": 32, "task_spec": "Start", "triggered": false, "workflow_name": "sample", "internal_data": {}, "data": {"current_user": {"username": "test_user1", "id": "1"}}}, "348a4290-c626-4a3d-9bf0-c25f09c5e448": {"id": "348a4290-c626-4a3d-9bf0-c25f09c5e448", "parent": "69a8b231-43fd-4faa-8343-de37d7985824", "children": ["dc89284f-e574-4e6b-9c74-e79db384beba"], "last_state_change": 1654725001.8002229, "state": 32, "task_spec": "StartEvent_1", "triggered": false, "workflow_name": "sample", "internal_data": {"event_fired": true}, "data": {"current_user": {"username": "test_user1", "id": "1"}}}, "dc89284f-e574-4e6b-9c74-e79db384beba": {"id": "dc89284f-e574-4e6b-9c74-e79db384beba", "parent": "348a4290-c626-4a3d-9bf0-c25f09c5e448", "children": ["f014d940-4023-4676-8a22-8ab82501cb6a"], "last_state_change": 1654725001.800621, "state": 32, "task_spec": "Activity_0pxf6g1", "triggered": false, "workflow_name": "sample", "internal_data": {}, "data": {"current_user": {"username": "test_user1", "id": "1"}, "my_var": "Hello World", "Mike": "Awesome", "person": "Kevin"}}, "f014d940-4023-4676-8a22-8ab82501cb6a": {"id": "f014d940-4023-4676-8a22-8ab82501cb6a", "parent": "dc89284f-e574-4e6b-9c74-e79db384beba", "children": ["5c7368cf-6b56-4d40-a0b2-e6ccd1115cb1"], "last_state_change": 1654725001.801095, "state": 32, "task_spec": "Activity_0a21ntf", "triggered": false, "workflow_name": "sample", "internal_data": {}, "data": {"current_user": {"username": "test_user1", "id": "1"}, "my_var": "Hello World", "Mike": "Awesome", "person": "Kevin", "wonderfulness": "Very wonderful"}}, "5c7368cf-6b56-4d40-a0b2-e6ccd1115cb1": {"id": "5c7368cf-6b56-4d40-a0b2-e6ccd1115cb1", "parent": "f014d940-4023-4676-8a22-8ab82501cb6a", "children": ["6487a111-1427-4de4-aa0e-bdb3b1ccba01"], "last_state_change": 1654725001.8016891, "state": 32, "task_spec": "Event_1qb1u6a", "triggered": false, "workflow_name": "sample", "internal_data": {}, "data": {"current_user": {"username": "test_user1", "id": "1"}, "my_var": "Hello World", "Mike": "Awesome", "person": "Kevin", "wonderfulness": "Very wonderful"}}, "6487a111-1427-4de4-aa0e-bdb3b1ccba01": {"id": "6487a111-1427-4de4-aa0e-bdb3b1ccba01", "parent": "5c7368cf-6b56-4d40-a0b2-e6ccd1115cb1", "children": ["11314c29-ab0c-447d-82c0-48d824b017ec"], "last_state_change": 1654725001.8022258, "state": 32, "task_spec": "sample.EndJoin", "triggered": false, "workflow_name": "sample", "internal_data": {}, "data": {"current_user": {"username": "test_user1", "id": "1"}, "my_var": "Hello World", "Mike": "Awesome", "person": "Kevin", "wonderfulness": "Very wonderful"}}, "11314c29-ab0c-447d-82c0-48d824b017ec": {"id": "11314c29-ab0c-447d-82c0-48d824b017ec", "parent": "6487a111-1427-4de4-aa0e-bdb3b1ccba01", "children": [], "last_state_change": 1654725001.802538, "state": 32, "task_spec": "End", "triggered": false, "workflow_name": "sample", "internal_data": {}, "data": {"current_user": {"username": "test_user1", "id": "1"}, "my_var": "Hello World", "Mike": "Awesome", "person": "Kevin", "wonderfulness": "Very wonderful"}}}, "root": "4e227637-6ded-431a-ad6a-dd57d7b87b38", "subprocess_specs": {}, "subprocesses": {}, "serializer_version": "1.0-CRC"} \ No newline at end of file +{ + "spec": { + "name": "sample", + "description": "sample", + "file": "sample.bpmn", + "task_specs": { + "Start": { + "id": "sample_1", + "name": "Start", + "description": "", + "manual": false, + "internal": false, + "position": { "x": 0, "y": 0 }, + "lookahead": 2, + "inputs": [], + "outputs": ["StartEvent_1"], + "typename": "StartTask" + }, + "sample.EndJoin": { + "id": "sample_2", + "name": "sample.EndJoin", + "description": "", + "manual": false, + "internal": false, + "position": { "x": 0, "y": 0 }, + "lookahead": 2, + "inputs": ["Event_1qb1u6a"], + "outputs": ["End"], + "typename": "_EndJoin" + }, + "End": { + "id": "sample_3", + "name": "End", + "description": "", + "manual": false, + "internal": false, + "position": { "x": 0, "y": 0 }, + "lookahead": 2, + "inputs": ["sample.EndJoin"], + "outputs": [], + "typename": "Simple" + }, + "StartEvent_1": { + "id": "sample_4", + "name": "StartEvent_1", + "description": null, + "manual": false, + "internal": false, + "position": { "x": 152.0, "y": 102.0 }, + "lookahead": 2, + "inputs": ["Start"], + "outputs": ["Activity_0pxf6g1"], + "lane": null, + "documentation": null, + "loopTask": false, + "outgoing_sequence_flows": { + "Activity_0pxf6g1": { + "id": "Flow_10jwwqy", + "name": null, + "documentation": null, + "target_task_spec": "Activity_0pxf6g1", + "typename": "SequenceFlow" + } + }, + "outgoing_sequence_flows_by_id": { + "Flow_10jwwqy": { + "id": "Flow_10jwwqy", + "name": null, + "documentation": null, + "target_task_spec": "Activity_0pxf6g1", + "typename": "SequenceFlow" + } + }, + "event_definition": { + "internal": false, + "external": false, + "typename": "NoneEventDefinition" + }, + "typename": "StartEvent", + "extensions": {} + }, + "Activity_0pxf6g1": { + "id": "sample_5", + "name": "Activity_0pxf6g1", + "description": "My Script", + "manual": false, + "internal": false, + "position": { "x": 240.0, "y": 80.0 }, + "lookahead": 2, + "inputs": ["StartEvent_1"], + "outputs": ["Activity_0a21ntf"], + "lane": null, + "documentation": null, + "loopTask": false, + "outgoing_sequence_flows": { + "Activity_0a21ntf": { + "id": "Flow_0htxke7", + "name": null, + "documentation": null, + "target_task_spec": "Activity_0a21ntf", + "typename": "SequenceFlow" + } + }, + "outgoing_sequence_flows_by_id": { + "Flow_0htxke7": { + "id": "Flow_0htxke7", + "name": null, + "documentation": null, + "target_task_spec": "Activity_0a21ntf", + "typename": "SequenceFlow" + } + }, + "script": "my_var = \"Hello World\"\nMike = \"Awesome\"\nperson = \"Kevin\"", + "typename": "ScriptTask", + "extensions": {} + }, + "Activity_0a21ntf": { + "id": "sample_6", + "name": "Activity_0a21ntf", + "description": "is wonderful?", + "manual": false, + "internal": false, + "position": { "x": 0, "y": 0 }, + "lookahead": 2, + "inputs": ["Activity_0pxf6g1"], + "outputs": ["Event_1qb1u6a"], + "lane": null, + "documentation": null, + "loopTask": false, + "outgoing_sequence_flows": { + "Event_1qb1u6a": { + "id": "Flow_1hd6o66", + "name": null, + "documentation": null, + "target_task_spec": "Event_1qb1u6a", + "typename": "SequenceFlow" + } + }, + "outgoing_sequence_flows_by_id": { + "Flow_1hd6o66": { + "id": "Flow_1hd6o66", + "name": null, + "documentation": null, + "target_task_spec": "Event_1qb1u6a", + "typename": "SequenceFlow" + } + }, + "decision_table": { + "id": "DecisionTable_02m334z", + "name": "", + "inputs": [ + { + "id": "Input_1", + "label": "", + "name": "", + "expression": "person", + "typeRef": "string" + } + ], + "outputs": [ + { + "id": "Output_1", + "label": "", + "name": "wonderfulness", + "typeRef": "string" + } + ], + "rules": [ + { + "id": "DecisionRule_1hnzjl8", + "description": "", + "input_entries": [ + { + "id": "UnaryTests_1pb0ou0", + "input_id": "Input_1", + "description": "", + "lhs": ["\"Dan\""] + } + ], + "output_entries": [ + { + "id": "LiteralExpression_0rtsxgu", + "output_id": "Output_1", + "description": "", + "text": "\"pretty wonderful\"" + } + ] + }, + { + "id": "DecisionRule_1cc73tk", + "description": "", + "input_entries": [ + { + "id": "UnaryTests_1fbj1wn", + "input_id": "Input_1", + "description": "", + "lhs": ["\"Kevin\""] + } + ], + "output_entries": [ + { + "id": "LiteralExpression_1d9nsnp", + "output_id": "Output_1", + "description": "", + "text": "\"Very wonderful\"" + } + ] + }, + { + "id": "DecisionRule_09y32t9", + "description": "", + "input_entries": [ + { + "id": "UnaryTests_05h3qcx", + "input_id": "Input_1", + "description": "", + "lhs": ["\"Mike\""] + } + ], + "output_entries": [ + { + "id": "LiteralExpression_15b83d9", + "output_id": "Output_1", + "description": "", + "text": "\"Powerful wonderful\"" + } + ] + } + ] + }, + "typename": "BusinessRuleTask", + "extensions": {} + }, + "Event_1qb1u6a": { + "id": "sample_7", + "name": "Event_1qb1u6a", + "description": null, + "manual": false, + "internal": false, + "position": { "x": 802.0, "y": 92.0 }, + "lookahead": 2, + "inputs": ["Activity_0a21ntf"], + "outputs": ["sample.EndJoin"], + "lane": null, + "documentation": null, + "loopTask": false, + "outgoing_sequence_flows": { + "sample.EndJoin": { + "id": "Event_1qb1u6a.ToEndJoin", + "name": null, + "documentation": null, + "target_task_spec": "sample.EndJoin", + "typename": "SequenceFlow" + } + }, + "outgoing_sequence_flows_by_id": { + "Event_1qb1u6a.ToEndJoin": { + "id": "Event_1qb1u6a.ToEndJoin", + "name": null, + "documentation": null, + "target_task_spec": "sample.EndJoin", + "typename": "SequenceFlow" + } + }, + "event_definition": { + "internal": false, + "external": false, + "typename": "NoneEventDefinition" + }, + "typename": "EndEvent", + "extensions": {} + }, + "Root": { + "id": "sample_8", + "name": "Root", + "description": "", + "manual": false, + "internal": false, + "position": { "x": 0, "y": 0 }, + "lookahead": 2, + "inputs": [], + "outputs": [], + "typename": "Simple" + } + }, + "typename": "BpmnProcessSpec" + }, + "data": { + "validate_only": false, + "process_instance_id": 63, + "current_user": { "username": "test_user1", "id": "1" }, + "my_var": "Hello World", + "Mike": "Awesome", + "person": "Kevin", + "wonderfulness": "Very wonderful" + }, + "last_task": "11314c29-ab0c-447d-82c0-48d824b017ec", + "success": true, + "tasks": { + "4e227637-6ded-431a-ad6a-dd57d7b87b38": { + "id": "4e227637-6ded-431a-ad6a-dd57d7b87b38", + "parent": null, + "children": ["69a8b231-43fd-4faa-8343-de37d7985824"], + "last_state_change": 1654725001.792306, + "state": 32, + "task_spec": "Root", + "triggered": false, + "workflow_name": "sample", + "internal_data": {}, + "data": {} + }, + "69a8b231-43fd-4faa-8343-de37d7985824": { + "id": "69a8b231-43fd-4faa-8343-de37d7985824", + "parent": "4e227637-6ded-431a-ad6a-dd57d7b87b38", + "children": ["348a4290-c626-4a3d-9bf0-c25f09c5e448"], + "last_state_change": 1654725001.7997818, + "state": 32, + "task_spec": "Start", + "triggered": false, + "workflow_name": "sample", + "internal_data": {}, + "data": { "current_user": { "username": "test_user1", "id": "1" } } + }, + "348a4290-c626-4a3d-9bf0-c25f09c5e448": { + "id": "348a4290-c626-4a3d-9bf0-c25f09c5e448", + "parent": "69a8b231-43fd-4faa-8343-de37d7985824", + "children": ["dc89284f-e574-4e6b-9c74-e79db384beba"], + "last_state_change": 1654725001.8002229, + "state": 32, + "task_spec": "StartEvent_1", + "triggered": false, + "workflow_name": "sample", + "internal_data": { "event_fired": true }, + "data": { "current_user": { "username": "test_user1", "id": "1" } } + }, + "dc89284f-e574-4e6b-9c74-e79db384beba": { + "id": "dc89284f-e574-4e6b-9c74-e79db384beba", + "parent": "348a4290-c626-4a3d-9bf0-c25f09c5e448", + "children": ["f014d940-4023-4676-8a22-8ab82501cb6a"], + "last_state_change": 1654725001.800621, + "state": 32, + "task_spec": "Activity_0pxf6g1", + "triggered": false, + "workflow_name": "sample", + "internal_data": {}, + "data": { + "current_user": { "username": "test_user1", "id": "1" }, + "my_var": "Hello World", + "Mike": "Awesome", + "person": "Kevin" + } + }, + "f014d940-4023-4676-8a22-8ab82501cb6a": { + "id": "f014d940-4023-4676-8a22-8ab82501cb6a", + "parent": "dc89284f-e574-4e6b-9c74-e79db384beba", + "children": ["5c7368cf-6b56-4d40-a0b2-e6ccd1115cb1"], + "last_state_change": 1654725001.801095, + "state": 32, + "task_spec": "Activity_0a21ntf", + "triggered": false, + "workflow_name": "sample", + "internal_data": {}, + "data": { + "current_user": { "username": "test_user1", "id": "1" }, + "my_var": "Hello World", + "Mike": "Awesome", + "person": "Kevin", + "wonderfulness": "Very wonderful" + } + }, + "5c7368cf-6b56-4d40-a0b2-e6ccd1115cb1": { + "id": "5c7368cf-6b56-4d40-a0b2-e6ccd1115cb1", + "parent": "f014d940-4023-4676-8a22-8ab82501cb6a", + "children": ["6487a111-1427-4de4-aa0e-bdb3b1ccba01"], + "last_state_change": 1654725001.8016891, + "state": 32, + "task_spec": "Event_1qb1u6a", + "triggered": false, + "workflow_name": "sample", + "internal_data": {}, + "data": { + "current_user": { "username": "test_user1", "id": "1" }, + "my_var": "Hello World", + "Mike": "Awesome", + "person": "Kevin", + "wonderfulness": "Very wonderful" + } + }, + "6487a111-1427-4de4-aa0e-bdb3b1ccba01": { + "id": "6487a111-1427-4de4-aa0e-bdb3b1ccba01", + "parent": "5c7368cf-6b56-4d40-a0b2-e6ccd1115cb1", + "children": ["11314c29-ab0c-447d-82c0-48d824b017ec"], + "last_state_change": 1654725001.8022258, + "state": 32, + "task_spec": "sample.EndJoin", + "triggered": false, + "workflow_name": "sample", + "internal_data": {}, + "data": { + "current_user": { "username": "test_user1", "id": "1" }, + "my_var": "Hello World", + "Mike": "Awesome", + "person": "Kevin", + "wonderfulness": "Very wonderful" + } + }, + "11314c29-ab0c-447d-82c0-48d824b017ec": { + "id": "11314c29-ab0c-447d-82c0-48d824b017ec", + "parent": "6487a111-1427-4de4-aa0e-bdb3b1ccba01", + "children": [], + "last_state_change": 1654725001.802538, + "state": 32, + "task_spec": "End", + "triggered": false, + "workflow_name": "sample", + "internal_data": {}, + "data": { + "current_user": { "username": "test_user1", "id": "1" }, + "my_var": "Hello World", + "Mike": "Awesome", + "person": "Kevin", + "wonderfulness": "Very wonderful" + } + } + }, + "root": "4e227637-6ded-431a-ad6a-dd57d7b87b38", + "subprocess_specs": {}, + "subprocesses": {}, + "serializer_version": "1.0-CRC" +} diff --git a/tests/spiffworkflow_backend/integration/test_process_api.py b/tests/spiffworkflow_backend/integration/test_process_api.py index 491f0f06..a1d90eb3 100644 --- a/tests/spiffworkflow_backend/integration/test_process_api.py +++ b/tests/spiffworkflow_backend/integration/test_process_api.py @@ -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