From 8145ff9025dcd1267357c954fed495a72a769aa7 Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Fri, 2 Jul 2021 16:14:19 -0400 Subject: [PATCH] Tests for calling the script --- .../check_study_script.bpmn | 53 +++++++++++++++++++ tests/scripts/test_check_study.py | 25 +++++++++ 2 files changed, 78 insertions(+) create mode 100644 tests/data/check_study_script/check_study_script.bpmn create mode 100644 tests/scripts/test_check_study.py diff --git a/tests/data/check_study_script/check_study_script.bpmn b/tests/data/check_study_script/check_study_script.bpmn new file mode 100644 index 00000000..91cfc790 --- /dev/null +++ b/tests/data/check_study_script/check_study_script.bpmn @@ -0,0 +1,53 @@ + + + + + Flow_17nzcku + + + + Flow_17nzcku + Flow_0oozrfg + check_study = check_study() + + + + # Check Study +<div><span>{{check_study}}</span></div> + Flow_0oozrfg + Flow_10sc31i + + + Flow_10sc31i + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/scripts/test_check_study.py b/tests/scripts/test_check_study.py new file mode 100644 index 00000000..e05afbd2 --- /dev/null +++ b/tests/scripts/test_check_study.py @@ -0,0 +1,25 @@ +from tests.base_test import BaseTest +from crc import app +from unittest.mock import patch + + +class TestCheckStudy(BaseTest): + + def test_check_study_script_validation(self): + self.load_example_data() + spec_model = self.load_test_spec('check_study_script') + rv = self.app.get('/v1.0/workflow-specification/%s/validate' % spec_model.id, headers=self.logged_in_headers()) + self.assertEqual([], rv.json) + + @patch('crc.services.protocol_builder.requests.get') + def test_check_study(self, mock_get): + app.config['PB_ENABLED'] = True + app.config['PB_ENABLED'] = True + mock_get.return_value.ok = True + mock_get.return_value.text = self.protocol_builder_response('check_study.json') + workflow = self.create_workflow('check_study_script') + workflow_api = self.get_workflow_api(workflow) + task = workflow_api.next_task + + self.assertIn('DETAIL', task.documentation) + self.assertIn('STATUS', task.documentation)