2022-10-12 14:22:22 +00:00
|
|
|
"""Test_logging_service."""
|
|
|
|
from flask.app import Flask
|
|
|
|
from flask.testing import FlaskClient
|
2022-10-20 20:00:12 +00:00
|
|
|
from spiffworkflow_backend.models.user import UserModel
|
2022-10-28 02:03:49 +00:00
|
|
|
from tests.spiffworkflow_backend.helpers.base_test import BaseTest
|
2022-10-20 20:00:12 +00:00
|
|
|
|
2022-10-12 14:22:22 +00:00
|
|
|
|
|
|
|
class TestLoggingService(BaseTest):
|
|
|
|
"""Test logging service."""
|
|
|
|
|
|
|
|
def test_logging_service_spiff_logger(
|
2022-10-20 20:00:12 +00:00
|
|
|
self,
|
|
|
|
app: Flask,
|
|
|
|
client: FlaskClient,
|
|
|
|
with_db_and_bpmn_file_cleanup: None,
|
|
|
|
with_super_admin_user: UserModel,
|
2022-10-12 14:22:22 +00:00
|
|
|
) -> None:
|
|
|
|
"""Test_process_instance_run."""
|
|
|
|
process_group_id = "test_logging_spiff_logger"
|
|
|
|
process_model_id = "simple_script"
|
2022-10-20 20:00:12 +00:00
|
|
|
headers = self.logged_in_headers(with_super_admin_user)
|
2022-10-12 14:22:22 +00:00
|
|
|
response = self.create_process_instance(
|
|
|
|
client, process_group_id, process_model_id, headers
|
|
|
|
)
|
|
|
|
assert response.json is not None
|
|
|
|
process_instance_id = response.json["id"]
|
|
|
|
response = client.post(
|
|
|
|
f"/v1.0/process-models/{process_group_id}/{process_model_id}/process-instances/{process_instance_id}/run",
|
2022-10-20 20:00:12 +00:00
|
|
|
headers=headers,
|
2022-10-12 14:22:22 +00:00
|
|
|
)
|
|
|
|
assert response.status_code == 200
|
|
|
|
|
|
|
|
log_response = client.get(
|
|
|
|
f"/v1.0/process-models/{process_group_id}/{process_model_id}/process-instances/{process_instance_id}/logs",
|
2022-10-20 20:00:12 +00:00
|
|
|
headers=headers,
|
2022-10-12 14:22:22 +00:00
|
|
|
)
|
|
|
|
assert log_response.status_code == 200
|
|
|
|
assert log_response.json
|
|
|
|
logs: list = log_response.json["results"]
|
|
|
|
assert len(logs) > 0
|
|
|
|
for log in logs:
|
|
|
|
assert log["process_instance_id"] == process_instance_id
|
|
|
|
for key in [
|
|
|
|
"timestamp",
|
|
|
|
"spiff_task_guid",
|
|
|
|
"bpmn_task_identifier",
|
|
|
|
"bpmn_process_identifier",
|
|
|
|
"message",
|
|
|
|
]:
|
|
|
|
assert key in log.keys()
|