delete all data in the databases before every test. we may have to control the order better w/ burnettk

This commit is contained in:
jasquat 2022-06-29 11:47:17 -04:00
parent d427fd72d4
commit 5fd85eadda
4 changed files with 38 additions and 33 deletions

View File

@ -5,6 +5,8 @@ from typing import Iterator
import pytest
from flask.app import Flask
from flask_bpmn.models.db import db
from flask_bpmn.models.db import SpiffworkflowBaseDBModel
from spiffworkflow_backend.services.process_model_service import ProcessModelService
@ -39,8 +41,11 @@ def app() -> Flask:
@pytest.fixture()
def with_bpmn_file_cleanup() -> Iterator[None]:
def with_db_and_bpmn_file_cleanup() -> Iterator[None]:
"""Process_group_resource."""
for model in SpiffworkflowBaseDBModel._all_subclasses():
db.session.query(model).delete()
try:
yield
finally:

View File

@ -32,7 +32,7 @@ from SpiffWorkflow.serializer.exceptions import MissingSpecError # type: ignore
from SpiffWorkflow.specs import WorkflowSpec # type: ignore
from SpiffWorkflow.task import Task
from spiffworkflow_backend.models.active_task import ActiveTaskModel # type: ignore
from spiffworkflow_backend.models.active_task import ActiveTaskModel
from spiffworkflow_backend.models.file import File
from spiffworkflow_backend.models.file import FileType
from spiffworkflow_backend.models.principal import PrincipalModel
@ -342,7 +342,7 @@ class ProcessInstanceProcessor:
# FIXME: look for the correct principal based on ready_or_waiting_task.lane
assigned_principal_id=PrincipalModel.query.first().id,
process_instance_data=json.dumps(self.get_data()),
status=ready_or_waiting_task.state.value,
status=ready_or_waiting_task.state.name,
)
db.session.add(active_task)

View File

@ -31,7 +31,7 @@ from spiffworkflow_backend.services.process_model_service import ProcessModelSer
# phase 1: req_id: 7.1 Deploy process
def test_process_model_add(
app: Flask, client: FlaskClient, with_bpmn_file_cleanup: None
app: Flask, client: FlaskClient, with_db_and_bpmn_file_cleanup: None
) -> None:
"""Test_add_new_process_model."""
# group_id = None,
@ -54,7 +54,7 @@ def test_process_model_add(
def test_process_model_delete(
app: Flask, client: FlaskClient, with_bpmn_file_cleanup: None
app: Flask, client: FlaskClient, with_db_and_bpmn_file_cleanup: None
) -> None:
"""Test_process_model_delete."""
create_process_model(client)
@ -80,7 +80,7 @@ def test_process_model_delete(
def test_process_model_delete_with_instances(
app: Flask, client: FlaskClient, with_bpmn_file_cleanup: None
app: Flask, client: FlaskClient, with_db_and_bpmn_file_cleanup: None
) -> None:
"""Test_process_model_delete_with_instances."""
db.session.query(ProcessInstanceModel).delete()
@ -116,7 +116,7 @@ def test_process_model_delete_with_instances(
def test_process_model_update(
app: Flask, client: FlaskClient, with_bpmn_file_cleanup: None
app: Flask, client: FlaskClient, with_db_and_bpmn_file_cleanup: None
) -> None:
"""Test_process_model_update."""
create_process_model(client)
@ -139,7 +139,7 @@ def test_process_model_update(
def test_process_model_list(
app: Flask, client: FlaskClient, with_bpmn_file_cleanup: None
app: Flask, client: FlaskClient, with_db_and_bpmn_file_cleanup: None
) -> None:
"""Test_process_model_list."""
# create a group
@ -218,7 +218,7 @@ def test_process_model_list(
def test_process_group_add(
app: Flask, client: FlaskClient, with_bpmn_file_cleanup: None
app: Flask, client: FlaskClient, with_db_and_bpmn_file_cleanup: None
) -> None:
"""Test_add_process_group."""
process_group = ProcessGroup(
@ -246,7 +246,7 @@ def test_process_group_add(
def test_process_group_delete(
app: Flask, client: FlaskClient, with_bpmn_file_cleanup: None
app: Flask, client: FlaskClient, with_db_and_bpmn_file_cleanup: None
) -> None:
"""Test_process_group_delete."""
process_group_id = "test"
@ -269,7 +269,7 @@ def test_process_group_delete(
def test_process_group_update(
app: Flask, client: FlaskClient, with_bpmn_file_cleanup: None
app: Flask, client: FlaskClient, with_db_and_bpmn_file_cleanup: None
) -> None:
"""Test Process Group Update."""
group_id = "test_process_group"
@ -296,7 +296,7 @@ def test_process_group_update(
def test_process_group_list(
app: Flask, client: FlaskClient, with_bpmn_file_cleanup: None
app: Flask, client: FlaskClient, with_db_and_bpmn_file_cleanup: None
) -> None:
"""Test_process_group_list."""
# add 5 groups
@ -371,7 +371,7 @@ def test_process_group_list(
def test_process_model_file_update_fails_if_no_file_given(
app: Flask, client: FlaskClient, with_bpmn_file_cleanup: None
app: Flask, client: FlaskClient, with_db_and_bpmn_file_cleanup: None
) -> None:
"""Test_process_model_file_update."""
create_spec_file(client)
@ -393,7 +393,7 @@ def test_process_model_file_update_fails_if_no_file_given(
def test_process_model_file_update_fails_if_contents_is_empty(
app: Flask, client: FlaskClient, with_bpmn_file_cleanup: None
app: Flask, client: FlaskClient, with_db_and_bpmn_file_cleanup: None
) -> None:
"""Test_process_model_file_update."""
create_spec_file(client)
@ -415,7 +415,7 @@ def test_process_model_file_update_fails_if_contents_is_empty(
def test_process_model_file_update(
app: Flask, client: FlaskClient, with_bpmn_file_cleanup: None
app: Flask, client: FlaskClient, with_db_and_bpmn_file_cleanup: None
) -> None:
"""Test_process_model_file_update."""
original_file = create_spec_file(client)
@ -447,7 +447,7 @@ def test_process_model_file_update(
def test_get_file(
app: Flask, client: FlaskClient, with_bpmn_file_cleanup: None
app: Flask, client: FlaskClient, with_db_and_bpmn_file_cleanup: None
) -> None:
"""Test_get_file."""
user = find_or_create_user()
@ -466,7 +466,7 @@ def test_get_file(
def dest_get_workflow_from_workflow_spec(
app: Flask, client: FlaskClient, with_bpmn_file_cleanup: None
app: Flask, client: FlaskClient, with_db_and_bpmn_file_cleanup: None
) -> None:
"""Test_get_workflow_from_workflow_spec."""
user = find_or_create_user()
@ -482,7 +482,7 @@ def dest_get_workflow_from_workflow_spec(
def test_get_process_groups_when_none(
app: Flask, client: FlaskClient, with_bpmn_file_cleanup: None
app: Flask, client: FlaskClient, with_db_and_bpmn_file_cleanup: None
) -> None:
"""Test_get_process_groups_when_none."""
user = find_or_create_user()
@ -493,7 +493,7 @@ def test_get_process_groups_when_none(
def test_get_process_groups_when_there_are_some(
app: Flask, client: FlaskClient, with_bpmn_file_cleanup: None
app: Flask, client: FlaskClient, with_db_and_bpmn_file_cleanup: None
) -> None:
"""Test_get_process_groups_when_there_are_some."""
user = find_or_create_user()
@ -508,7 +508,7 @@ def test_get_process_groups_when_there_are_some(
def test_get_process_group_when_found(
app: Flask, client: FlaskClient, with_bpmn_file_cleanup: None
app: Flask, client: FlaskClient, with_db_and_bpmn_file_cleanup: None
) -> None:
"""Test_get_process_group_when_found."""
user = find_or_create_user()
@ -525,7 +525,7 @@ def test_get_process_group_when_found(
def test_get_process_model_when_found(
app: Flask, client: FlaskClient, with_bpmn_file_cleanup: None
app: Flask, client: FlaskClient, with_db_and_bpmn_file_cleanup: None
) -> None:
"""Test_get_process_model_when_found."""
user = find_or_create_user()
@ -544,7 +544,7 @@ def test_get_process_model_when_found(
def test_get_process_model_when_not_found(
app: Flask, client: FlaskClient, with_bpmn_file_cleanup: None
app: Flask, client: FlaskClient, with_db_and_bpmn_file_cleanup: None
) -> None:
"""Test_get_process_model_when_not_found."""
user = find_or_create_user()
@ -560,7 +560,7 @@ def test_get_process_model_when_not_found(
def test_process_instance_create(
app: Flask, client: FlaskClient, with_bpmn_file_cleanup: None
app: Flask, client: FlaskClient, with_db_and_bpmn_file_cleanup: None
) -> None:
"""Test_process_instance_create."""
test_process_group_id = "runs_without_input"
@ -577,7 +577,7 @@ def test_process_instance_create(
def test_process_instance_run(
app: Flask, client: FlaskClient, with_bpmn_file_cleanup: None
app: Flask, client: FlaskClient, with_db_and_bpmn_file_cleanup: None
) -> None:
"""Test_process_instance_run."""
process_group_id = "runs_without_input"
@ -605,7 +605,7 @@ def test_process_instance_run(
def test_process_instance_list_with_default_list(
app: Flask, client: FlaskClient, with_bpmn_file_cleanup: None
app: Flask, client: FlaskClient, with_db_and_bpmn_file_cleanup: None
) -> None:
"""Test_process_instance_list_with_default_list."""
db.session.query(ProcessInstanceModel).delete()
@ -641,7 +641,7 @@ def test_process_instance_list_with_default_list(
def test_process_instance_list_with_paginated_items(
app: Flask, client: FlaskClient, with_bpmn_file_cleanup: None
app: Flask, client: FlaskClient, with_db_and_bpmn_file_cleanup: None
) -> None:
"""Test_process_instance_list_with_paginated_items."""
db.session.query(ProcessInstanceModel).delete()
@ -691,7 +691,7 @@ def test_process_instance_list_with_paginated_items(
def test_process_instance_list_filter(
app: Flask, client: FlaskClient, with_bpmn_file_cleanup: None
app: Flask, client: FlaskClient, with_db_and_bpmn_file_cleanup: None
) -> None:
"""Test_process_instance_list_filter."""
db.session.query(ProcessInstanceModel).delete()
@ -786,7 +786,7 @@ def test_process_instance_list_filter(
def test_process_instance_report_with_default_list(
app: Flask, client: FlaskClient, with_bpmn_file_cleanup: None
app: Flask, client: FlaskClient, with_db_and_bpmn_file_cleanup: None
) -> None:
"""Test_process_instance_report_with_default_list."""
db.session.query(ProcessInstanceModel).delete()
@ -836,7 +836,7 @@ def setup_testing_instance(
def test_error_handler(
app: Flask, client: FlaskClient, with_bpmn_file_cleanup: None
app: Flask, client: FlaskClient, with_db_and_bpmn_file_cleanup: None
) -> None:
"""Test_error_handler."""
db.session.query(ProcessInstanceModel).delete()
@ -882,7 +882,7 @@ def test_error_handler(
def test_error_handler_suspend(
app: Flask, client: FlaskClient, with_bpmn_file_cleanup: None
app: Flask, client: FlaskClient, with_db_and_bpmn_file_cleanup: None
) -> None:
"""Test_error_handler_suspend."""
db.session.query(ProcessInstanceModel).delete()
@ -923,7 +923,7 @@ def test_error_handler_suspend(
def test_error_handler_with_email(
app: Flask, client: FlaskClient, with_bpmn_file_cleanup: None
app: Flask, client: FlaskClient, with_db_and_bpmn_file_cleanup: None
) -> None:
"""Test_error_handler."""
db.session.query(ProcessInstanceModel).delete()
@ -971,7 +971,7 @@ def test_error_handler_with_email(
def test_process_model_file_create(
app: Flask, client: FlaskClient, with_bpmn_file_cleanup: None
app: Flask, client: FlaskClient, with_db_and_bpmn_file_cleanup: None
) -> None:
"""Test_process_model_file_create."""
process_group_id = "hello_world"

View File

@ -6,7 +6,7 @@ from spiffworkflow_backend.services.process_model_service import ProcessModelSer
def test_there_is_at_least_one_group_after_we_create_one(
app: Flask, with_bpmn_file_cleanup: None
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()