From 9c0a8cc9dfd2701f16edd63124f2b4ecb5ded165 Mon Sep 17 00:00:00 2001 From: jasquat Date: Wed, 24 May 2023 11:10:40 -0400 Subject: [PATCH] only test admin permissions in ci since it takes longer run w/ burnettk --- .github/workflows/backend_tests.yml | 1 + spiffworkflow-backend/conftest.py | 17 ++++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/backend_tests.yml b/.github/workflows/backend_tests.yml index 24ff8838..c164e0da 100644 --- a/.github/workflows/backend_tests.yml +++ b/.github/workflows/backend_tests.yml @@ -84,6 +84,7 @@ jobs: PRE_COMMIT_COLOR: "always" SPIFFWORKFLOW_BACKEND_DATABASE_PASSWORD: password SPIFFWORKFLOW_BACKEND_DATABASE_TYPE: ${{ matrix.database }} + SPIFFWORKFLOW_BACKEND_RUNNING_IN_CI: 'true' steps: - name: Check out the repository diff --git a/spiffworkflow-backend/conftest.py b/spiffworkflow-backend/conftest.py index 2cd60296..a6be6423 100644 --- a/spiffworkflow-backend/conftest.py +++ b/spiffworkflow-backend/conftest.py @@ -1,4 +1,4 @@ -"""Conftest.""" +# noqa import os import shutil @@ -25,8 +25,7 @@ from spiffworkflow_backend import create_app # noqa: E402 @pytest.fixture(scope="session") -def app() -> Flask: - """App.""" +def app() -> Flask: # noqa os.environ["SPIFFWORKFLOW_BACKEND_ENV"] = "unit_testing" os.environ["FLASK_SESSION_SECRET_KEY"] = "e7711a3ba96c46c68e084a86952de16f" app = create_app() @@ -53,8 +52,12 @@ def with_db_and_bpmn_file_cleanup() -> None: @pytest.fixture() -def with_super_admin_user() -> UserModel: - """With_super_admin_user.""" - user = BaseTest.find_or_create_user(username="testadmin1") - AuthorizationService.import_permissions_from_yaml_file(user) +def with_super_admin_user() -> UserModel: # noqa + # this loads all permissions from yaml everytime this function is called which is slow + # so default to just setting a simple super admin and only run with the "real" permissions in ci + if os.environ.get("SPIFFWORKFLOW_BACKEND_RUNNING_IN_CI") == "true": + user = BaseTest.find_or_create_user(username="testadmin1") + AuthorizationService.import_permissions_from_yaml_file(user) + else: + user = BaseTest.create_user_with_permission("super_admin") return user