mirror of
https://github.com/status-im/spiff-arena.git
synced 2025-01-14 20:24:34 +00:00
23f0b12e9a
64ac70428 Move to Python 3.11 (#27) 167851df1 remove leading slash from model identifiers 3503fe400 one instance test left for cypress w/ burnettk 7e09363c4 merged in main and resolved conflicts w/ burnettk cullerton afbc3157d fixed some acceptance tests w/ burnettk cullerton 96e7b63c6 made a process model form w/ burnettk c19aac25f Somethings up w/authentication. Maybe the stored token is bad d17007eaa Merge branch 'main' into feature/nested-groups 729b13881 script to modify all model json files to use full path for model id. Also removes process_group_id 7856b8caa return next task when running an instance w/ burnettk d183b961c First pass at custom report/perspective for Process Instance List (#23) f303c0f77 remove process_group_identifier from process-instances endpoint 207de9ab8 Merge branch 'main' into feature/nested-groups fec8d06b8 started test for test_script_unit_test_run ea31c7a12 fixed process_model_identifier in script_unit_test_create 5d058cbea Fix url in test f8afd7bdd Remove the `_2` methods 7c13ec802 Fix urls for uspend and resume endpoints 19158d7b0 Get testing bpmn files out of the config directory 5f1ee7f16 fixed failing test de3b4b81d Merge branch 'main' into feature/nested-groups 440871d57 First stab at nested folders. Added temp endpoints Changes to tests and test helpers 1bd6a199f Don't need parent. Just use the whole path for the group id a2ab420b2 Committing so Jon can view code git-subtree-dir: spiffworkflow-backend git-subtree-split: 64ac7042887af80869963bc103c01f56404727f2
128 lines
3.9 KiB
Python
128 lines
3.9 KiB
Python
"""Conftest."""
|
|
import os
|
|
import shutil
|
|
|
|
import pytest
|
|
from flask.app import Flask
|
|
from flask.testing import FlaskClient
|
|
from flask_bpmn.models.db import db
|
|
from flask_bpmn.models.db import SpiffworkflowBaseDBModel
|
|
from tests.spiffworkflow_backend.helpers.base_test import BaseTest
|
|
|
|
from spiffworkflow_backend.models.active_task_user import ActiveTaskUserModel
|
|
from spiffworkflow_backend.models.process_instance import ProcessInstanceModel
|
|
from spiffworkflow_backend.models.user import UserModel
|
|
from spiffworkflow_backend.services.process_instance_processor import (
|
|
ProcessInstanceProcessor,
|
|
)
|
|
from spiffworkflow_backend.services.process_instance_service import (
|
|
ProcessInstanceService,
|
|
)
|
|
from spiffworkflow_backend.services.process_model_service import ProcessModelService
|
|
|
|
# from tests.spiffworkflow_backend.helpers.test_data import load_test_spec
|
|
|
|
|
|
# We need to call this before importing spiffworkflow_backend
|
|
# otherwise typeguard cannot work. hence the noqa: E402
|
|
if os.environ.get("RUN_TYPEGUARD") == "true":
|
|
from typeguard.importhook import install_import_hook
|
|
|
|
install_import_hook(packages="spiffworkflow_backend")
|
|
|
|
|
|
from spiffworkflow_backend import create_app # noqa: E402
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def app() -> Flask:
|
|
"""App."""
|
|
os.environ["SPIFFWORKFLOW_BACKEND_ENV"] = "testing"
|
|
os.environ["FLASK_SESSION_SECRET_KEY"] = "super_secret_key"
|
|
app = create_app()
|
|
|
|
return app
|
|
|
|
|
|
@pytest.fixture()
|
|
def with_db_and_bpmn_file_cleanup() -> None:
|
|
"""Process_group_resource."""
|
|
db.session.query(ActiveTaskUserModel).delete()
|
|
|
|
for model in SpiffworkflowBaseDBModel._all_subclasses():
|
|
db.session.query(model).delete()
|
|
db.session.commit()
|
|
|
|
try:
|
|
yield
|
|
finally:
|
|
process_model_service = ProcessModelService()
|
|
if os.path.exists(process_model_service.root_path()):
|
|
shutil.rmtree(process_model_service.root_path())
|
|
|
|
|
|
@pytest.fixture()
|
|
def with_super_admin_user() -> UserModel:
|
|
"""With_super_admin_user."""
|
|
return BaseTest.create_user_with_permission("super_admin")
|
|
|
|
|
|
@pytest.fixture()
|
|
def setup_process_instances_for_reports(
|
|
client: FlaskClient, with_super_admin_user: UserModel
|
|
) -> list[ProcessInstanceModel]:
|
|
"""Setup_process_instances_for_reports."""
|
|
user = with_super_admin_user
|
|
process_group_id = "runs_without_input"
|
|
process_model_id = "sample"
|
|
# bpmn_file_name = "sample.bpmn"
|
|
bpmn_file_location = "sample"
|
|
process_model_identifier = BaseTest().basic_test_setup(
|
|
client,
|
|
with_super_admin_user,
|
|
process_group_id=process_group_id,
|
|
process_model_id=process_model_id,
|
|
# bpmn_file_name=bpmn_file_name,
|
|
bpmn_file_location=bpmn_file_location,
|
|
)
|
|
|
|
# BaseTest().create_process_group(
|
|
# client=client, user=user, process_group_id=process_group_id, display_name=process_group_id
|
|
# )
|
|
# process_model_id = "runs_without_input/sample"
|
|
# load_test_spec(
|
|
# process_model_id=f"{process_group_id}/{process_model_id}",
|
|
# process_model_source_directory="sample"
|
|
# )
|
|
process_instances = []
|
|
for data in [kay(), ray(), jay()]:
|
|
process_instance = ProcessInstanceService.create_process_instance(
|
|
# process_group_identifier=process_group_id,
|
|
process_model_identifier=process_model_identifier,
|
|
user=user,
|
|
)
|
|
processor = ProcessInstanceProcessor(process_instance)
|
|
processor.slam_in_data(data)
|
|
process_instance.status = "complete"
|
|
db.session.add(process_instance)
|
|
db.session.commit()
|
|
|
|
process_instances.append(process_instance)
|
|
|
|
return process_instances
|
|
|
|
|
|
def kay() -> dict:
|
|
"""Kay."""
|
|
return {"name": "kay", "grade_level": 2, "test_score": 10}
|
|
|
|
|
|
def ray() -> dict:
|
|
"""Ray."""
|
|
return {"name": "ray", "grade_level": 1, "test_score": 9}
|
|
|
|
|
|
def jay() -> dict:
|
|
"""Jay."""
|
|
return {"name": "jay", "grade_level": 2, "test_score": 8}
|