working on tests

This commit is contained in:
burnettk 2022-11-24 13:01:53 -05:00
parent b761a36d62
commit 444b55a503
5 changed files with 27 additions and 18 deletions

View File

@ -74,8 +74,6 @@ class ProcessModelService(FileSystemService):
def add_process_model(self, process_model: ProcessModelInfo) -> None:
"""Add_spec."""
display_order = self.next_display_order(process_model)
process_model.display_order = display_order
self.save_process_model(process_model)
def update_process_model(
@ -225,7 +223,7 @@ class ProcessModelService(FileSystemService):
def get_process_groups(
cls, process_group_id: Optional[str] = None
) -> list[ProcessGroup]:
"""Returns the process_groups as a list in display order."""
"""Returns the process_groups."""
process_groups = cls.__scan_process_groups(process_group_id)
process_groups.sort()
return process_groups
@ -243,7 +241,7 @@ class ProcessModelService(FileSystemService):
)
)
if cls.is_group(process_group_path):
return self.find_or_create_process_group(
return cls.find_or_create_process_group(
process_group_path,
find_direct_nested_items=find_direct_nested_items,
)
@ -252,22 +250,22 @@ class ProcessModelService(FileSystemService):
"process_group_not_found", f"Process Group Id: {process_group_id}"
)
def add_process_group(self, process_group: ProcessGroup) -> ProcessGroup:
@classmethod
def add_process_group(cls, process_group: ProcessGroup) -> ProcessGroup:
"""Add_process_group."""
display_order = len(self.get_process_groups())
process_group.display_order = display_order
return self.update_process_group(process_group)
return cls.update_process_group(process_group)
def update_process_group(self, process_group: ProcessGroup) -> ProcessGroup:
@classmethod
def update_process_group(cls, process_group: ProcessGroup) -> ProcessGroup:
"""Update_process_group."""
cat_path = self.process_group_path(process_group.id)
cat_path = cls.process_group_path(process_group.id)
os.makedirs(cat_path, exist_ok=True)
json_path = os.path.join(cat_path, self.PROCESS_GROUP_JSON_FILE)
json_path = os.path.join(cat_path, cls.PROCESS_GROUP_JSON_FILE)
serialized_process_group = process_group.serialized
# we don't store `id` in the json files
# this allows us to move groups around on the filesystem
del serialized_process_group["id"]
self.write_json_file(json_path, serialized_process_group)
cls.write_json_file(json_path, serialized_process_group)
return process_group
def process_group_move(

View File

@ -321,7 +321,6 @@ class SpecFileService(FileSystemService):
message_triggerable_process_model = MessageTriggerableProcessModel(
message_model_id=message_model.id,
process_model_identifier=ref.process_model_id,
process_group_identifier="process_group_identifier",
)
db.session.add(message_triggerable_process_model)
db.session.commit()
@ -329,8 +328,6 @@ class SpecFileService(FileSystemService):
if (
message_triggerable_process_model.process_model_identifier
!= ref.process_model_id
# or message_triggerable_process_model.process_group_identifier
# != process_model_info.process_group_id
):
raise ValidationException(
f"Message model is already used to start process model {ref.process_model_id}"

View File

@ -253,7 +253,10 @@ class BaseTest:
There must be an existing process model to instantiate.
"""
if not ProcessModelService.is_model(test_process_model_id):
import pdb; pdb.set_trace()
dirname = os.path.dirname(test_process_model_id)
if not ProcessModelService.is_group(dirname):
process_group = ProcessGroup(id=dirname, display_name=dirname)
ProcessModelService.add_process_group(process_group)
basename = os.path.basename(test_process_model_id)
load_test_spec(
process_model_id=test_process_model_id,

View File

@ -1,13 +1,25 @@
"""Test_acceptance_test_fixtures."""
from flask.app import Flask
import os
from spiffworkflow_backend.models.process_group import ProcessGroup
from spiffworkflow_backend.services.acceptance_test_fixtures import (
load_acceptance_test_fixtures,
)
from spiffworkflow_backend.services.process_model_service import ProcessModelService
def test_start_dates_are_one_hour_apart(app: Flask) -> None:
"""Test_start_dates_are_one_hour_apart."""
process_model_identifier = 'misc/acceptance-tests-group-one/acceptance-tests-model-1'
group_identifier = os.path.dirname(process_model_identifier)
parent_group_identifier = os.path.dirname(group_identifier)
if not ProcessModelService.is_group(parent_group_identifier):
process_group = ProcessGroup(id=parent_group_identifier, display_name=parent_group_identifier)
ProcessModelService.add_process_group(process_group)
if not ProcessModelService.is_group(group_identifier):
process_group = ProcessGroup(id=group_identifier, display_name=group_identifier)
ProcessModelService.add_process_group(process_group)
process_instances = load_acceptance_test_fixtures()
assert len(process_instances) > 2

View File

@ -9,8 +9,7 @@ def test_there_is_at_least_one_group_after_we_create_one(
app: Flask, with_db_and_bpmn_file_cleanup: None
) -> None:
"""Test_there_is_at_least_one_group_after_we_create_one."""
process_model_service = ProcessModelService()
process_group = ProcessGroup(id="hey", display_name="sure")
process_model_service.add_process_group(process_group)
ProcessModelService.add_process_group(process_group)
process_groups = ProcessModelService.get_process_groups()
assert len(process_groups) > 0