This commit is contained in:
burnettk 2023-03-16 22:59:42 -04:00
parent c4acbab343
commit 6bfce59fe3
3 changed files with 21 additions and 18 deletions

View File

@ -1,7 +1,5 @@
"""APIs for dealing with process groups, process models, and process instances.""" """APIs for dealing with process groups, process models, and process instances."""
import base64 import base64
from spiffworkflow_backend.models.bpmn_process_definition import BpmnProcessDefinitionModel
from spiffworkflow_backend.models.task_definition import TaskDefinitionModel
import json import json
from typing import Any from typing import Any
from typing import Dict from typing import Dict
@ -21,6 +19,7 @@ from sqlalchemy import and_
from sqlalchemy import or_ from sqlalchemy import or_
from spiffworkflow_backend.exceptions.api_error import ApiError from spiffworkflow_backend.exceptions.api_error import ApiError
from spiffworkflow_backend.models.bpmn_process_definition import BpmnProcessDefinitionModel
from spiffworkflow_backend.models.db import db from spiffworkflow_backend.models.db import db
from spiffworkflow_backend.models.human_task import HumanTaskModel from spiffworkflow_backend.models.human_task import HumanTaskModel
from spiffworkflow_backend.models.human_task_user import HumanTaskUserModel from spiffworkflow_backend.models.human_task_user import HumanTaskUserModel
@ -46,6 +45,7 @@ from spiffworkflow_backend.models.spiff_logging import SpiffLoggingModel
from spiffworkflow_backend.models.spiff_step_details import SpiffStepDetailsModel from spiffworkflow_backend.models.spiff_step_details import SpiffStepDetailsModel
from spiffworkflow_backend.models.task import Task from spiffworkflow_backend.models.task import Task
from spiffworkflow_backend.models.task import TaskModel from spiffworkflow_backend.models.task import TaskModel
from spiffworkflow_backend.models.task_definition import TaskDefinitionModel
from spiffworkflow_backend.models.user import UserModel from spiffworkflow_backend.models.user import UserModel
from spiffworkflow_backend.routes.process_api_blueprint import ( from spiffworkflow_backend.routes.process_api_blueprint import (
_find_process_instance_by_id_or_raise, _find_process_instance_by_id_or_raise,
@ -239,14 +239,16 @@ def process_instance_log_list(
logs = ( logs = (
log_query.order_by(TaskModel.end_in_seconds.desc()) # type: ignore log_query.order_by(TaskModel.end_in_seconds.desc()) # type: ignore
.join(TaskDefinitionModel, TaskDefinitionModel.id == TaskModel.task_definition_id) .join(TaskDefinitionModel, TaskDefinitionModel.id == TaskModel.task_definition_id)
.join(BpmnProcessDefinitionModel, BpmnProcessDefinitionModel.id == TaskDefinitionModel.bpmn_process_definition_id) .join(
BpmnProcessDefinitionModel, BpmnProcessDefinitionModel.id == TaskDefinitionModel.bpmn_process_definition_id
)
.outerjoin(HumanTaskModel, HumanTaskModel.task_model_id == TaskModel.id) .outerjoin(HumanTaskModel, HumanTaskModel.task_model_id == TaskModel.id)
.outerjoin(UserModel, UserModel.id == HumanTaskModel.completed_by_user_id) .outerjoin(UserModel, UserModel.id == HumanTaskModel.completed_by_user_id)
.add_columns( .add_columns(
TaskModel.guid.label('spiff_task_guid'), TaskModel.guid.label("spiff_task_guid"), # type: ignore
UserModel.username, UserModel.username,
BpmnProcessDefinitionModel.bpmn_identifier.label('bpmn_process_definition_identifier'), BpmnProcessDefinitionModel.bpmn_identifier.label("bpmn_process_definition_identifier"), # type: ignore
TaskDefinitionModel.bpmn_identifier.label('task_definition_identifier'), TaskDefinitionModel.bpmn_identifier.label("task_definition_identifier"), # type: ignore
) )
.paginate(page=page, per_page=per_page, error_out=False) .paginate(page=page, per_page=per_page, error_out=False)
) )

View File

@ -1,17 +1,17 @@
"""Test_logging_service.""" """Test_logging_service."""
from flask.app import Flask from flask.app import Flask
from tests.spiffworkflow_backend.helpers.test_data import load_test_spec
from spiffworkflow_backend.services.authorization_service import AuthorizationService
from flask.testing import FlaskClient from flask.testing import FlaskClient
from tests.spiffworkflow_backend.helpers.base_test import BaseTest from tests.spiffworkflow_backend.helpers.base_test import BaseTest
from tests.spiffworkflow_backend.helpers.test_data import load_test_spec
from spiffworkflow_backend.models.user import UserModel from spiffworkflow_backend.models.user import UserModel
from spiffworkflow_backend.services.process_instance_service import ( from spiffworkflow_backend.services.authorization_service import AuthorizationService
ProcessInstanceService,
)
from spiffworkflow_backend.services.process_instance_processor import ( from spiffworkflow_backend.services.process_instance_processor import (
ProcessInstanceProcessor, ProcessInstanceProcessor,
) )
from spiffworkflow_backend.services.process_instance_service import (
ProcessInstanceService,
)
class TestLoggingService(BaseTest): class TestLoggingService(BaseTest):
@ -71,5 +71,5 @@ class TestLoggingService(BaseTest):
]: ]:
assert key in log.keys() assert key in log.keys()
if log['task_definition_identifier'] == 'Activity_SimpleForm': if log["task_definition_identifier"] == "Activity_SimpleForm":
assert log['username'] == initiator_user.username assert log["username"] == initiator_user.username

View File

@ -1,7 +1,5 @@
"""Test_process_instance_processor.""" """Test_process_instance_processor."""
from uuid import UUID from uuid import UUID
from spiffworkflow_backend.models import bpmn_process_definition
from spiffworkflow_backend.models.bpmn_process import BpmnProcessModel
import pytest import pytest
from flask import g from flask import g
@ -12,6 +10,7 @@ from tests.spiffworkflow_backend.helpers.base_test import BaseTest
from tests.spiffworkflow_backend.helpers.test_data import load_test_spec from tests.spiffworkflow_backend.helpers.test_data import load_test_spec
from spiffworkflow_backend.exceptions.api_error import ApiError from spiffworkflow_backend.exceptions.api_error import ApiError
from spiffworkflow_backend.models.bpmn_process import BpmnProcessModel
from spiffworkflow_backend.models.group import GroupModel from spiffworkflow_backend.models.group import GroupModel
from spiffworkflow_backend.models.process_instance import ProcessInstanceModel from spiffworkflow_backend.models.process_instance import ProcessInstanceModel
from spiffworkflow_backend.models.process_instance import ProcessInstanceStatus from spiffworkflow_backend.models.process_instance import ProcessInstanceStatus
@ -351,7 +350,9 @@ class TestProcessInstanceProcessor(BaseTest):
task_definition = task_model.task_definition task_definition = task_model.task_definition
assert task_definition.bpmn_identifier == spiff_task_name assert task_definition.bpmn_identifier == spiff_task_name
assert task_definition.bpmn_process_definition.bpmn_identifier == bpmn_process_identifier assert task_definition.bpmn_process_definition.bpmn_identifier == bpmn_process_identifier
message = f"{base_failure_message} Expected: {expected_python_env_data}. Received: {task_model.json_data()}" message = (
f"{base_failure_message} Expected: {expected_python_env_data}. Received: {task_model.json_data()}"
)
# TODO: if we split out env data again we will need to use it here instead of json_data # TODO: if we split out env data again we will need to use it here instead of json_data
# assert task_model.python_env_data() == expected_python_env_data, message # assert task_model.python_env_data() == expected_python_env_data, message
assert task_model.json_data() == expected_python_env_data, message assert task_model.json_data() == expected_python_env_data, message
@ -365,13 +366,13 @@ class TestProcessInstanceProcessor(BaseTest):
assert_spiff_task_is_in_process("top_level_subprocess_script", "top_level_subprocess") assert_spiff_task_is_in_process("top_level_subprocess_script", "top_level_subprocess")
assert_spiff_task_is_in_process("top_level_script", "top_level_process") assert_spiff_task_is_in_process("top_level_script", "top_level_process")
if spiff_task.task_spec.name == 'top_level_call_activity': if spiff_task.task_spec.name == "top_level_call_activity":
# the task id / guid of the call activity gets used as the guid of the bpmn process that it calls # the task id / guid of the call activity gets used as the guid of the bpmn process that it calls
bpmn_process = BpmnProcessModel.query.filter_by(guid=str(spiff_task.id)).first() bpmn_process = BpmnProcessModel.query.filter_by(guid=str(spiff_task.id)).first()
assert bpmn_process is not None assert bpmn_process is not None
bpmn_process_definition = bpmn_process.bpmn_process_definition bpmn_process_definition = bpmn_process.bpmn_process_definition
assert bpmn_process_definition is not None assert bpmn_process_definition is not None
assert bpmn_process_definition.bpmn_identifier == 'test_process_to_call' assert bpmn_process_definition.bpmn_identifier == "test_process_to_call"
assert processor.get_data() == fifth_data_set assert processor.get_data() == fifth_data_set