jasquat 23f0b12e9a Squashed 'spiffworkflow-backend/' changes from b8924100d..64ac70428
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
2022-11-09 15:02:19 -05:00

54 lines
1.9 KiB
Python

"""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
def assure_process_group_exists(process_group_id: Optional[str] = None) -> ProcessGroup:
"""Assure_process_group_exists."""
process_group = None
process_model_service = ProcessModelService()
if process_group_id is not None:
try:
process_group = process_model_service.get_process_group(process_group_id)
except ProcessEntityNotFoundError:
process_group = None
if process_group is None:
process_group_id_to_create = "test_process_group"
if process_group_id is not None:
process_group_id_to_create = process_group_id
process_group = ProcessGroup(
id=process_group_id_to_create,
display_name="Test Workflows",
admin=False,
display_order=0,
)
process_model_service.add_process_group(process_group)
return process_group
def load_test_spec(
process_model_id: str,
bpmn_file_name: Optional[str] = None,
process_model_source_directory: Optional[str] = None,
) -> ProcessModelInfo:
"""Loads a bpmn file into the process model dir based on a directory in tests/data."""
if process_model_source_directory is None:
raise Exception("You must inclode a `process_model_source_directory`.")
spec = ExampleDataLoader.create_spec(
process_model_id=process_model_id,
display_name=process_model_id,
bpmn_file_name=bpmn_file_name,
process_model_source_directory=process_model_source_directory,
)
return spec