From c24cc56fb00e07f6cfe16840c65471443b120daf Mon Sep 17 00:00:00 2001 From: burnettk Date: Thu, 27 Oct 2022 22:03:49 -0400 Subject: [PATCH] Squashed 'spiffworkflow-backend/' changes from 0de4c06d0..4d7e5e531 4d7e5e531 we will set these at runtime 39c9e8785 templated SPIFF_SUBDOMAIN for keycloak 1a51f9091 update flask-bpmn 354e6edb1 Merge pull request #8 from sartography/feature/clean_up_sentry_errors 0c11a0b75 pyl passes w/ burnettk 9c57a876e avoid sending two errors to sentry w/ burnettk git-subtree-dir: spiffworkflow-backend git-subtree-split: 4d7e5e53185431b113eb7c038b687134499422c8 --- bin/import_tickets_for_command_line.py | 1 - bin/recreate_db | 14 ++++++++ bin/run_server_locally | 11 +++++- bin/spiffworkflow-realm.json | 3 ++ bin/start_blocking_appscheduler.py | 1 - bin/start_keycloak | 7 ++-- conftest.py | 17 ++------- keycloak/Dockerfile | 2 +- poetry.lock | 2 +- pyproject.toml | 6 +--- src/spiffworkflow_backend/__init__.py | 6 ++-- src/spiffworkflow_backend/config/__init__.py | 8 ++++- src/spiffworkflow_backend/config/default.py | 2 +- .../config/permissions/development.yml | 2 +- src/spiffworkflow_backend/config/testing.py | 12 ++++++- .../models/active_task.py | 7 ++-- .../models/active_task_user.py | 3 +- src/spiffworkflow_backend/models/file.py | 5 ++- .../models/message_correlation.py | 5 ++- .../message_correlation_message_instance.py | 3 +- .../models/message_correlation_property.py | 3 +- .../models/message_instance.py | 5 ++- .../message_triggerable_process_model.py | 3 +- .../models/permission_assignment.py | 5 ++- src/spiffworkflow_backend/models/principal.py | 5 ++- .../models/process_group.py | 1 - .../models/process_instance.py | 9 +++-- .../models/process_instance_report.py | 7 ++-- .../models/process_model.py | 1 - .../models/secret_model.py | 3 +- .../models/spiff_logging.py | 3 +- src/spiffworkflow_backend/models/user.py | 5 ++- .../models/user_group_assignment.py | 5 ++- .../routes/admin_blueprint/admin_blueprint.py | 3 +- .../routes/process_api_blueprint.py | 5 ++- src/spiffworkflow_backend/routes/user.py | 3 +- .../routes/user_blueprint.py | 3 +- .../scripts/fact_service.py | 1 - src/spiffworkflow_backend/scripts/get_env.py | 1 - .../scripts/get_localtime.py | 1 - src/spiffworkflow_backend/scripts/get_user.py | 1 - .../services/acceptance_test_fixtures.py | 3 +- .../services/authentication_service.py | 3 +- .../services/authorization_service.py | 30 ++++------------ .../services/background_processing_service.py | 1 - .../services/data_setup_service.py | 1 - .../services/email_service.py | 35 ++++++++----------- .../services/error_handling_service.py | 1 - .../services/file_system_service.py | 1 - .../services/git_service.py | 1 - .../services/group_service.py | 23 ++++++++++++ .../services/logging_service.py | 1 - .../services/message_service.py | 7 ++-- .../services/process_instance_processor.py | 1 - .../services/process_instance_service.py | 5 +-- .../services/process_model_service.py | 1 - .../services/script_unit_test_runner.py | 1 - .../services/secret_service.py | 1 - .../services/service_task_service.py | 1 - .../services/spec_file_service.py | 1 - .../services/user_service.py | 1 - .../helpers/base_test.py | 5 ++- .../helpers/example_data.py | 1 - .../helpers/test_data.py | 3 +- .../integration/test_authentication.py | 3 +- .../integration/test_logging_service.py | 3 +- .../integration/test_process_api.py | 5 ++- .../integration/test_secret_service.py | 5 ++- .../scripts/test_get_localtime.py | 5 ++- .../unit/test_acceptance_test_fixtures.py | 1 - .../unit/test_authorization_service.py | 5 ++- .../unit/test_dot_notation.py | 5 ++- .../unit/test_environment_var_script.py | 3 +- .../unit/test_message_instance.py | 5 ++- .../unit/test_message_service.py | 5 ++- .../unit/test_permission_target.py | 3 +- .../unit/test_permissions.py | 5 ++- .../unit/test_process_group.py | 1 - .../unit/test_process_instance_processor.py | 5 ++- .../unit/test_process_instance_report.py | 3 +- .../unit/test_process_model.py | 5 ++- .../unit/test_process_model_service.py | 3 +- .../unit/test_restricted_script_engine.py | 5 ++- .../unit/test_script_unit_test_runner.py | 5 ++- .../unit/test_service_task_delegate.py | 3 +- .../unit/test_spec_file_service.py | 3 +- .../unit/test_spiff_logging.py | 3 +- .../unit/test_various_bpmn_constructs.py | 5 ++- tests/test_main.py | 1 - 89 files changed, 182 insertions(+), 231 deletions(-) create mode 100644 src/spiffworkflow_backend/services/group_service.py diff --git a/bin/import_tickets_for_command_line.py b/bin/import_tickets_for_command_line.py index 8b145dc4..5818d438 100644 --- a/bin/import_tickets_for_command_line.py +++ b/bin/import_tickets_for_command_line.py @@ -2,7 +2,6 @@ import csv from flask_bpmn.models.db import db - from spiffworkflow_backend import get_hacked_up_app_for_script from spiffworkflow_backend.models.process_instance import ProcessInstanceModel from spiffworkflow_backend.models.user import UserModel diff --git a/bin/recreate_db b/bin/recreate_db index 57ec07aa..5eb248fe 100755 --- a/bin/recreate_db +++ b/bin/recreate_db @@ -9,6 +9,20 @@ set -o errtrace -o errexit -o nounset -o pipefail export FLASK_SESSION_SECRET_KEY="this_is_recreate_db_secret_key" +if [[ -z "${BPMN_SPEC_ABSOLUTE_DIR:-}" ]]; then + script_dir="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" + + BPMN_SPEC_ABSOLUTE_DIR="${script_dir}/../../../sample-process-models" + if [[ ! -d "$BPMN_SPEC_ABSOLUTE_DIR" ]]; then + BPMN_SPEC_ABSOLUTE_DIR="${script_dir}/../../sample-process-models" + if [[ ! -d "$BPMN_SPEC_ABSOLUTE_DIR" ]]; then + >&2 echo "ERROR: Could not find a location for the sample processes. Last tried: $BPMN_SPEC_ABSOLUTE_DIR" + exit 1 + fi + fi + export BPMN_SPEC_ABSOLUTE_DIR +fi + tasks="" if [[ "${1:-}" == "clean" ]]; then subcommand="${2:-}" diff --git a/bin/run_server_locally b/bin/run_server_locally index f06acc9a..89801b45 100755 --- a/bin/run_server_locally +++ b/bin/run_server_locally @@ -19,7 +19,16 @@ fi if [[ -z "${BPMN_SPEC_ABSOLUTE_DIR:-}" ]]; then script_dir="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" - export BPMN_SPEC_ABSOLUTE_DIR="$script_dir/../../sample-process-models" + + BPMN_SPEC_ABSOLUTE_DIR="${script_dir}/../../../sample-process-models" + if [[ ! -d "$BPMN_SPEC_ABSOLUTE_DIR" ]]; then + BPMN_SPEC_ABSOLUTE_DIR="${script_dir}/../../sample-process-models" + if [[ ! -d "$BPMN_SPEC_ABSOLUTE_DIR" ]]; then + >&2 echo "ERROR: Could not find a location for the sample processes. Last tried: $BPMN_SPEC_ABSOLUTE_DIR" + exit 1 + fi + fi + export BPMN_SPEC_ABSOLUTE_DIR fi export FLASK_SESSION_SECRET_KEY=super_secret_key diff --git a/bin/spiffworkflow-realm.json b/bin/spiffworkflow-realm.json index 93a99d71..4b37f289 100644 --- a/bin/spiffworkflow-realm.json +++ b/bin/spiffworkflow-realm.json @@ -1280,6 +1280,7 @@ "http://localhost:7000/*", "http://67.205.133.116:7000/*", "http://167.172.242.138:7000/*", + "https://api.{{SPIFF_SUBDOMAIN}}.spiffworkflow.org/*", "https://api.demo.spiffworkflow.org/*" ], "webOrigins": [], @@ -1552,6 +1553,7 @@ "http://localhost:7001/*", "http://67.205.133.116:7000/*", "http://167.172.242.138:7001/*", + "https://api.{{SPIFF_SUBDOMAIN}}.spiffworkflow.org/*", "https://api.demo.spiffworkflow.org/*" ], "webOrigins": ["*"], @@ -1623,6 +1625,7 @@ "http://localhost:7001/*", "http://67.205.133.116:7000/*", "http://167.172.242.138:7001/*", + "https://api.{{SPIFF_SUBDOMAIN}}.spiffworkflow.org/*", "https://api.demo.spiffworkflow.org/*" ], "webOrigins": [], diff --git a/bin/start_blocking_appscheduler.py b/bin/start_blocking_appscheduler.py index 4af99e41..61b753f2 100755 --- a/bin/start_blocking_appscheduler.py +++ b/bin/start_blocking_appscheduler.py @@ -2,7 +2,6 @@ import time from apscheduler.schedulers.background import BlockingScheduler # type: ignore - from spiffworkflow_backend import create_app from spiffworkflow_backend import start_scheduler from spiffworkflow_backend.helpers.db_helper import try_to_connect diff --git a/bin/start_keycloak b/bin/start_keycloak index 169c9397..6b605e5f 100755 --- a/bin/start_keycloak +++ b/bin/start_keycloak @@ -18,7 +18,7 @@ set -o errtrace -o errexit -o nounset -o pipefail if ! docker network inspect spiffworkflow > /dev/null 2>&1; then docker network create spiffworkflow fi -docker rm keycloak 2>/dev/null || echo 'no keycloak container found' +docker rm keycloak 2>/dev/null || echo 'no keycloak container found, safe to start new container' docker run \ -p 7002:8080 \ -d \ @@ -31,7 +31,10 @@ docker run \ -Dkeycloak.profile.feature.token_exchange=enabled \ -Dkeycloak.profile.feature.admin_fine_grained_authz=enabled -docker cp bin/spiffworkflow-realm.json keycloak:/tmp +cp bin/spiffworkflow-realm.json /tmp/spiffworkflow-realm.json +spiff_subdomain="unused-for-local-dev" +perl -pi -e "s/{{SPIFF_SUBDOMAIN}}/${spiff_subdomain}/g" /tmp/spiffworkflow-realm.json +docker cp /tmp/spiffworkflow-realm.json keycloak:/tmp sleep 20 remove_traps diff --git a/conftest.py b/conftest.py index 17daaaa0..79bec5e1 100644 --- a/conftest.py +++ b/conftest.py @@ -6,9 +6,6 @@ import pytest from flask.app import Flask from flask_bpmn.models.db import db from flask_bpmn.models.db import SpiffworkflowBaseDBModel -from tests.spiffworkflow_backend.helpers.base_test import BaseTest -from tests.spiffworkflow_backend.helpers.test_data import load_test_spec - from spiffworkflow_backend.models.active_task_user import ActiveTaskUserModel from spiffworkflow_backend.models.process_instance import ProcessInstanceModel from spiffworkflow_backend.models.user import UserModel @@ -19,6 +16,8 @@ from spiffworkflow_backend.services.process_instance_service import ( ProcessInstanceService, ) from spiffworkflow_backend.services.process_model_service import ProcessModelService +from tests.spiffworkflow_backend.helpers.base_test import BaseTest +from tests.spiffworkflow_backend.helpers.test_data import load_test_spec # We need to call this before importing spiffworkflow_backend @@ -36,21 +35,9 @@ from spiffworkflow_backend import create_app # noqa: E402 def app() -> Flask: """App.""" os.environ["SPIFFWORKFLOW_BACKEND_ENV"] = "testing" - - # os.environ["FLASK_SESSION_SECRET_KEY"] = "this_is_testing_secret_key" os.environ["FLASK_SESSION_SECRET_KEY"] = "super_secret_key" app = create_app() - # NOTE: set this here since nox shoves tests and src code to - # different places and this allows us to know exactly where we are at the start - app.config["BPMN_SPEC_ABSOLUTE_DIR"] = os.path.join( - os.path.dirname(__file__), - "tests", - "spiffworkflow_backend", - "files", - "bpmn_specs", - ) - return app diff --git a/keycloak/Dockerfile b/keycloak/Dockerfile index 7484cd03..14c47206 100644 --- a/keycloak/Dockerfile +++ b/keycloak/Dockerfile @@ -6,7 +6,7 @@ ENV KC_HEALTH_ENABLED="true" # ENV KC_METRICS_ENABLED=true ENV PROXY_ADDRESS_FORWARDING="true" # ENV KC_HOSTNAME="keycloak.demo.spiffworkflow.org" -ENV KC_HOSTNAME_URL="https://keycloak.demo.spiffworkflow.org" +# ENV KC_HOSTNAME_URL="https://keycloak.demo.spiffworkflow.org" ENV KC_FEATURES="token-exchange,admin-fine-grained-authz" # ENV KC_DB=postgres # Install custom providers diff --git a/poetry.lock b/poetry.lock index b6f15f95..4566e5a5 100644 --- a/poetry.lock +++ b/poetry.lock @@ -639,7 +639,7 @@ werkzeug = "*" type = "git" url = "https://github.com/sartography/flask-bpmn" reference = "main" -resolved_reference = "a901d7ffb2b79abfec17c332bbe77c43c1d28705" +resolved_reference = "cedc5253add81a18a274f2cd3289fe36bb138f8b" [[package]] name = "Flask-Cors" diff --git a/pyproject.toml b/pyproject.toml index 1281c702..a4741447 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,15 +27,11 @@ flask-marshmallow = "*" flask-migrate = "*" flask-restful = "*" werkzeug = "*" -# go back to main once https://github.com/sartography/SpiffWorkflow/pull/241 is merged SpiffWorkflow = {git = "https://github.com/sartography/SpiffWorkflow", rev = "main"} -# SpiffWorkflow = {develop = true, path = "/Users/kevin/projects/github/sartography/SpiffWorkflow"} -# SpiffWorkflow = {develop = true, path = "/home/jason/projects/github/sartography/SpiffWorkflow"} sentry-sdk = "^1.10" sphinx-autoapi = "^2.0" -# flask-bpmn = {develop = true, path = "/home/jason/projects/github/sartography/flask-bpmn"} -# flask-bpmn = {develop = true, path = "/Users/kevin/projects/github/sartography/flask-bpmn"} flask-bpmn = {git = "https://github.com/sartography/flask-bpmn", rev = "main"} +# flask-bpmn = {develop = true, path = "../flask-bpmn"} mysql-connector-python = "^8.0.29" pytest-flask = "^1.2.0" pytest-flask-sqlalchemy = "^1.1.0" diff --git a/src/spiffworkflow_backend/__init__.py b/src/spiffworkflow_backend/__init__.py index 548cdb34..9f1a74e7 100644 --- a/src/spiffworkflow_backend/__init__.py +++ b/src/spiffworkflow_backend/__init__.py @@ -5,6 +5,7 @@ from typing import Any import connexion # type: ignore import flask.app import flask.json +import spiffworkflow_backend.load_database_models # noqa: F401 import sqlalchemy from apscheduler.schedulers.background import BackgroundScheduler # type: ignore from apscheduler.schedulers.base import BaseScheduler # type: ignore @@ -14,9 +15,6 @@ from flask_bpmn.models.db import db from flask_bpmn.models.db import migrate from flask_cors import CORS # type: ignore from flask_mail import Mail # type: ignore -from werkzeug.exceptions import NotFound - -import spiffworkflow_backend.load_database_models # noqa: F401 from spiffworkflow_backend.config import setup_config from spiffworkflow_backend.routes.admin_blueprint.admin_blueprint import admin_blueprint from spiffworkflow_backend.routes.process_api_blueprint import process_api_blueprint @@ -26,6 +24,7 @@ from spiffworkflow_backend.services.authorization_service import AuthorizationSe from spiffworkflow_backend.services.background_processing_service import ( BackgroundProcessingService, ) +from werkzeug.exceptions import NotFound class MyJSONEncoder(DefaultJSONProvider): @@ -148,6 +147,7 @@ def configure_sentry(app: flask.app.Flask) -> None: import sentry_sdk from sentry_sdk.integrations.flask import FlaskIntegration + # get rid of NotFound errors def before_send(event: Any, hint: Any) -> Any: """Before_send.""" if "exc_info" in hint: diff --git a/src/spiffworkflow_backend/config/__init__.py b/src/spiffworkflow_backend/config/__init__.py index c74ea406..08219579 100644 --- a/src/spiffworkflow_backend/config/__init__.py +++ b/src/spiffworkflow_backend/config/__init__.py @@ -3,9 +3,12 @@ import os import threading from flask.app import Flask +from spiffworkflow_backend.services.logging_service import setup_logger from werkzeug.utils import ImportStringError -from spiffworkflow_backend.services.logging_service import setup_logger + +class ConfigurationError(Exception): + """ConfigurationError.""" def setup_database_uri(app: Flask) -> None: @@ -85,5 +88,8 @@ def setup_config(app: Flask) -> None: # src/spiffworkflow_backend/config/secrets.py app.config.from_pyfile(os.path.join("config", "secrets.py"), silent=True) + if app.config["BPMN_SPEC_ABSOLUTE_DIR"] is None: + raise ConfigurationError("BPMN_SPEC_ABSOLUTE_DIR config must be set") + thread_local_data = threading.local() app.config["THREAD_LOCAL_DATA"] = thread_local_data diff --git a/src/spiffworkflow_backend/config/default.py b/src/spiffworkflow_backend/config/default.py index 956ed39f..53d670c7 100644 --- a/src/spiffworkflow_backend/config/default.py +++ b/src/spiffworkflow_backend/config/default.py @@ -7,7 +7,7 @@ SELF_REGISTRATION = environ.get("SELF_REGISTRATION", default=False) DEVELOPMENT = False -BPMN_SPEC_ABSOLUTE_DIR = environ.get("BPMN_SPEC_ABSOLUTE_DIR", default="") +BPMN_SPEC_ABSOLUTE_DIR = environ.get("BPMN_SPEC_ABSOLUTE_DIR") CORS_DEFAULT = "*" CORS_ALLOW_ORIGINS = re.split( r",\s*", environ.get("CORS_ALLOW_ORIGINS", default=CORS_DEFAULT) diff --git a/src/spiffworkflow_backend/config/permissions/development.yml b/src/spiffworkflow_backend/config/permissions/development.yml index 6869667b..957a654c 100644 --- a/src/spiffworkflow_backend/config/permissions/development.yml +++ b/src/spiffworkflow_backend/config/permissions/development.yml @@ -65,7 +65,7 @@ permissions: uri: /v1.0/process-models/finance/* read-all: - groups: [finance, admin, "Project Lead"] + groups: [admin, "Project Lead"] users: [] allowed_permissions: [read] uri: /* diff --git a/src/spiffworkflow_backend/config/testing.py b/src/spiffworkflow_backend/config/testing.py index 30776eae..ce422587 100644 --- a/src/spiffworkflow_backend/config/testing.py +++ b/src/spiffworkflow_backend/config/testing.py @@ -1,7 +1,7 @@ """Testing.py.""" +import os from os import environ - TESTING = True SECRET_KEY = "the_secret_key" SPIFFWORKFLOW_BACKEND_LOG_TO_FILE = ( @@ -15,3 +15,13 @@ SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME = environ.get( SPIFFWORKFLOW_BACKEND_LOG_LEVEL = environ.get( "SPIFFWORKFLOW_BACKEND_LOG_LEVEL", default="debug" ) + +# NOTE: set this here since nox shoves tests and src code to +# different places and this allows us to know exactly where we are at the start +BPMN_SPEC_ABSOLUTE_DIR = os.path.join( + os.path.dirname(__file__), + "tests", + "spiffworkflow_backend", + "files", + "bpmn_specs", +) diff --git a/src/spiffworkflow_backend/models/active_task.py b/src/spiffworkflow_backend/models/active_task.py index ea9e1055..50bd8c75 100644 --- a/src/spiffworkflow_backend/models/active_task.py +++ b/src/spiffworkflow_backend/models/active_task.py @@ -6,14 +6,13 @@ from typing import TYPE_CHECKING from flask_bpmn.models.db import db from flask_bpmn.models.db import SpiffworkflowBaseDBModel -from sqlalchemy import ForeignKey -from sqlalchemy.orm import relationship -from sqlalchemy.orm import RelationshipProperty - from spiffworkflow_backend.models.group import GroupModel from spiffworkflow_backend.models.process_instance import ProcessInstanceModel from spiffworkflow_backend.models.task import Task from spiffworkflow_backend.models.user import UserModel +from sqlalchemy import ForeignKey +from sqlalchemy.orm import relationship +from sqlalchemy.orm import RelationshipProperty if TYPE_CHECKING: diff --git a/src/spiffworkflow_backend/models/active_task_user.py b/src/spiffworkflow_backend/models/active_task_user.py index f194c38e..002759b1 100644 --- a/src/spiffworkflow_backend/models/active_task_user.py +++ b/src/spiffworkflow_backend/models/active_task_user.py @@ -5,10 +5,9 @@ from dataclasses import dataclass from flask_bpmn.models.db import db from flask_bpmn.models.db import SpiffworkflowBaseDBModel -from sqlalchemy import ForeignKey - from spiffworkflow_backend.models.active_task import ActiveTaskModel from spiffworkflow_backend.models.user import UserModel +from sqlalchemy import ForeignKey @dataclass diff --git a/src/spiffworkflow_backend/models/file.py b/src/spiffworkflow_backend/models/file.py index eb49b873..7a6a0fc3 100644 --- a/src/spiffworkflow_backend/models/file.py +++ b/src/spiffworkflow_backend/models/file.py @@ -8,11 +8,10 @@ from flask_bpmn.models.db import db from flask_bpmn.models.db import SpiffworkflowBaseDBModel from marshmallow import INCLUDE from marshmallow import Schema -from sqlalchemy.orm import deferred -from sqlalchemy.orm import relationship - from spiffworkflow_backend.helpers.spiff_enum import SpiffEnum from spiffworkflow_backend.models.data_store import DataStoreModel +from sqlalchemy.orm import deferred +from sqlalchemy.orm import relationship class FileModel(SpiffworkflowBaseDBModel): diff --git a/src/spiffworkflow_backend/models/message_correlation.py b/src/spiffworkflow_backend/models/message_correlation.py index baec8270..c3338f0b 100644 --- a/src/spiffworkflow_backend/models/message_correlation.py +++ b/src/spiffworkflow_backend/models/message_correlation.py @@ -4,13 +4,12 @@ from typing import TYPE_CHECKING from flask_bpmn.models.db import db from flask_bpmn.models.db import SpiffworkflowBaseDBModel -from sqlalchemy import ForeignKey -from sqlalchemy.orm import relationship - from spiffworkflow_backend.models.message_correlation_property import ( MessageCorrelationPropertyModel, ) from spiffworkflow_backend.models.process_instance import ProcessInstanceModel +from sqlalchemy import ForeignKey +from sqlalchemy.orm import relationship if TYPE_CHECKING: from spiffworkflow_backend.models.message_correlation_message_instance import ( # noqa: F401 diff --git a/src/spiffworkflow_backend/models/message_correlation_message_instance.py b/src/spiffworkflow_backend/models/message_correlation_message_instance.py index 320dfba3..f056aec6 100644 --- a/src/spiffworkflow_backend/models/message_correlation_message_instance.py +++ b/src/spiffworkflow_backend/models/message_correlation_message_instance.py @@ -3,10 +3,9 @@ from dataclasses import dataclass from flask_bpmn.models.db import db from flask_bpmn.models.db import SpiffworkflowBaseDBModel -from sqlalchemy import ForeignKey - from spiffworkflow_backend.models.message_correlation import MessageCorrelationModel from spiffworkflow_backend.models.message_instance import MessageInstanceModel +from sqlalchemy import ForeignKey @dataclass diff --git a/src/spiffworkflow_backend/models/message_correlation_property.py b/src/spiffworkflow_backend/models/message_correlation_property.py index b84b7140..04acaa94 100644 --- a/src/spiffworkflow_backend/models/message_correlation_property.py +++ b/src/spiffworkflow_backend/models/message_correlation_property.py @@ -1,9 +1,8 @@ """Message_correlation_property.""" from flask_bpmn.models.db import db from flask_bpmn.models.db import SpiffworkflowBaseDBModel -from sqlalchemy import ForeignKey - from spiffworkflow_backend.models.message_model import MessageModel +from sqlalchemy import ForeignKey class MessageCorrelationPropertyModel(SpiffworkflowBaseDBModel): diff --git a/src/spiffworkflow_backend/models/message_instance.py b/src/spiffworkflow_backend/models/message_instance.py index 61dd12b2..2bc9c267 100644 --- a/src/spiffworkflow_backend/models/message_instance.py +++ b/src/spiffworkflow_backend/models/message_instance.py @@ -7,15 +7,14 @@ from typing import TYPE_CHECKING from flask_bpmn.models.db import db from flask_bpmn.models.db import SpiffworkflowBaseDBModel +from spiffworkflow_backend.models.message_model import MessageModel +from spiffworkflow_backend.models.process_instance import ProcessInstanceModel from sqlalchemy import ForeignKey from sqlalchemy.event import listens_for from sqlalchemy.orm import relationship from sqlalchemy.orm import Session from sqlalchemy.orm import validates -from spiffworkflow_backend.models.message_model import MessageModel -from spiffworkflow_backend.models.process_instance import ProcessInstanceModel - if TYPE_CHECKING: from spiffworkflow_backend.models.message_correlation_message_instance import ( # noqa: F401 MessageCorrelationMessageInstanceModel, diff --git a/src/spiffworkflow_backend/models/message_triggerable_process_model.py b/src/spiffworkflow_backend/models/message_triggerable_process_model.py index 97d54aa7..b82580d7 100644 --- a/src/spiffworkflow_backend/models/message_triggerable_process_model.py +++ b/src/spiffworkflow_backend/models/message_triggerable_process_model.py @@ -1,9 +1,8 @@ """Message_correlation_property.""" from flask_bpmn.models.db import db from flask_bpmn.models.db import SpiffworkflowBaseDBModel -from sqlalchemy import ForeignKey - from spiffworkflow_backend.models.message_model import MessageModel +from sqlalchemy import ForeignKey class MessageTriggerableProcessModel(SpiffworkflowBaseDBModel): diff --git a/src/spiffworkflow_backend/models/permission_assignment.py b/src/spiffworkflow_backend/models/permission_assignment.py index 63295f74..19434192 100644 --- a/src/spiffworkflow_backend/models/permission_assignment.py +++ b/src/spiffworkflow_backend/models/permission_assignment.py @@ -4,11 +4,10 @@ from typing import Any from flask_bpmn.models.db import db from flask_bpmn.models.db import SpiffworkflowBaseDBModel -from sqlalchemy import ForeignKey -from sqlalchemy.orm import validates - from spiffworkflow_backend.models.permission_target import PermissionTargetModel from spiffworkflow_backend.models.principal import PrincipalModel +from sqlalchemy import ForeignKey +from sqlalchemy.orm import validates class PermitDeny(enum.Enum): diff --git a/src/spiffworkflow_backend/models/principal.py b/src/spiffworkflow_backend/models/principal.py index c7efa860..d43be35a 100644 --- a/src/spiffworkflow_backend/models/principal.py +++ b/src/spiffworkflow_backend/models/principal.py @@ -3,13 +3,12 @@ from dataclasses import dataclass from flask_bpmn.models.db import db from flask_bpmn.models.db import SpiffworkflowBaseDBModel +from spiffworkflow_backend.models.group import GroupModel +from spiffworkflow_backend.models.user import UserModel from sqlalchemy import ForeignKey from sqlalchemy.orm import relationship from sqlalchemy.schema import CheckConstraint -from spiffworkflow_backend.models.group import GroupModel -from spiffworkflow_backend.models.user import UserModel - class DataValidityError(Exception): """DataValidityError.""" diff --git a/src/spiffworkflow_backend/models/process_group.py b/src/spiffworkflow_backend/models/process_group.py index 0b100ed4..c7229d9f 100644 --- a/src/spiffworkflow_backend/models/process_group.py +++ b/src/spiffworkflow_backend/models/process_group.py @@ -8,7 +8,6 @@ from typing import Any import marshmallow from marshmallow import post_load from marshmallow import Schema - from spiffworkflow_backend.models.process_model import ProcessModelInfo diff --git a/src/spiffworkflow_backend/models/process_instance.py b/src/spiffworkflow_backend/models/process_instance.py index d1d117c8..c375aa73 100644 --- a/src/spiffworkflow_backend/models/process_instance.py +++ b/src/spiffworkflow_backend/models/process_instance.py @@ -12,16 +12,15 @@ from marshmallow import INCLUDE from marshmallow import Schema from marshmallow_enum import EnumField # type: ignore from SpiffWorkflow.util.deep_merge import DeepMerge # type: ignore -from sqlalchemy import ForeignKey -from sqlalchemy.orm import deferred -from sqlalchemy.orm import relationship -from sqlalchemy.orm import validates - from spiffworkflow_backend.helpers.spiff_enum import SpiffEnum from spiffworkflow_backend.models.process_model import ProcessModelInfo from spiffworkflow_backend.models.task import Task from spiffworkflow_backend.models.task import TaskSchema from spiffworkflow_backend.models.user import UserModel +from sqlalchemy import ForeignKey +from sqlalchemy.orm import deferred +from sqlalchemy.orm import relationship +from sqlalchemy.orm import validates class NavigationItemSchema(Schema): diff --git a/src/spiffworkflow_backend/models/process_instance_report.py b/src/spiffworkflow_backend/models/process_instance_report.py index 8f8886bf..b33043d4 100644 --- a/src/spiffworkflow_backend/models/process_instance_report.py +++ b/src/spiffworkflow_backend/models/process_instance_report.py @@ -9,10 +9,6 @@ from typing import TypedDict from flask_bpmn.models.db import db from flask_bpmn.models.db import SpiffworkflowBaseDBModel -from sqlalchemy import ForeignKey -from sqlalchemy.orm import deferred -from sqlalchemy.orm import relationship - from spiffworkflow_backend.exceptions.process_entity_not_found_error import ( ProcessEntityNotFoundError, ) @@ -22,6 +18,9 @@ from spiffworkflow_backend.services.process_instance_processor import ( ProcessInstanceProcessor, ) from spiffworkflow_backend.services.process_model_service import ProcessModelService +from sqlalchemy import ForeignKey +from sqlalchemy.orm import deferred +from sqlalchemy.orm import relationship ReportMetadata = dict[str, Any] diff --git a/src/spiffworkflow_backend/models/process_model.py b/src/spiffworkflow_backend/models/process_model.py index 9558a79b..ccbd0bc5 100644 --- a/src/spiffworkflow_backend/models/process_model.py +++ b/src/spiffworkflow_backend/models/process_model.py @@ -9,7 +9,6 @@ from typing import Any import marshmallow from marshmallow import Schema from marshmallow.decorators import post_load - from spiffworkflow_backend.models.file import File diff --git a/src/spiffworkflow_backend/models/secret_model.py b/src/spiffworkflow_backend/models/secret_model.py index 92fd470a..9cc338ed 100644 --- a/src/spiffworkflow_backend/models/secret_model.py +++ b/src/spiffworkflow_backend/models/secret_model.py @@ -4,9 +4,8 @@ from dataclasses import dataclass from flask_bpmn.models.db import db from flask_bpmn.models.db import SpiffworkflowBaseDBModel from marshmallow import Schema -from sqlalchemy import ForeignKey - from spiffworkflow_backend.models.user import UserModel +from sqlalchemy import ForeignKey @dataclass() diff --git a/src/spiffworkflow_backend/models/spiff_logging.py b/src/spiffworkflow_backend/models/spiff_logging.py index a655ec51..b4c0b978 100644 --- a/src/spiffworkflow_backend/models/spiff_logging.py +++ b/src/spiffworkflow_backend/models/spiff_logging.py @@ -4,10 +4,9 @@ from typing import Optional from flask_bpmn.models.db import db from flask_bpmn.models.db import SpiffworkflowBaseDBModel -from sqlalchemy import ForeignKey - from spiffworkflow_backend.models.process_instance import ProcessInstanceModel from spiffworkflow_backend.models.user import UserModel +from sqlalchemy import ForeignKey @dataclass diff --git a/src/spiffworkflow_backend/models/user.py b/src/spiffworkflow_backend/models/user.py index 22cdfb69..72126764 100644 --- a/src/spiffworkflow_backend/models/user.py +++ b/src/spiffworkflow_backend/models/user.py @@ -10,13 +10,12 @@ from flask_bpmn.api.api_error import ApiError from flask_bpmn.models.db import db from flask_bpmn.models.db import SpiffworkflowBaseDBModel from marshmallow import Schema -from sqlalchemy.orm import relationship -from sqlalchemy.orm import validates - from spiffworkflow_backend.models.group import GroupModel from spiffworkflow_backend.services.authentication_service import ( AuthenticationProviderTypes, ) +from sqlalchemy.orm import relationship +from sqlalchemy.orm import validates class UserNotFoundError(Exception): diff --git a/src/spiffworkflow_backend/models/user_group_assignment.py b/src/spiffworkflow_backend/models/user_group_assignment.py index fa5b620c..8cccf1d8 100644 --- a/src/spiffworkflow_backend/models/user_group_assignment.py +++ b/src/spiffworkflow_backend/models/user_group_assignment.py @@ -1,11 +1,10 @@ """UserGroupAssignment.""" from flask_bpmn.models.db import db from flask_bpmn.models.db import SpiffworkflowBaseDBModel -from sqlalchemy import ForeignKey -from sqlalchemy.orm import relationship - from spiffworkflow_backend.models.group import GroupModel from spiffworkflow_backend.models.user import UserModel +from sqlalchemy import ForeignKey +from sqlalchemy.orm import relationship class UserGroupAssignmentModel(SpiffworkflowBaseDBModel): diff --git a/src/spiffworkflow_backend/routes/admin_blueprint/admin_blueprint.py b/src/spiffworkflow_backend/routes/admin_blueprint/admin_blueprint.py index 2e480f2a..f13e4e07 100644 --- a/src/spiffworkflow_backend/routes/admin_blueprint/admin_blueprint.py +++ b/src/spiffworkflow_backend/routes/admin_blueprint/admin_blueprint.py @@ -7,8 +7,6 @@ from flask import redirect from flask import render_template from flask import request from flask import url_for -from werkzeug.wrappers import Response - from spiffworkflow_backend.services.process_instance_processor import ( ProcessInstanceProcessor, ) @@ -18,6 +16,7 @@ from spiffworkflow_backend.services.process_instance_service import ( from spiffworkflow_backend.services.process_model_service import ProcessModelService from spiffworkflow_backend.services.spec_file_service import SpecFileService from spiffworkflow_backend.services.user_service import UserService +from werkzeug.wrappers import Response admin_blueprint = Blueprint( "admin", __name__, template_folder="templates", static_folder="static" diff --git a/src/spiffworkflow_backend/routes/process_api_blueprint.py b/src/spiffworkflow_backend/routes/process_api_blueprint.py index 9fb16cc6..18ad9e10 100644 --- a/src/spiffworkflow_backend/routes/process_api_blueprint.py +++ b/src/spiffworkflow_backend/routes/process_api_blueprint.py @@ -29,9 +29,6 @@ from lxml import etree # type: ignore from lxml.builder import ElementMaker # type: ignore from SpiffWorkflow.task import Task as SpiffTask # type: ignore from SpiffWorkflow.task import TaskState -from sqlalchemy import asc -from sqlalchemy import desc - from spiffworkflow_backend.exceptions.process_entity_not_found_error import ( ProcessEntityNotFoundError, ) @@ -76,6 +73,8 @@ from spiffworkflow_backend.services.secret_service import SecretService from spiffworkflow_backend.services.service_task_service import ServiceTaskService from spiffworkflow_backend.services.spec_file_service import SpecFileService from spiffworkflow_backend.services.user_service import UserService +from sqlalchemy import asc +from sqlalchemy import desc class TaskDataSelectOption(TypedDict): diff --git a/src/spiffworkflow_backend/routes/user.py b/src/spiffworkflow_backend/routes/user.py index aa5bcdd8..97ad8eee 100644 --- a/src/spiffworkflow_backend/routes/user.py +++ b/src/spiffworkflow_backend/routes/user.py @@ -12,14 +12,13 @@ from flask import g from flask import redirect from flask import request from flask_bpmn.api.api_error import ApiError -from werkzeug.wrappers import Response - from spiffworkflow_backend.models.user import UserModel from spiffworkflow_backend.services.authentication_service import ( AuthenticationService, ) from spiffworkflow_backend.services.authorization_service import AuthorizationService from spiffworkflow_backend.services.user_service import UserService +from werkzeug.wrappers import Response """ .. module:: crc.api.user diff --git a/src/spiffworkflow_backend/routes/user_blueprint.py b/src/spiffworkflow_backend/routes/user_blueprint.py index 29bbddcd..9520dfc8 100644 --- a/src/spiffworkflow_backend/routes/user_blueprint.py +++ b/src/spiffworkflow_backend/routes/user_blueprint.py @@ -9,11 +9,10 @@ from flask import request from flask import Response from flask_bpmn.api.api_error import ApiError from flask_bpmn.models.db import db -from sqlalchemy.exc import IntegrityError - from spiffworkflow_backend.models.group import GroupModel from spiffworkflow_backend.models.user import UserModel from spiffworkflow_backend.models.user_group_assignment import UserGroupAssignmentModel +from sqlalchemy.exc import IntegrityError APPLICATION_JSON: Final = "application/json" diff --git a/src/spiffworkflow_backend/scripts/fact_service.py b/src/spiffworkflow_backend/scripts/fact_service.py index ea585d2a..387939ae 100644 --- a/src/spiffworkflow_backend/scripts/fact_service.py +++ b/src/spiffworkflow_backend/scripts/fact_service.py @@ -3,7 +3,6 @@ from typing import Any from typing import Optional from SpiffWorkflow.task import Task as SpiffTask # type: ignore - from spiffworkflow_backend.scripts.script import Script diff --git a/src/spiffworkflow_backend/scripts/get_env.py b/src/spiffworkflow_backend/scripts/get_env.py index 310bcdec..45b86179 100644 --- a/src/spiffworkflow_backend/scripts/get_env.py +++ b/src/spiffworkflow_backend/scripts/get_env.py @@ -3,7 +3,6 @@ from typing import Any from typing import Optional from SpiffWorkflow.task import Task as SpiffTask # type: ignore - from spiffworkflow_backend.scripts.script import Script diff --git a/src/spiffworkflow_backend/scripts/get_localtime.py b/src/spiffworkflow_backend/scripts/get_localtime.py index 7dada59c..019313da 100644 --- a/src/spiffworkflow_backend/scripts/get_localtime.py +++ b/src/spiffworkflow_backend/scripts/get_localtime.py @@ -6,7 +6,6 @@ from typing import Optional import pytz from flask_bpmn.api.api_error import ApiError from SpiffWorkflow.task import Task as SpiffTask # type: ignore - from spiffworkflow_backend.scripts.script import Script diff --git a/src/spiffworkflow_backend/scripts/get_user.py b/src/spiffworkflow_backend/scripts/get_user.py index 73553b3e..db0561a4 100644 --- a/src/spiffworkflow_backend/scripts/get_user.py +++ b/src/spiffworkflow_backend/scripts/get_user.py @@ -4,7 +4,6 @@ from typing import Optional from flask import g from SpiffWorkflow.task import Task as SpiffTask # type: ignore - from spiffworkflow_backend.scripts.script import Script diff --git a/src/spiffworkflow_backend/services/acceptance_test_fixtures.py b/src/spiffworkflow_backend/services/acceptance_test_fixtures.py index 144c5ef2..afed26ba 100644 --- a/src/spiffworkflow_backend/services/acceptance_test_fixtures.py +++ b/src/spiffworkflow_backend/services/acceptance_test_fixtures.py @@ -4,10 +4,9 @@ import time from flask import current_app from flask_bpmn.models.db import db -from tests.spiffworkflow_backend.helpers.base_test import BaseTest - from spiffworkflow_backend.models.process_instance import ProcessInstanceModel from spiffworkflow_backend.models.process_instance import ProcessInstanceStatus +from tests.spiffworkflow_backend.helpers.base_test import BaseTest def load_acceptance_test_fixtures() -> list[ProcessInstanceModel]: diff --git a/src/spiffworkflow_backend/services/authentication_service.py b/src/spiffworkflow_backend/services/authentication_service.py index 18f08d0f..1ec35ae1 100644 --- a/src/spiffworkflow_backend/services/authentication_service.py +++ b/src/spiffworkflow_backend/services/authentication_service.py @@ -11,9 +11,8 @@ from flask import current_app from flask import redirect from flask_bpmn.api.api_error import ApiError from flask_bpmn.models.db import db -from werkzeug.wrappers import Response - from spiffworkflow_backend.models.refresh_token import RefreshTokenModel +from werkzeug.wrappers import Response class AuthenticationProviderTypes(enum.Enum): diff --git a/src/spiffworkflow_backend/services/authorization_service.py b/src/spiffworkflow_backend/services/authorization_service.py index 8796fa99..7c654609 100644 --- a/src/spiffworkflow_backend/services/authorization_service.py +++ b/src/spiffworkflow_backend/services/authorization_service.py @@ -11,8 +11,6 @@ from flask import request from flask_bpmn.api.api_error import ApiError from flask_bpmn.models.db import db from SpiffWorkflow.task import Task as SpiffTask # type: ignore -from sqlalchemy import text - from spiffworkflow_backend.models.active_task import ActiveTaskModel from spiffworkflow_backend.models.group import GroupModel from spiffworkflow_backend.models.permission_assignment import PermissionAssignmentModel @@ -22,10 +20,12 @@ from spiffworkflow_backend.models.principal import PrincipalModel from spiffworkflow_backend.models.user import UserModel from spiffworkflow_backend.models.user import UserNotFoundError from spiffworkflow_backend.models.user_group_assignment import UserGroupAssignmentModel +from spiffworkflow_backend.services.group_service import GroupService from spiffworkflow_backend.services.process_instance_processor import ( ProcessInstanceProcessor, ) from spiffworkflow_backend.services.user_service import UserService +from sqlalchemy import text class PermissionsFileNotSetError(Exception): @@ -138,25 +138,11 @@ class AuthorizationService: default_group = None if "default_group" in permission_configs: default_group_identifier = permission_configs["default_group"] - default_group = GroupModel.query.filter_by( - identifier=default_group_identifier - ).first() - if default_group is None: - default_group = GroupModel(identifier=default_group_identifier) - db.session.add(default_group) - db.session.commit() - UserService.create_principal( - default_group.id, id_column_name="group_id" - ) + default_group = GroupService.find_or_create_group(default_group_identifier) if "groups" in permission_configs: for group_identifier, group_config in permission_configs["groups"].items(): - group = GroupModel.query.filter_by(identifier=group_identifier).first() - if group is None: - group = GroupModel(identifier=group_identifier) - db.session.add(group) - db.session.commit() - UserService.create_principal(group.id, id_column_name="group_id") + group = GroupService.find_or_create_group(group_identifier) for username in group_config["users"]: user = UserModel.query.filter_by(username=username).first() if user is None: @@ -186,13 +172,9 @@ class AuthorizationService: for allowed_permission in permission_config["allowed_permissions"]: if "groups" in permission_config: for group_identifier in permission_config["groups"]: - principal = ( - PrincipalModel.query.join(GroupModel) - .filter(GroupModel.identifier == group_identifier) - .first() - ) + group = GroupService.find_or_create_group(group_identifier) cls.create_permission_for_principal( - principal, permission_target, allowed_permission + group.principal, permission_target, allowed_permission ) if "users" in permission_config: for username in permission_config["users"]: diff --git a/src/spiffworkflow_backend/services/background_processing_service.py b/src/spiffworkflow_backend/services/background_processing_service.py index 08a2b02d..8c4fee6e 100644 --- a/src/spiffworkflow_backend/services/background_processing_service.py +++ b/src/spiffworkflow_backend/services/background_processing_service.py @@ -1,6 +1,5 @@ """Background_processing_service.""" import flask - from spiffworkflow_backend.services.message_service import MessageService from spiffworkflow_backend.services.process_instance_service import ( ProcessInstanceService, diff --git a/src/spiffworkflow_backend/services/data_setup_service.py b/src/spiffworkflow_backend/services/data_setup_service.py index 88bd6048..adee89bd 100644 --- a/src/spiffworkflow_backend/services/data_setup_service.py +++ b/src/spiffworkflow_backend/services/data_setup_service.py @@ -1,6 +1,5 @@ """Data_setup_service.""" from flask import current_app - from spiffworkflow_backend.services.process_model_service import ProcessModelService from spiffworkflow_backend.services.spec_file_service import SpecFileService diff --git a/src/spiffworkflow_backend/services/email_service.py b/src/spiffworkflow_backend/services/email_service.py index 461c9fd2..c554fbb4 100644 --- a/src/spiffworkflow_backend/services/email_service.py +++ b/src/spiffworkflow_backend/services/email_service.py @@ -24,26 +24,19 @@ class EmailService: """We will receive all data related to an email and send it.""" mail = current_app.config["MAIL_APP"] - # Send mail - try: - msg = Message( - subject, - sender=sender, - recipients=recipients, - body=content, - html=content_html, - cc=cc, - bcc=bcc, - reply_to=reply_to, - ) + msg = Message( + subject, + sender=sender, + recipients=recipients, + body=content, + html=content_html, + cc=cc, + bcc=bcc, + reply_to=reply_to, + ) - if attachment_files is not None: - for file in attachment_files: - msg.attach(file["name"], file["type"], file["data"]) + if attachment_files is not None: + for file in attachment_files: + msg.attach(file["name"], file["type"], file["data"]) - mail.send(msg) - - except Exception as e: - # app.logger.error('An exception happened in EmailService', exc_info=True) - # app.logger.error(str(e)) - raise e + mail.send(msg) diff --git a/src/spiffworkflow_backend/services/error_handling_service.py b/src/spiffworkflow_backend/services/error_handling_service.py index 36c66d93..2e011466 100644 --- a/src/spiffworkflow_backend/services/error_handling_service.py +++ b/src/spiffworkflow_backend/services/error_handling_service.py @@ -5,7 +5,6 @@ from typing import Union from flask_bpmn.api.api_error import ApiError from flask_bpmn.models.db import db - from spiffworkflow_backend.models.process_instance import ProcessInstanceModel from spiffworkflow_backend.models.process_instance import ProcessInstanceStatus from spiffworkflow_backend.services.email_service import EmailService diff --git a/src/spiffworkflow_backend/services/file_system_service.py b/src/spiffworkflow_backend/services/file_system_service.py index 3b23ce1b..f0a80fb0 100644 --- a/src/spiffworkflow_backend/services/file_system_service.py +++ b/src/spiffworkflow_backend/services/file_system_service.py @@ -7,7 +7,6 @@ from typing import Optional import pytz from flask import current_app from flask_bpmn.api.api_error import ApiError - from spiffworkflow_backend.models.file import CONTENT_TYPES from spiffworkflow_backend.models.file import File from spiffworkflow_backend.models.file import FileType diff --git a/src/spiffworkflow_backend/services/git_service.py b/src/spiffworkflow_backend/services/git_service.py index 815e4cad..08f45386 100644 --- a/src/spiffworkflow_backend/services/git_service.py +++ b/src/spiffworkflow_backend/services/git_service.py @@ -2,7 +2,6 @@ import os from flask import current_app - from spiffworkflow_backend.models.process_model import ProcessModelInfo from spiffworkflow_backend.services.file_system_service import FileSystemService diff --git a/src/spiffworkflow_backend/services/group_service.py b/src/spiffworkflow_backend/services/group_service.py new file mode 100644 index 00000000..a2e54460 --- /dev/null +++ b/src/spiffworkflow_backend/services/group_service.py @@ -0,0 +1,23 @@ +"""Group_service.""" +from typing import Optional + +from flask_bpmn.models.db import db +from spiffworkflow_backend.models.group import GroupModel +from spiffworkflow_backend.services.user_service import UserService + + +class GroupService: + """GroupService.""" + + @classmethod + def find_or_create_group(cls, group_identifier: str) -> GroupModel: + """Find_or_create_group.""" + group: Optional[GroupModel] = GroupModel.query.filter_by( + identifier=group_identifier + ).first() + if group is None: + group = GroupModel(identifier=group_identifier) + db.session.add(group) + db.session.commit() + UserService.create_principal(group.id, id_column_name="group_id") + return group diff --git a/src/spiffworkflow_backend/services/logging_service.py b/src/spiffworkflow_backend/services/logging_service.py index ce30e8b9..cbc0a8d0 100644 --- a/src/spiffworkflow_backend/services/logging_service.py +++ b/src/spiffworkflow_backend/services/logging_service.py @@ -8,7 +8,6 @@ from typing import Optional from flask import g from flask.app import Flask from flask_bpmn.models.db import db - from spiffworkflow_backend.models.spiff_logging import SpiffLoggingModel diff --git a/src/spiffworkflow_backend/services/message_service.py b/src/spiffworkflow_backend/services/message_service.py index da1e6224..5e0c02ef 100644 --- a/src/spiffworkflow_backend/services/message_service.py +++ b/src/spiffworkflow_backend/services/message_service.py @@ -3,10 +3,6 @@ from typing import Any from typing import Optional from flask_bpmn.models.db import db -from sqlalchemy import and_ -from sqlalchemy import or_ -from sqlalchemy import select - from spiffworkflow_backend.models.message_correlation import MessageCorrelationModel from spiffworkflow_backend.models.message_correlation_message_instance import ( MessageCorrelationMessageInstanceModel, @@ -23,6 +19,9 @@ from spiffworkflow_backend.services.process_instance_processor import ( from spiffworkflow_backend.services.process_instance_service import ( ProcessInstanceService, ) +from sqlalchemy import and_ +from sqlalchemy import or_ +from sqlalchemy import select class MessageServiceError(Exception): diff --git a/src/spiffworkflow_backend/services/process_instance_processor.py b/src/spiffworkflow_backend/services/process_instance_processor.py index a2fe0d44..3c49ec7c 100644 --- a/src/spiffworkflow_backend/services/process_instance_processor.py +++ b/src/spiffworkflow_backend/services/process_instance_processor.py @@ -55,7 +55,6 @@ from SpiffWorkflow.spiff.serializer import UserTaskConverter from SpiffWorkflow.task import Task as SpiffTask # type: ignore from SpiffWorkflow.task import TaskState from SpiffWorkflow.util.deep_merge import DeepMerge # type: ignore - from spiffworkflow_backend.models.active_task import ActiveTaskModel from spiffworkflow_backend.models.active_task_user import ActiveTaskUserModel from spiffworkflow_backend.models.bpmn_process_id_lookup import BpmnProcessIdLookup diff --git a/src/spiffworkflow_backend/services/process_instance_service.py b/src/spiffworkflow_backend/services/process_instance_service.py index 214dc4f7..0e75caa5 100644 --- a/src/spiffworkflow_backend/services/process_instance_service.py +++ b/src/spiffworkflow_backend/services/process_instance_service.py @@ -10,7 +10,6 @@ from flask_bpmn.api.api_error import ApiError from flask_bpmn.models.db import db from SpiffWorkflow.task import Task as SpiffTask # type: ignore from SpiffWorkflow.util.deep_merge import DeepMerge # type: ignore - from spiffworkflow_backend.models.process_instance import ProcessInstanceApi from spiffworkflow_backend.models.process_instance import ProcessInstanceModel from spiffworkflow_backend.models.process_instance import ProcessInstanceStatus @@ -167,9 +166,7 @@ class ProcessInstanceService: f"task {spiff_task.task_spec.name}, it is not in the task event model, " f"and it should be." ) - current_app.logger.error( - "missing_form_data", missing_form_error, exc_info=True - ) + current_app.logger.exception("missing_form_data", missing_form_error) return {} else: return {} diff --git a/src/spiffworkflow_backend/services/process_model_service.py b/src/spiffworkflow_backend/services/process_model_service.py index 57d84229..ec24f461 100644 --- a/src/spiffworkflow_backend/services/process_model_service.py +++ b/src/spiffworkflow_backend/services/process_model_service.py @@ -8,7 +8,6 @@ from typing import Optional from typing import TypeVar from flask_bpmn.api.api_error import ApiError - from spiffworkflow_backend.exceptions.process_entity_not_found_error import ( ProcessEntityNotFoundError, ) diff --git a/src/spiffworkflow_backend/services/script_unit_test_runner.py b/src/spiffworkflow_backend/services/script_unit_test_runner.py index 9112e20f..b9ec129e 100644 --- a/src/spiffworkflow_backend/services/script_unit_test_runner.py +++ b/src/spiffworkflow_backend/services/script_unit_test_runner.py @@ -8,7 +8,6 @@ from typing import Optional from SpiffWorkflow.bpmn.exceptions import WorkflowTaskExecException # type: ignore from SpiffWorkflow.task import Task as SpiffTask # type: ignore - from spiffworkflow_backend.services.process_instance_processor import ( CustomBpmnScriptEngine, ) diff --git a/src/spiffworkflow_backend/services/secret_service.py b/src/spiffworkflow_backend/services/secret_service.py index 42f401c1..33264499 100644 --- a/src/spiffworkflow_backend/services/secret_service.py +++ b/src/spiffworkflow_backend/services/secret_service.py @@ -3,7 +3,6 @@ from typing import Optional from flask_bpmn.api.api_error import ApiError from flask_bpmn.models.db import db - from spiffworkflow_backend.models.secret_model import SecretModel # from cryptography.fernet import Fernet diff --git a/src/spiffworkflow_backend/services/service_task_service.py b/src/spiffworkflow_backend/services/service_task_service.py index 97ce1495..fb2961f5 100644 --- a/src/spiffworkflow_backend/services/service_task_service.py +++ b/src/spiffworkflow_backend/services/service_task_service.py @@ -5,7 +5,6 @@ from typing import Any import requests from flask import current_app from flask import g - from spiffworkflow_backend.services.file_system_service import FileSystemService from spiffworkflow_backend.services.secret_service import SecretService diff --git a/src/spiffworkflow_backend/services/spec_file_service.py b/src/spiffworkflow_backend/services/spec_file_service.py index 4e1e30e2..5395e73b 100644 --- a/src/spiffworkflow_backend/services/spec_file_service.py +++ b/src/spiffworkflow_backend/services/spec_file_service.py @@ -11,7 +11,6 @@ from lxml import etree # type: ignore from lxml.etree import _Element # type: ignore from lxml.etree import Element as EtreeElement from SpiffWorkflow.bpmn.parser.ValidationException import ValidationException # type: ignore - from spiffworkflow_backend.models.bpmn_process_id_lookup import BpmnProcessIdLookup from spiffworkflow_backend.models.file import File from spiffworkflow_backend.models.file import FileType diff --git a/src/spiffworkflow_backend/services/user_service.py b/src/spiffworkflow_backend/services/user_service.py index d4749e01..035cf566 100644 --- a/src/spiffworkflow_backend/services/user_service.py +++ b/src/spiffworkflow_backend/services/user_service.py @@ -6,7 +6,6 @@ from flask import current_app from flask import g from flask_bpmn.api.api_error import ApiError from flask_bpmn.models.db import db - from spiffworkflow_backend.models.active_task import ActiveTaskModel from spiffworkflow_backend.models.active_task_user import ActiveTaskUserModel from spiffworkflow_backend.models.group import GroupModel diff --git a/tests/spiffworkflow_backend/helpers/base_test.py b/tests/spiffworkflow_backend/helpers/base_test.py index b7d2c5d7..9c356561 100644 --- a/tests/spiffworkflow_backend/helpers/base_test.py +++ b/tests/spiffworkflow_backend/helpers/base_test.py @@ -12,9 +12,6 @@ from flask.app import Flask from flask.testing import FlaskClient from flask_bpmn.api.api_error import ApiError from flask_bpmn.models.db import db -from tests.spiffworkflow_backend.helpers.test_data import load_test_spec -from werkzeug.test import TestResponse # type: ignore - from spiffworkflow_backend.models.permission_assignment import Permission from spiffworkflow_backend.models.permission_target import PermissionTargetModel from spiffworkflow_backend.models.process_group import ProcessGroup @@ -27,6 +24,8 @@ from spiffworkflow_backend.models.user import UserModel from spiffworkflow_backend.services.authorization_service import AuthorizationService from spiffworkflow_backend.services.process_model_service import ProcessModelService from spiffworkflow_backend.services.user_service import UserService +from tests.spiffworkflow_backend.helpers.test_data import load_test_spec +from werkzeug.test import TestResponse # type: ignore # from tests.spiffworkflow_backend.helpers.test_data import logged_in_headers diff --git a/tests/spiffworkflow_backend/helpers/example_data.py b/tests/spiffworkflow_backend/helpers/example_data.py index a94be48e..6babccbb 100644 --- a/tests/spiffworkflow_backend/helpers/example_data.py +++ b/tests/spiffworkflow_backend/helpers/example_data.py @@ -4,7 +4,6 @@ import os from typing import Optional from flask import current_app - from spiffworkflow_backend.models.process_model import ProcessModelInfo from spiffworkflow_backend.services.process_model_service import ProcessModelService from spiffworkflow_backend.services.spec_file_service import SpecFileService diff --git a/tests/spiffworkflow_backend/helpers/test_data.py b/tests/spiffworkflow_backend/helpers/test_data.py index fd418aa2..adda7c6e 100644 --- a/tests/spiffworkflow_backend/helpers/test_data.py +++ b/tests/spiffworkflow_backend/helpers/test_data.py @@ -1,14 +1,13 @@ """User.""" from typing import Optional -from tests.spiffworkflow_backend.helpers.example_data import ExampleDataLoader - from spiffworkflow_backend.exceptions.process_entity_not_found_error import ( ProcessEntityNotFoundError, ) from spiffworkflow_backend.models.process_group import ProcessGroup from spiffworkflow_backend.models.process_model import ProcessModelInfo from spiffworkflow_backend.services.process_model_service import ProcessModelService +from tests.spiffworkflow_backend.helpers.example_data import ExampleDataLoader def assure_process_group_exists(process_group_id: Optional[str] = None) -> ProcessGroup: diff --git a/tests/spiffworkflow_backend/integration/test_authentication.py b/tests/spiffworkflow_backend/integration/test_authentication.py index 34e4d71b..53794348 100644 --- a/tests/spiffworkflow_backend/integration/test_authentication.py +++ b/tests/spiffworkflow_backend/integration/test_authentication.py @@ -2,11 +2,10 @@ import ast import base64 -from tests.spiffworkflow_backend.helpers.base_test import BaseTest - from spiffworkflow_backend.services.authentication_service import ( AuthenticationService, ) +from tests.spiffworkflow_backend.helpers.base_test import BaseTest class TestAuthentication(BaseTest): diff --git a/tests/spiffworkflow_backend/integration/test_logging_service.py b/tests/spiffworkflow_backend/integration/test_logging_service.py index a8d2720f..d63dee0c 100644 --- a/tests/spiffworkflow_backend/integration/test_logging_service.py +++ b/tests/spiffworkflow_backend/integration/test_logging_service.py @@ -1,9 +1,8 @@ """Test_logging_service.""" from flask.app import Flask from flask.testing import FlaskClient -from tests.spiffworkflow_backend.helpers.base_test import BaseTest - from spiffworkflow_backend.models.user import UserModel +from tests.spiffworkflow_backend.helpers.base_test import BaseTest class TestLoggingService(BaseTest): diff --git a/tests/spiffworkflow_backend/integration/test_process_api.py b/tests/spiffworkflow_backend/integration/test_process_api.py index 2d79b652..e9410e10 100644 --- a/tests/spiffworkflow_backend/integration/test_process_api.py +++ b/tests/spiffworkflow_backend/integration/test_process_api.py @@ -8,9 +8,6 @@ import pytest from flask.app import Flask from flask.testing import FlaskClient from flask_bpmn.models.db import db -from tests.spiffworkflow_backend.helpers.base_test import BaseTest -from tests.spiffworkflow_backend.helpers.test_data import load_test_spec - from spiffworkflow_backend.exceptions.process_entity_not_found_error import ( ProcessEntityNotFoundError, ) @@ -33,6 +30,8 @@ from spiffworkflow_backend.services.process_instance_processor import ( ProcessInstanceProcessor, ) from spiffworkflow_backend.services.process_model_service import ProcessModelService +from tests.spiffworkflow_backend.helpers.base_test import BaseTest +from tests.spiffworkflow_backend.helpers.test_data import load_test_spec # from spiffworkflow_backend.services.git_service import GitService diff --git a/tests/spiffworkflow_backend/integration/test_secret_service.py b/tests/spiffworkflow_backend/integration/test_secret_service.py index 3735ebc5..e1b80425 100644 --- a/tests/spiffworkflow_backend/integration/test_secret_service.py +++ b/tests/spiffworkflow_backend/integration/test_secret_service.py @@ -6,15 +6,14 @@ import pytest from flask.app import Flask from flask.testing import FlaskClient from flask_bpmn.api.api_error import ApiError -from tests.spiffworkflow_backend.helpers.base_test import BaseTest -from werkzeug.test import TestResponse # type: ignore - from spiffworkflow_backend.models.process_model import ProcessModelInfo from spiffworkflow_backend.models.secret_model import SecretModel from spiffworkflow_backend.models.secret_model import SecretModelSchema from spiffworkflow_backend.models.user import UserModel from spiffworkflow_backend.services.process_model_service import ProcessModelService from spiffworkflow_backend.services.secret_service import SecretService +from tests.spiffworkflow_backend.helpers.base_test import BaseTest +from werkzeug.test import TestResponse # type: ignore class SecretServiceTestHelpers(BaseTest): diff --git a/tests/spiffworkflow_backend/scripts/test_get_localtime.py b/tests/spiffworkflow_backend/scripts/test_get_localtime.py index 03ef995e..cb81ce61 100644 --- a/tests/spiffworkflow_backend/scripts/test_get_localtime.py +++ b/tests/spiffworkflow_backend/scripts/test_get_localtime.py @@ -4,9 +4,6 @@ import datetime import pytz from flask.app import Flask 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.scripts.get_localtime import GetLocaltime from spiffworkflow_backend.services.process_instance_processor import ( ProcessInstanceProcessor, @@ -14,6 +11,8 @@ from spiffworkflow_backend.services.process_instance_processor import ( from spiffworkflow_backend.services.process_instance_service import ( ProcessInstanceService, ) +from tests.spiffworkflow_backend.helpers.base_test import BaseTest +from tests.spiffworkflow_backend.helpers.test_data import load_test_spec class TestGetLocaltime(BaseTest): diff --git a/tests/spiffworkflow_backend/unit/test_acceptance_test_fixtures.py b/tests/spiffworkflow_backend/unit/test_acceptance_test_fixtures.py index 1d515712..a9305a04 100644 --- a/tests/spiffworkflow_backend/unit/test_acceptance_test_fixtures.py +++ b/tests/spiffworkflow_backend/unit/test_acceptance_test_fixtures.py @@ -1,6 +1,5 @@ """Test_acceptance_test_fixtures.""" from flask.app import Flask - from spiffworkflow_backend.services.acceptance_test_fixtures import ( load_acceptance_test_fixtures, ) diff --git a/tests/spiffworkflow_backend/unit/test_authorization_service.py b/tests/spiffworkflow_backend/unit/test_authorization_service.py index ff2ac9bc..1d173efb 100644 --- a/tests/spiffworkflow_backend/unit/test_authorization_service.py +++ b/tests/spiffworkflow_backend/unit/test_authorization_service.py @@ -1,9 +1,6 @@ """Test_message_service.""" import pytest from flask import Flask -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 UserNotFoundError from spiffworkflow_backend.services.authorization_service import AuthorizationService from spiffworkflow_backend.services.process_instance_processor import ( @@ -12,6 +9,8 @@ from spiffworkflow_backend.services.process_instance_processor import ( from spiffworkflow_backend.services.process_instance_service import ( ProcessInstanceService, ) +from tests.spiffworkflow_backend.helpers.base_test import BaseTest +from tests.spiffworkflow_backend.helpers.test_data import load_test_spec class TestAuthorizationService(BaseTest): diff --git a/tests/spiffworkflow_backend/unit/test_dot_notation.py b/tests/spiffworkflow_backend/unit/test_dot_notation.py index 4446d4d9..248e73d5 100644 --- a/tests/spiffworkflow_backend/unit/test_dot_notation.py +++ b/tests/spiffworkflow_backend/unit/test_dot_notation.py @@ -1,14 +1,13 @@ """Test_various_bpmn_constructs.""" from flask.app import Flask -from tests.spiffworkflow_backend.helpers.base_test import BaseTest -from tests.spiffworkflow_backend.helpers.test_data import load_test_spec - from spiffworkflow_backend.services.process_instance_processor import ( ProcessInstanceProcessor, ) from spiffworkflow_backend.services.process_instance_service import ( ProcessInstanceService, ) +from tests.spiffworkflow_backend.helpers.base_test import BaseTest +from tests.spiffworkflow_backend.helpers.test_data import load_test_spec class TestDotNotation(BaseTest): diff --git a/tests/spiffworkflow_backend/unit/test_environment_var_script.py b/tests/spiffworkflow_backend/unit/test_environment_var_script.py index ac96e7e4..e00fb770 100644 --- a/tests/spiffworkflow_backend/unit/test_environment_var_script.py +++ b/tests/spiffworkflow_backend/unit/test_environment_var_script.py @@ -1,10 +1,9 @@ """Test_environment_var_script.""" from flask import Flask -from tests.spiffworkflow_backend.helpers.base_test import BaseTest - from spiffworkflow_backend.services.process_instance_processor import ( ProcessInstanceProcessor, ) +from tests.spiffworkflow_backend.helpers.base_test import BaseTest class TestEnvironmentVarScript(BaseTest): diff --git a/tests/spiffworkflow_backend/unit/test_message_instance.py b/tests/spiffworkflow_backend/unit/test_message_instance.py index 842d5ff4..032e21b9 100644 --- a/tests/spiffworkflow_backend/unit/test_message_instance.py +++ b/tests/spiffworkflow_backend/unit/test_message_instance.py @@ -2,11 +2,10 @@ import pytest from flask import Flask from flask_bpmn.models.db import db -from tests.spiffworkflow_backend.helpers.base_test import BaseTest -from tests.spiffworkflow_backend.helpers.test_data import load_test_spec - from spiffworkflow_backend.models.message_instance import MessageInstanceModel from spiffworkflow_backend.models.message_model import MessageModel +from tests.spiffworkflow_backend.helpers.base_test import BaseTest +from tests.spiffworkflow_backend.helpers.test_data import load_test_spec class TestMessageInstance(BaseTest): diff --git a/tests/spiffworkflow_backend/unit/test_message_service.py b/tests/spiffworkflow_backend/unit/test_message_service.py index 38079c96..25a901e5 100644 --- a/tests/spiffworkflow_backend/unit/test_message_service.py +++ b/tests/spiffworkflow_backend/unit/test_message_service.py @@ -1,8 +1,5 @@ """Test_message_service.""" from flask import Flask -from tests.spiffworkflow_backend.helpers.base_test import BaseTest -from tests.spiffworkflow_backend.helpers.test_data import load_test_spec - from spiffworkflow_backend.models.message_correlation import MessageCorrelationModel from spiffworkflow_backend.models.message_correlation_message_instance import ( MessageCorrelationMessageInstanceModel, @@ -16,6 +13,8 @@ from spiffworkflow_backend.services.process_instance_processor import ( from spiffworkflow_backend.services.process_instance_service import ( ProcessInstanceService, ) +from tests.spiffworkflow_backend.helpers.base_test import BaseTest +from tests.spiffworkflow_backend.helpers.test_data import load_test_spec class TestMessageService(BaseTest): diff --git a/tests/spiffworkflow_backend/unit/test_permission_target.py b/tests/spiffworkflow_backend/unit/test_permission_target.py index 56768142..a6fefd68 100644 --- a/tests/spiffworkflow_backend/unit/test_permission_target.py +++ b/tests/spiffworkflow_backend/unit/test_permission_target.py @@ -2,12 +2,11 @@ import pytest from flask.app import Flask from flask_bpmn.models.db import db -from tests.spiffworkflow_backend.helpers.base_test import BaseTest - from spiffworkflow_backend.models.permission_target import ( InvalidPermissionTargetUriError, ) from spiffworkflow_backend.models.permission_target import PermissionTargetModel +from tests.spiffworkflow_backend.helpers.base_test import BaseTest class TestPermissionTarget(BaseTest): diff --git a/tests/spiffworkflow_backend/unit/test_permissions.py b/tests/spiffworkflow_backend/unit/test_permissions.py index 39f857e2..fd12bdea 100644 --- a/tests/spiffworkflow_backend/unit/test_permissions.py +++ b/tests/spiffworkflow_backend/unit/test_permissions.py @@ -1,14 +1,13 @@ """Test Permissions.""" from flask.app import Flask from flask_bpmn.models.db import db -from tests.spiffworkflow_backend.helpers.base_test import BaseTest -from tests.spiffworkflow_backend.helpers.test_data import load_test_spec - from spiffworkflow_backend.models.group import GroupModel from spiffworkflow_backend.models.permission_assignment import PermissionAssignmentModel from spiffworkflow_backend.models.permission_target import PermissionTargetModel from spiffworkflow_backend.models.principal import PrincipalModel from spiffworkflow_backend.services.user_service import UserService +from tests.spiffworkflow_backend.helpers.base_test import BaseTest +from tests.spiffworkflow_backend.helpers.test_data import load_test_spec # we think we can get the list of roles for a user. diff --git a/tests/spiffworkflow_backend/unit/test_process_group.py b/tests/spiffworkflow_backend/unit/test_process_group.py index 6c3ad0ad..b2cf3c44 100644 --- a/tests/spiffworkflow_backend/unit/test_process_group.py +++ b/tests/spiffworkflow_backend/unit/test_process_group.py @@ -1,6 +1,5 @@ """Process Model.""" from flask.app import Flask - from spiffworkflow_backend.models.process_group import ProcessGroup from spiffworkflow_backend.services.process_model_service import ProcessModelService diff --git a/tests/spiffworkflow_backend/unit/test_process_instance_processor.py b/tests/spiffworkflow_backend/unit/test_process_instance_processor.py index 543b99c0..d58a2a6c 100644 --- a/tests/spiffworkflow_backend/unit/test_process_instance_processor.py +++ b/tests/spiffworkflow_backend/unit/test_process_instance_processor.py @@ -2,9 +2,6 @@ import pytest from flask import g from flask.app import Flask -from tests.spiffworkflow_backend.helpers.base_test import BaseTest -from tests.spiffworkflow_backend.helpers.test_data import load_test_spec - from spiffworkflow_backend.models.group import GroupModel from spiffworkflow_backend.models.process_instance import ProcessInstanceStatus from spiffworkflow_backend.services.authorization_service import AuthorizationService @@ -17,6 +14,8 @@ from spiffworkflow_backend.services.process_instance_processor import ( from spiffworkflow_backend.services.process_instance_service import ( ProcessInstanceService, ) +from tests.spiffworkflow_backend.helpers.base_test import BaseTest +from tests.spiffworkflow_backend.helpers.test_data import load_test_spec class TestProcessInstanceProcessor(BaseTest): diff --git a/tests/spiffworkflow_backend/unit/test_process_instance_report.py b/tests/spiffworkflow_backend/unit/test_process_instance_report.py index acfac138..94274c1d 100644 --- a/tests/spiffworkflow_backend/unit/test_process_instance_report.py +++ b/tests/spiffworkflow_backend/unit/test_process_instance_report.py @@ -2,12 +2,11 @@ from typing import Optional from flask.app import Flask -from tests.spiffworkflow_backend.helpers.base_test import BaseTest - from spiffworkflow_backend.models.process_instance import ProcessInstanceModel from spiffworkflow_backend.models.process_instance_report import ( ProcessInstanceReportModel, ) +from tests.spiffworkflow_backend.helpers.base_test import BaseTest # from tests.spiffworkflow_backend.helpers.test_data import find_or_create_process_group # from spiffworkflow_backend.models.permission_assignment import PermissionAssignmentModel diff --git a/tests/spiffworkflow_backend/unit/test_process_model.py b/tests/spiffworkflow_backend/unit/test_process_model.py index 479db44a..55a32525 100644 --- a/tests/spiffworkflow_backend/unit/test_process_model.py +++ b/tests/spiffworkflow_backend/unit/test_process_model.py @@ -1,14 +1,13 @@ """Process Model.""" from flask.app import Flask from flask_bpmn.models.db import db -from tests.spiffworkflow_backend.helpers.base_test import BaseTest -from tests.spiffworkflow_backend.helpers.test_data import load_test_spec - from spiffworkflow_backend.models.bpmn_process_id_lookup import BpmnProcessIdLookup from spiffworkflow_backend.models.process_model import ProcessModelInfo from spiffworkflow_backend.services.process_instance_processor import ( ProcessInstanceProcessor, ) +from tests.spiffworkflow_backend.helpers.base_test import BaseTest +from tests.spiffworkflow_backend.helpers.test_data import load_test_spec class TestProcessModel(BaseTest): diff --git a/tests/spiffworkflow_backend/unit/test_process_model_service.py b/tests/spiffworkflow_backend/unit/test_process_model_service.py index 535dc03d..e6ac041b 100644 --- a/tests/spiffworkflow_backend/unit/test_process_model_service.py +++ b/tests/spiffworkflow_backend/unit/test_process_model_service.py @@ -1,10 +1,9 @@ """Test_process_model_service.""" from flask import Flask +from spiffworkflow_backend.services.process_model_service import ProcessModelService from tests.spiffworkflow_backend.helpers.base_test import BaseTest from tests.spiffworkflow_backend.helpers.test_data import load_test_spec -from spiffworkflow_backend.services.process_model_service import ProcessModelService - class TestProcessModelService(BaseTest): """TestProcessModelService.""" diff --git a/tests/spiffworkflow_backend/unit/test_restricted_script_engine.py b/tests/spiffworkflow_backend/unit/test_restricted_script_engine.py index 9b6f1bb3..ec40a599 100644 --- a/tests/spiffworkflow_backend/unit/test_restricted_script_engine.py +++ b/tests/spiffworkflow_backend/unit/test_restricted_script_engine.py @@ -2,12 +2,11 @@ import pytest from flask.app import Flask from flask_bpmn.api.api_error import ApiError -from tests.spiffworkflow_backend.helpers.base_test import BaseTest -from tests.spiffworkflow_backend.helpers.test_data import load_test_spec - from spiffworkflow_backend.services.process_instance_processor import ( ProcessInstanceProcessor, ) +from tests.spiffworkflow_backend.helpers.base_test import BaseTest +from tests.spiffworkflow_backend.helpers.test_data import load_test_spec class TestOpenFile(BaseTest): diff --git a/tests/spiffworkflow_backend/unit/test_script_unit_test_runner.py b/tests/spiffworkflow_backend/unit/test_script_unit_test_runner.py index 69c54851..2ac71570 100644 --- a/tests/spiffworkflow_backend/unit/test_script_unit_test_runner.py +++ b/tests/spiffworkflow_backend/unit/test_script_unit_test_runner.py @@ -1,13 +1,12 @@ """Test Permissions.""" from flask.app import Flask -from tests.spiffworkflow_backend.helpers.base_test import BaseTest -from tests.spiffworkflow_backend.helpers.test_data import load_test_spec - from spiffworkflow_backend.services.process_instance_processor import ( ProcessInstanceProcessor, ) from spiffworkflow_backend.services.script_unit_test_runner import PythonScriptContext from spiffworkflow_backend.services.script_unit_test_runner import ScriptUnitTestRunner +from tests.spiffworkflow_backend.helpers.base_test import BaseTest +from tests.spiffworkflow_backend.helpers.test_data import load_test_spec class TestScriptUnitTestRunner(BaseTest): diff --git a/tests/spiffworkflow_backend/unit/test_service_task_delegate.py b/tests/spiffworkflow_backend/unit/test_service_task_delegate.py index 95b55756..647db175 100644 --- a/tests/spiffworkflow_backend/unit/test_service_task_delegate.py +++ b/tests/spiffworkflow_backend/unit/test_service_task_delegate.py @@ -1,9 +1,8 @@ """Test_various_bpmn_constructs.""" from flask.app import Flask -from tests.spiffworkflow_backend.helpers.base_test import BaseTest - from spiffworkflow_backend.services.secret_service import SecretService from spiffworkflow_backend.services.service_task_service import ServiceTaskDelegate +from tests.spiffworkflow_backend.helpers.base_test import BaseTest class TestServiceTaskDelegate(BaseTest): diff --git a/tests/spiffworkflow_backend/unit/test_spec_file_service.py b/tests/spiffworkflow_backend/unit/test_spec_file_service.py index fd882e71..fea3f904 100644 --- a/tests/spiffworkflow_backend/unit/test_spec_file_service.py +++ b/tests/spiffworkflow_backend/unit/test_spec_file_service.py @@ -5,11 +5,10 @@ import pytest from flask import Flask from flask_bpmn.api.api_error import ApiError from flask_bpmn.models.db import db +from spiffworkflow_backend.models.bpmn_process_id_lookup import BpmnProcessIdLookup from tests.spiffworkflow_backend.helpers.base_test import BaseTest from tests.spiffworkflow_backend.helpers.test_data import load_test_spec -from spiffworkflow_backend.models.bpmn_process_id_lookup import BpmnProcessIdLookup - class TestSpecFileService(BaseTest): """TestSpecFileService.""" diff --git a/tests/spiffworkflow_backend/unit/test_spiff_logging.py b/tests/spiffworkflow_backend/unit/test_spiff_logging.py index c4a5984f..5a2d5dd6 100644 --- a/tests/spiffworkflow_backend/unit/test_spiff_logging.py +++ b/tests/spiffworkflow_backend/unit/test_spiff_logging.py @@ -3,11 +3,10 @@ from decimal import Decimal from flask.app import Flask from flask_bpmn.models.db import db +from spiffworkflow_backend.models.spiff_logging import SpiffLoggingModel from tests.spiffworkflow_backend.helpers.base_test import BaseTest from tests.spiffworkflow_backend.helpers.test_data import load_test_spec -from spiffworkflow_backend.models.spiff_logging import SpiffLoggingModel - class TestSpiffLogging(BaseTest): """TestSpiffLogging.""" diff --git a/tests/spiffworkflow_backend/unit/test_various_bpmn_constructs.py b/tests/spiffworkflow_backend/unit/test_various_bpmn_constructs.py index c97803d8..46e7b5bb 100644 --- a/tests/spiffworkflow_backend/unit/test_various_bpmn_constructs.py +++ b/tests/spiffworkflow_backend/unit/test_various_bpmn_constructs.py @@ -1,11 +1,10 @@ """Test_various_bpmn_constructs.""" from flask.app import Flask -from tests.spiffworkflow_backend.helpers.base_test import BaseTest -from tests.spiffworkflow_backend.helpers.test_data import load_test_spec - from spiffworkflow_backend.services.process_instance_processor import ( ProcessInstanceProcessor, ) +from tests.spiffworkflow_backend.helpers.base_test import BaseTest +from tests.spiffworkflow_backend.helpers.test_data import load_test_spec class TestVariousBpmnConstructs(BaseTest): diff --git a/tests/test_main.py b/tests/test_main.py index 7917a970..001dbcc6 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -1,7 +1,6 @@ """Test cases for the __main__ module.""" import pytest from click.testing import CliRunner - from spiffworkflow_backend import __main__