From 6bfce59fe35d443404ddee988fc07bc48bd2f8b4 Mon Sep 17 00:00:00 2001 From: burnettk Date: Thu, 16 Mar 2023 22:59:42 -0400 Subject: [PATCH] lint --- .../routes/process_instances_controller.py | 14 ++++++++------ .../integration/test_logging_service.py | 14 +++++++------- .../unit/test_process_instance_processor.py | 11 ++++++----- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_instances_controller.py b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_instances_controller.py index 9be858856..86764e45e 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_instances_controller.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_instances_controller.py @@ -1,7 +1,5 @@ """APIs for dealing with process groups, process models, and process instances.""" import base64 -from spiffworkflow_backend.models.bpmn_process_definition import BpmnProcessDefinitionModel -from spiffworkflow_backend.models.task_definition import TaskDefinitionModel import json from typing import Any from typing import Dict @@ -21,6 +19,7 @@ from sqlalchemy import and_ from sqlalchemy import or_ from spiffworkflow_backend.exceptions.api_error import ApiError +from spiffworkflow_backend.models.bpmn_process_definition import BpmnProcessDefinitionModel from spiffworkflow_backend.models.db import db from spiffworkflow_backend.models.human_task import HumanTaskModel from spiffworkflow_backend.models.human_task_user import HumanTaskUserModel @@ -46,6 +45,7 @@ from spiffworkflow_backend.models.spiff_logging import SpiffLoggingModel from spiffworkflow_backend.models.spiff_step_details import SpiffStepDetailsModel from spiffworkflow_backend.models.task import Task from spiffworkflow_backend.models.task import TaskModel +from spiffworkflow_backend.models.task_definition import TaskDefinitionModel from spiffworkflow_backend.models.user import UserModel from spiffworkflow_backend.routes.process_api_blueprint import ( _find_process_instance_by_id_or_raise, @@ -239,14 +239,16 @@ def process_instance_log_list( logs = ( log_query.order_by(TaskModel.end_in_seconds.desc()) # type: ignore .join(TaskDefinitionModel, TaskDefinitionModel.id == TaskModel.task_definition_id) - .join(BpmnProcessDefinitionModel, BpmnProcessDefinitionModel.id == TaskDefinitionModel.bpmn_process_definition_id) + .join( + BpmnProcessDefinitionModel, BpmnProcessDefinitionModel.id == TaskDefinitionModel.bpmn_process_definition_id + ) .outerjoin(HumanTaskModel, HumanTaskModel.task_model_id == TaskModel.id) .outerjoin(UserModel, UserModel.id == HumanTaskModel.completed_by_user_id) .add_columns( - TaskModel.guid.label('spiff_task_guid'), + TaskModel.guid.label("spiff_task_guid"), # type: ignore UserModel.username, - BpmnProcessDefinitionModel.bpmn_identifier.label('bpmn_process_definition_identifier'), - TaskDefinitionModel.bpmn_identifier.label('task_definition_identifier'), + BpmnProcessDefinitionModel.bpmn_identifier.label("bpmn_process_definition_identifier"), # type: ignore + TaskDefinitionModel.bpmn_identifier.label("task_definition_identifier"), # type: ignore ) .paginate(page=page, per_page=per_page, error_out=False) ) diff --git a/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_logging_service.py b/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_logging_service.py index c15b5eeb4..df13ceb66 100644 --- a/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_logging_service.py +++ b/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_logging_service.py @@ -1,17 +1,17 @@ """Test_logging_service.""" from flask.app import Flask -from tests.spiffworkflow_backend.helpers.test_data import load_test_spec -from spiffworkflow_backend.services.authorization_service import AuthorizationService from flask.testing import FlaskClient from tests.spiffworkflow_backend.helpers.base_test import BaseTest +from tests.spiffworkflow_backend.helpers.test_data import load_test_spec from spiffworkflow_backend.models.user import UserModel -from spiffworkflow_backend.services.process_instance_service import ( - ProcessInstanceService, -) +from spiffworkflow_backend.services.authorization_service import AuthorizationService from spiffworkflow_backend.services.process_instance_processor import ( ProcessInstanceProcessor, ) +from spiffworkflow_backend.services.process_instance_service import ( + ProcessInstanceService, +) class TestLoggingService(BaseTest): @@ -71,5 +71,5 @@ class TestLoggingService(BaseTest): ]: assert key in log.keys() - if log['task_definition_identifier'] == 'Activity_SimpleForm': - assert log['username'] == initiator_user.username + if log["task_definition_identifier"] == "Activity_SimpleForm": + assert log["username"] == initiator_user.username diff --git a/spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_process_instance_processor.py b/spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_process_instance_processor.py index ce5355e5c..a1cdec22a 100644 --- a/spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_process_instance_processor.py +++ b/spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_process_instance_processor.py @@ -1,7 +1,5 @@ """Test_process_instance_processor.""" from uuid import UUID -from spiffworkflow_backend.models import bpmn_process_definition -from spiffworkflow_backend.models.bpmn_process import BpmnProcessModel import pytest from flask import g @@ -12,6 +10,7 @@ from tests.spiffworkflow_backend.helpers.base_test import BaseTest from tests.spiffworkflow_backend.helpers.test_data import load_test_spec from spiffworkflow_backend.exceptions.api_error import ApiError +from spiffworkflow_backend.models.bpmn_process import BpmnProcessModel from spiffworkflow_backend.models.group import GroupModel from spiffworkflow_backend.models.process_instance import ProcessInstanceModel from spiffworkflow_backend.models.process_instance import ProcessInstanceStatus @@ -351,7 +350,9 @@ class TestProcessInstanceProcessor(BaseTest): task_definition = task_model.task_definition assert task_definition.bpmn_identifier == spiff_task_name assert task_definition.bpmn_process_definition.bpmn_identifier == bpmn_process_identifier - message = f"{base_failure_message} Expected: {expected_python_env_data}. Received: {task_model.json_data()}" + message = ( + f"{base_failure_message} Expected: {expected_python_env_data}. Received: {task_model.json_data()}" + ) # TODO: if we split out env data again we will need to use it here instead of json_data # assert task_model.python_env_data() == expected_python_env_data, message assert task_model.json_data() == expected_python_env_data, message @@ -365,13 +366,13 @@ class TestProcessInstanceProcessor(BaseTest): assert_spiff_task_is_in_process("top_level_subprocess_script", "top_level_subprocess") assert_spiff_task_is_in_process("top_level_script", "top_level_process") - if spiff_task.task_spec.name == 'top_level_call_activity': + if spiff_task.task_spec.name == "top_level_call_activity": # the task id / guid of the call activity gets used as the guid of the bpmn process that it calls bpmn_process = BpmnProcessModel.query.filter_by(guid=str(spiff_task.id)).first() assert bpmn_process is not None bpmn_process_definition = bpmn_process.bpmn_process_definition assert bpmn_process_definition is not None - assert bpmn_process_definition.bpmn_identifier == 'test_process_to_call' + assert bpmn_process_definition.bpmn_identifier == "test_process_to_call" assert processor.get_data() == fifth_data_set