jasquat 64e7049c9a Squashed 'spiffworkflow-backend/' changes from ffb6d366..d0336039
d0336039 added api endpoint to get the auth list from connector proxy w/ burnettk
ca13f0ca Merge pull request #142 from sartography/bugfix/clean_up_non_existant_workflow_types_and_libraries
304ee66b lint
935c883b migration.
1f99264c Remove all references to the MasterWorkflow, standalone workflows, and libraries, as these concepts should no longer exist.
a7a83a97 Merge branch 'main' of github.com:sartography/spiffworkflow-backend
6ce1cdb0 updated flask-bpmn for new ApiError. w/ burnettk
796735e8 Merge pull request #141 from sartography/bugfix/allow-strptime-in-scripts
5e13a239 Remove the "master_spec"
7e52204f fix bs issue
8cc59eb3 add strptime to script engine

git-subtree-dir: spiffworkflow-backend
git-subtree-split: d0336039c556bf5f19f8db2f32d9b37228e9f057
2022-10-18 16:41:10 -04:00

107 lines
4.1 KiB
Python

"""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,
)
class TestProcessModel(BaseTest):
"""TestProcessModel."""
def test_initializes_files_as_empty_array(self) -> None:
"""Test_initializes_files_as_empty_array."""
process_model_one = self.create_test_process_model(
id="model_one", display_name="Model One"
)
assert process_model_one.files == []
def test_can_run_process_model_with_call_activities_when_in_same_process_model_directory(
self, app: Flask, with_db_and_bpmn_file_cleanup: None
) -> None:
"""Test_can_run_process_model_with_call_activities."""
process_model = load_test_spec(
"call_activity_test",
process_model_source_directory="call_activity_same_directory",
)
process_instance = self.create_process_instance_from_process_model(
process_model
)
processor = ProcessInstanceProcessor(process_instance)
processor.do_engine_steps(save=True)
assert process_instance.status == "complete"
def test_can_run_process_model_with_call_activities_when_not_in_same_directory(
self, app: Flask, with_db_and_bpmn_file_cleanup: None
) -> None:
"""Test_can_run_process_model_with_call_activities."""
process_model = load_test_spec(
"call_activity_nested",
process_model_source_directory="call_activity_nested",
bpmn_file_name="call_activity_nested",
)
bpmn_file_names = [
"call_activity_level_2b",
"call_activity_level_2",
"call_activity_level_3",
]
for bpmn_file_name in bpmn_file_names:
load_test_spec(
bpmn_file_name,
process_model_source_directory="call_activity_nested",
bpmn_file_name=bpmn_file_name,
)
process_instance = self.create_process_instance_from_process_model(
process_model
)
processor = ProcessInstanceProcessor(process_instance)
processor.do_engine_steps(save=True)
assert process_instance.status == "complete"
def test_can_run_process_model_with_call_activities_when_process_identifier_is_not_in_database(
self, app: Flask, with_db_and_bpmn_file_cleanup: None
) -> None:
"""Test_can_run_process_model_with_call_activities."""
process_model = load_test_spec(
"call_activity_nested",
process_model_source_directory="call_activity_nested",
bpmn_file_name="call_activity_nested",
)
bpmn_file_names = [
"call_activity_level_2b",
"call_activity_level_2",
"call_activity_level_3",
]
for bpmn_file_name in bpmn_file_names:
load_test_spec(
bpmn_file_name,
process_model_source_directory="call_activity_nested",
bpmn_file_name=bpmn_file_name,
)
process_instance = self.create_process_instance_from_process_model(
process_model
)
# delete all of the id lookup items to force to processor to find the correct
# process model when running the process
db.session.query(BpmnProcessIdLookup).delete()
processor = ProcessInstanceProcessor(process_instance)
processor.do_engine_steps(save=True)
assert process_instance.status == "complete"
def create_test_process_model(self, id: str, display_name: str) -> ProcessModelInfo:
"""Create_test_process_model."""
return ProcessModelInfo(
id=id,
display_name=display_name,
description=display_name,
)