diff --git a/tests/data/get_logging/get_logging.bpmn b/tests/data/get_logging/get_logging.bpmn
new file mode 100644
index 00000000..d67463a2
--- /dev/null
+++ b/tests/data/get_logging/get_logging.bpmn
@@ -0,0 +1,96 @@
+
+
+
+
+ Flow_0d5wpav
+
+
+ Flow_0pc42yp
+ Flow_0n34cdi
+ log_model_info = log(level='info', code='test_code', message='You forgot to include the correct data.')
+log_model_debug = log(level='degug', code='debug_test_code', message='This is my debugging message')
+
+
+ # Logging Models Pre
+{{ logging_models_pre }}
+
+# Log Model
+{{ log_model }}
+
+# Logging Models All Post
+{{ logging_models_all_post }}
+
+
+# Logging Models Info Post
+{{ logging_models_info_post }}
+
+
+# Logging Models Debug Post
+{{ logging_models_debug_post }}
+ Flow_07j4f0v
+ Flow_016ui0e
+
+
+ Flow_016ui0e
+
+
+
+ Flow_0d5wpav
+ Flow_0pc42yp
+ logging_models_pre = get_logs()
+
+
+ Flow_0n34cdi
+ Flow_07j4f0v
+ logging_models_all_post = get_logs()
+logging_models_info_post = get_logs('test_code')
+logging_models_debug_post = get_logs('debug_test_code')
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/data/get_logging_for_study/get_logging_for_study.bpmn b/tests/data/get_logging_for_study/get_logging_for_study.bpmn
new file mode 100644
index 00000000..e3de15e6
--- /dev/null
+++ b/tests/data/get_logging_for_study/get_logging_for_study.bpmn
@@ -0,0 +1,90 @@
+
+
+
+
+ Flow_0bbqksl
+
+
+
+ # Hello
+You may manipulate this in a test, as you see fit
+ Flow_0bbqksl
+ Flow_0lh4lq8
+
+
+
+ Flow_0lh4lq8
+ Flow_10fc3fk
+ some_text = 'variable'
+log('info', 'some_code', 'Some longer message')
+log('info', 'some_other_code', 'Another really long message')
+log('debug', 'debug_code', f'This message has a { some_text }!')
+
+
+
+ Flow_10fc3fk
+ Flow_1dfqchi
+ workflow_logs = get_logs()
+study_logs = get_logs_for_study()
+
+
+
+ # Display Info
+
+## Workflow Logs
+{{ workflow_logs }}
+
+
+## Study Logs
+{{ study_logs }}
+ Flow_1dfqchi
+ Flow_0yxmlin
+
+
+ Flow_0yxmlin
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/scripts/test_task_logging.py b/tests/scripts/test_task_logging.py
index 31879aa8..62f8448a 100644
--- a/tests/scripts/test_task_logging.py
+++ b/tests/scripts/test_task_logging.py
@@ -1,12 +1,17 @@
from tests.base_test import BaseTest
from crc import session
+from crc.models.api_models import Task
from crc.models.task_log import TaskLogModel
+from crc.models.study import StudyModel
+from crc.scripts.log import MyScript
+
+import types
-class TestLoggingScript(BaseTest):
+class TestTaskLogging(BaseTest):
- def test_logging_script(self):
+ def test_add_log(self):
workflow = self.create_workflow('logging_task')
workflow_api = self.get_workflow_api(workflow)
task = workflow_api.next_task
@@ -17,3 +22,66 @@ class TestLoggingScript(BaseTest):
self.assertEqual('test_code', log_model.code)
self.assertEqual('info', log_model.level)
self.assertEqual('Activity_LogEvent', log_model.task)
+
+ def test_get_logs(self):
+ workflow = self.create_workflow('get_logging')
+ workflow_api = self.get_workflow_api(workflow)
+ task = workflow_api.next_task
+
+ self.assertEqual(2, len(task.data['logging_models_all_post']))
+ self.assertEqual(1, len(task.data['logging_models_info_post']))
+ self.assertEqual(1, len(task.data['logging_models_debug_post']))
+ self.assertIn(task.data['logging_models_info_post'][0], task.data['logging_models_all_post'])
+ self.assertIn(task.data['logging_models_debug_post'][0], task.data['logging_models_all_post'])
+ self.assertEqual('test_code', task.data['logging_models_info_post'][0]['code'])
+ self.assertEqual('debug_test_code', task.data['logging_models_debug_post'][0]['code'])
+
+ def test_get_logs_for_study(self):
+ self.load_example_data()
+ study = session.query(StudyModel).first()
+
+ workflow = self.create_workflow('hello_world', study=study)
+ workflow_api = self.get_workflow_api(workflow)
+ task = workflow_api.next_task
+
+ task_model = Task(id=task.id,
+ name=task.name,
+ title=task.title,
+ type=task.type,
+ state=task.state,
+ lane=task.lane,
+ form=task.form,
+ documentation=task.documentation,
+ data=task.data,
+ multi_instance_type=task.multi_instance_type,
+ multi_instance_count=task.multi_instance_count,
+ multi_instance_index=task.multi_instance_index,
+ process_name=task.process_name,
+ properties=task.properties)
+
+ task_model.get_name = types.MethodType(lambda x: x.name, task_model)
+
+ MyScript().do_task(task_model, study.id, workflow.id,
+ level='critical',
+ code='critical_code',
+ message='This is my critical message.')
+
+ MyScript().do_task(task_model, study.id, workflow.id,
+ level='debug',
+ code='debug_code',
+ message='This is my debug message.')
+
+ # This workflow adds 3 logs
+ # some_text = 'variable'
+ # log('info', 'some_code', 'Some longer message')
+ # log('info', 'some_other_code', 'Another really long message')
+ # log('debug', 'debug_code', f'This message has a { some_text }!')
+ workflow = self.create_workflow('get_logging_for_study', study=study)
+ workflow_api = self.get_workflow_api(workflow)
+ task = workflow_api.next_task
+ workflow_api = self.complete_form(workflow, task, {})
+ task = workflow_api.next_task
+ workflow_logs = task.data['workflow_logs']
+ study_logs = task.data['study_logs']
+ self.assertEqual(3, len(workflow_logs))
+ self.assertEqual(5, len(study_logs))