diff --git a/crc/scripts/request_approval.py b/crc/scripts/request_approval.py index 1df1a670..1e5d2c6c 100644 --- a/crc/scripts/request_approval.py +++ b/crc/scripts/request_approval.py @@ -26,7 +26,8 @@ RequestApproval approver1 "dhf8r" ApprovalService.add_approval(study_id, workflow_id, args) elif isinstance(uids, list): for id in uids: - ApprovalService.add_approval(study_id, workflow_id, id) + if id: ## Assure it's not empty or null + ApprovalService.add_approval(study_id, workflow_id, id) def get_uids(self, task, args): if len(args) < 1: diff --git a/tests/test_request_approval_script.py b/tests/test_request_approval_script.py index 2f4ab49e..8cd56807 100644 --- a/tests/test_request_approval_script.py +++ b/tests/test_request_approval_script.py @@ -1,6 +1,6 @@ -from crc.services.file_service import FileService from tests.base_test import BaseTest +from crc.services.file_service import FileService from crc.scripts.request_approval import RequestApproval from crc.services.workflow_processor import WorkflowProcessor from crc.api.common import ApiError @@ -26,6 +26,22 @@ class TestRequestApprovalScript(BaseTest): script.do_task(task, workflow.study_id, workflow.id, "study.approval1", "study.approval2") self.assertEquals(2, db.session.query(ApprovalModel).count()) + def test_do_task_with_blank_second_approver(self): + self.load_example_data() + self.create_reference_document() + workflow = self.create_workflow('empty_workflow') + processor = WorkflowProcessor(workflow) + task = processor.next_task() + task.data = {"study": {"approval1": "dhf8r", 'approval2':''}} + FileService.add_workflow_file(workflow_id=workflow.id, + irb_doc_code="UVACompl_PRCAppr", + name="anything.png", content_type="text", + binary_data=b'1234') + script = RequestApproval() + script.do_task(task, workflow.study_id, workflow.id, "study.approval1", "study.approval2") + self.assertEquals(1, db.session.query(ApprovalModel).count()) + + def test_do_task_with_incorrect_argument(self): """This script should raise an error if it can't figure out the approvers.""" self.load_example_data()