From 559d9a78d8fdae5e181248a4ac9cd3dee1db8cc5 Mon Sep 17 00:00:00 2001 From: jasquat Date: Tue, 7 Feb 2023 15:02:47 -0500 Subject: [PATCH] renamed development env to local_development and testing to unit_testing w/ burnettk --- .flake8 | 2 +- spiffworkflow-backend/.flake8 | 2 +- .../bin/get_bpmn_json_for_process_instance | 2 +- spiffworkflow-backend/bin/recreate_db | 18 +++++++++--------- spiffworkflow-backend/bin/run_server_locally | 2 +- .../bin/save_to_secrets_from_file | 2 +- spiffworkflow-backend/conftest.py | 2 +- spiffworkflow-backend/docker-compose.yml | 2 +- spiffworkflow-backend/noxfile.py | 2 +- .../src/spiffworkflow_backend/__init__.py | 2 +- .../{development.py => local_development.py} | 2 +- .../{development.yml => local_development.yml} | 0 .../{testing.yml => unit_testing.yml} | 0 .../config/{testing.py => unit_testing.py} | 2 +- .../unit/test_environment_var_script.py | 2 +- 15 files changed, 21 insertions(+), 21 deletions(-) rename spiffworkflow-backend/src/spiffworkflow_backend/config/{development.py => local_development.py} (86%) rename spiffworkflow-backend/src/spiffworkflow_backend/config/permissions/{development.yml => local_development.yml} (100%) rename spiffworkflow-backend/src/spiffworkflow_backend/config/permissions/{testing.yml => unit_testing.yml} (100%) rename spiffworkflow-backend/src/spiffworkflow_backend/config/{testing.py => unit_testing.py} (90%) diff --git a/.flake8 b/.flake8 index 25482610d..9231d3b02 100644 --- a/.flake8 +++ b/.flake8 @@ -32,7 +32,7 @@ per-file-ignores = # the exclude=./migrations option doesn't seem to work with pre-commit # migrations are autogenerated from "flask db migration" so ignore them spiffworkflow-backend/migrations/*:D - spiffworkflow-backend/src/spiffworkflow_backend/config/testing.py:S105 + spiffworkflow-backend/src/spiffworkflow_backend/config/unit_testing.py:S105 spiffworkflow-backend/src/spiffworkflow_backend/load_database_models.py:F401 # this file overwrites methods from the logging library so we can't change them diff --git a/spiffworkflow-backend/.flake8 b/spiffworkflow-backend/.flake8 index 66efd2c7f..456b44229 100644 --- a/spiffworkflow-backend/.flake8 +++ b/spiffworkflow-backend/.flake8 @@ -32,7 +32,7 @@ per-file-ignores = # the exclude=./migrations option doesn't seem to work with pre-commit # migrations are autogenerated from "flask db migration" so ignore them migrations/*:D - src/spiffworkflow_backend/config/testing.py:S105 + src/spiffworkflow_backend/config/unit_testing.py:S105 src/spiffworkflow_backend/load_database_models.py:F401 # this file overwrites methods from the logging library so we can't change them diff --git a/spiffworkflow-backend/bin/get_bpmn_json_for_process_instance b/spiffworkflow-backend/bin/get_bpmn_json_for_process_instance index eaf0a7594..3cfedccc1 100644 --- a/spiffworkflow-backend/bin/get_bpmn_json_for_process_instance +++ b/spiffworkflow-backend/bin/get_bpmn_json_for_process_instance @@ -8,7 +8,7 @@ from spiffworkflow_backend.models.process_instance import ProcessInstanceModel def main(process_instance_id: str): """Main.""" - os.environ["SPIFFWORKFLOW_BACKEND_ENV"] = "development" + os.environ["SPIFFWORKFLOW_BACKEND_ENV"] = "local_development" if os.environ.get("BPMN_SPEC_ABSOLUTE_DIR") is None: os.environ["BPMN_SPEC_ABSOLUTE_DIR"] = "hey" flask_env_key = "FLASK_SESSION_SECRET_KEY" diff --git a/spiffworkflow-backend/bin/recreate_db b/spiffworkflow-backend/bin/recreate_db index ec38c7b39..39a074071 100755 --- a/spiffworkflow-backend/bin/recreate_db +++ b/spiffworkflow-backend/bin/recreate_db @@ -35,8 +35,8 @@ if [[ "${1:-}" == "clean" ]]; then fi rm -f ./src/instance/*.sqlite3 - mysql -uroot -e "DROP DATABASE IF EXISTS spiffworkflow_backend_development" - mysql -uroot -e "DROP DATABASE IF EXISTS spiffworkflow_backend_testing" + mysql -uroot -e "DROP DATABASE IF EXISTS spiffworkflow_backend_local_development" + mysql -uroot -e "DROP DATABASE IF EXISTS spiffworkflow_backend_unit_testing" # TODO: check to see if the db already exists and we can connect to it. also actually clean it up. # start postgres in background with one db @@ -45,23 +45,23 @@ if [[ "${1:-}" == "clean" ]]; then docker run --name postgres-spiff -p 5432:5432 -e POSTGRES_PASSWORD=spiffworkflow_backend -e POSTGRES_USER=spiffworkflow_backend -e POSTGRES_DB=spiffworkflow_backend_testing -d postgres sleep 4 # classy fi - if ! docker exec -it postgres-spiff psql -U spiffworkflow_backend spiffworkflow_backend_development -c "select 1"; then + if ! docker exec -it postgres-spiff psql -U spiffworkflow_backend spiffworkflow_backend_local_development -c "select 1"; then # create other db. spiffworkflow_backend_testing came with the docker run. - docker exec -it postgres-spiff psql -U spiffworkflow_backend spiffworkflow_backend_testing -c "create database spiffworkflow_backend_development;" + docker exec -it postgres-spiff psql -U spiffworkflow_backend spiffworkflow_backend_testing -c "create database spiffworkflow_backend_local_development;" fi fi fi tasks="$tasks upgrade" -mysql -uroot -e "CREATE DATABASE IF NOT EXISTS spiffworkflow_backend_development" -mysql -uroot -e "CREATE DATABASE IF NOT EXISTS spiffworkflow_backend_testing" +mysql -uroot -e "CREATE DATABASE IF NOT EXISTS spiffworkflow_backend_local_development" +mysql -uroot -e "CREATE DATABASE IF NOT EXISTS spiffworkflow_backend_unit_testing" for task in $tasks; do - SPIFFWORKFLOW_BACKEND_ENV=development FLASK_APP=src/spiffworkflow_backend poetry run flask db "$task" + SPIFFWORKFLOW_BACKEND_ENV=local_development FLASK_APP=src/spiffworkflow_backend poetry run flask db "$task" done -SPIFFWORKFLOW_BACKEND_ENV=testing FLASK_APP=src/spiffworkflow_backend poetry run flask db upgrade -if [[ -n "${SPIFFWORKFLOW_BACKEND_ENV:-}" ]] && ! grep -Eq '^(development|testing)$' <<< "$SPIFFWORKFLOW_BACKEND_ENV"; then +SPIFFWORKFLOW_BACKEND_ENV=unit_testing FLASK_APP=src/spiffworkflow_backend poetry run flask db upgrade +if [[ -n "${SPIFFWORKFLOW_BACKEND_ENV:-}" ]] && ! grep -Eq '^(local_development|unit_testing)$' <<< "$SPIFFWORKFLOW_BACKEND_ENV"; then mysql -uroot -e "CREATE DATABASE IF NOT EXISTS spiffworkflow_backend_$SPIFFWORKFLOW_BACKEND_ENV" FLASK_APP=src/spiffworkflow_backend poetry run flask db upgrade fi diff --git a/spiffworkflow-backend/bin/run_server_locally b/spiffworkflow-backend/bin/run_server_locally index 0fa63d218..213a4f396 100755 --- a/spiffworkflow-backend/bin/run_server_locally +++ b/spiffworkflow-backend/bin/run_server_locally @@ -14,7 +14,7 @@ if [[ "$arg" == "acceptance" ]]; then fi if [[ -z "${SPIFFWORKFLOW_BACKEND_ENV:-}" ]]; then - export SPIFFWORKFLOW_BACKEND_ENV=development + export SPIFFWORKFLOW_BACKEND_ENV=local_development fi BPMN_SPEC_ABSOLUTE_DIR=$(./bin/find_sample_process_models) diff --git a/spiffworkflow-backend/bin/save_to_secrets_from_file b/spiffworkflow-backend/bin/save_to_secrets_from_file index ab7ef1733..5a28c66aa 100644 --- a/spiffworkflow-backend/bin/save_to_secrets_from_file +++ b/spiffworkflow-backend/bin/save_to_secrets_from_file @@ -10,7 +10,7 @@ from spiffworkflow_backend.services.secret_service import SecretService def main(env_file: str): """Main.""" - os.environ["SPIFFWORKFLOW_BACKEND_ENV"] = "development" + os.environ["SPIFFWORKFLOW_BACKEND_ENV"] = "local_development" if os.environ.get("BPMN_SPEC_ABSOLUTE_DIR") is None: os.environ["BPMN_SPEC_ABSOLUTE_DIR"] = "hey" flask_env_key = "FLASK_SESSION_SECRET_KEY" diff --git a/spiffworkflow-backend/conftest.py b/spiffworkflow-backend/conftest.py index 448d18569..01fd9e732 100644 --- a/spiffworkflow-backend/conftest.py +++ b/spiffworkflow-backend/conftest.py @@ -37,7 +37,7 @@ from spiffworkflow_backend import create_app # noqa: E402 @pytest.fixture(scope="session") def app() -> Flask: """App.""" - os.environ["SPIFFWORKFLOW_BACKEND_ENV"] = "testing" + os.environ["SPIFFWORKFLOW_BACKEND_ENV"] = "unit_testing" os.environ["FLASK_SESSION_SECRET_KEY"] = "super_secret_key" app = create_app() diff --git a/spiffworkflow-backend/docker-compose.yml b/spiffworkflow-backend/docker-compose.yml index 82e6a1b9c..4ec1028f9 100644 --- a/spiffworkflow-backend/docker-compose.yml +++ b/spiffworkflow-backend/docker-compose.yml @@ -51,7 +51,7 @@ services: context: . environment: - APPLICATION_ROOT=/ - - SPIFFWORKFLOW_BACKEND_ENV=${SPIFFWORKFLOW_BACKEND_ENV:-development} + - SPIFFWORKFLOW_BACKEND_ENV=${SPIFFWORKFLOW_BACKEND_ENV:-local_development} - FLASK_DEBUG=0 - FLASK_SESSION_SECRET_KEY=${FLASK_SESSION_SECRET_KEY:-super_secret_key} - OPEN_ID_SERVER_URL=${OPEN_ID_SERVER_URL:-http://localhost:7002/realms/spiffworkflow} diff --git a/spiffworkflow-backend/noxfile.py b/spiffworkflow-backend/noxfile.py index c3f6dab11..e47f70052 100644 --- a/spiffworkflow-backend/noxfile.py +++ b/spiffworkflow-backend/noxfile.py @@ -42,7 +42,7 @@ def setup_database(session: Session) -> None: flask_env_key = "FLASK_SESSION_SECRET_KEY" session.env[flask_env_key] = "super_secret_key" session.env["FLASK_APP"] = "src/spiffworkflow_backend" - session.env["SPIFFWORKFLOW_BACKEND_ENV"] = "testing" + session.env["SPIFFWORKFLOW_BACKEND_ENV"] = "unit_testing" session.run("flask", "db", "upgrade") diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/__init__.py b/spiffworkflow-backend/src/spiffworkflow_backend/__init__.py index 420f990c0..ba6717d9d 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/__init__.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/__init__.py @@ -142,7 +142,7 @@ def create_app() -> flask.app.Flask: def get_hacked_up_app_for_script() -> flask.app.Flask: """Get_hacked_up_app_for_script.""" - os.environ["SPIFFWORKFLOW_BACKEND_ENV"] = "development" + os.environ["SPIFFWORKFLOW_BACKEND_ENV"] = "local_development" flask_env_key = "FLASK_SESSION_SECRET_KEY" os.environ[flask_env_key] = "whatevs" if "BPMN_SPEC_ABSOLUTE_DIR" not in os.environ: diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/config/development.py b/spiffworkflow-backend/src/spiffworkflow_backend/config/local_development.py similarity index 86% rename from spiffworkflow-backend/src/spiffworkflow_backend/config/development.py rename to spiffworkflow-backend/src/spiffworkflow_backend/config/local_development.py index b1ea980c2..a1129c67e 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/config/development.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/config/local_development.py @@ -2,7 +2,7 @@ from os import environ SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME = environ.get( - "SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME", default="development.yml" + "SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME", default="local_development.yml" ) SPIFFWORKFLOW_BACKEND_LOG_LEVEL = environ.get( diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/config/permissions/development.yml b/spiffworkflow-backend/src/spiffworkflow_backend/config/permissions/local_development.yml similarity index 100% rename from spiffworkflow-backend/src/spiffworkflow_backend/config/permissions/development.yml rename to spiffworkflow-backend/src/spiffworkflow_backend/config/permissions/local_development.yml diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/config/permissions/testing.yml b/spiffworkflow-backend/src/spiffworkflow_backend/config/permissions/unit_testing.yml similarity index 100% rename from spiffworkflow-backend/src/spiffworkflow_backend/config/permissions/testing.yml rename to spiffworkflow-backend/src/spiffworkflow_backend/config/permissions/unit_testing.yml diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/config/testing.py b/spiffworkflow-backend/src/spiffworkflow_backend/config/unit_testing.py similarity index 90% rename from spiffworkflow-backend/src/spiffworkflow_backend/config/testing.py rename to spiffworkflow-backend/src/spiffworkflow_backend/config/unit_testing.py index 605c1bccc..77f123e98 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/config/testing.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/config/unit_testing.py @@ -9,7 +9,7 @@ SPIFFWORKFLOW_BACKEND_LOG_TO_FILE = ( ) SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME = environ.get( - "SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME", default="testing.yml" + "SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME", default="unit_testing.yml" ) SPIFFWORKFLOW_BACKEND_LOG_LEVEL = environ.get( diff --git a/spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_environment_var_script.py b/spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_environment_var_script.py index ac96e7e4d..1d2afd01f 100644 --- a/spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_environment_var_script.py +++ b/spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_environment_var_script.py @@ -20,4 +20,4 @@ class TestEnvironmentVarScript(BaseTest): with app.app_context(): script_engine = ProcessInstanceProcessor._script_engine result = script_engine._evaluate("get_env()", {}) - assert result == "testing" + assert result == "unit_testing"