mirror of
https://github.com/sartography/cr-connect-workflow.git
synced 2025-02-23 21:28:32 +00:00
Added a File class, that we wrap around the FileModel so the api endpoints don't change, but File no longer holds refences to versions or dates of the file_data model, we figure this out based on a clean database structure. The ApprovalFile is directly related to the file_data_model - so no chance that a reviewer would review the incorrect version of a file.py Noticed that our FileType enum called "bpmn" "bpmm", hope this doesn't screw someone up. Workflows are directly related to the data_models that create the workflow spec it needs. So the files should always be there. There are no more hashes, and thus no more hash errors where it can't find the files to rebuild the workflow.py Not much to report here, other than I broke every single test in the system at one point. So I'm super concerned about this, and will be testing it a lot before creating the pull request.
53 lines
2.2 KiB
Python
53 lines
2.2 KiB
Python
from crc.services.file_service import FileService
|
|
from tests.base_test import BaseTest
|
|
|
|
from crc.scripts.request_approval import RequestApproval
|
|
from crc.services.workflow_processor import WorkflowProcessor
|
|
from crc.api.common import ApiError
|
|
|
|
from crc import db
|
|
from crc.models.approval import ApprovalModel
|
|
|
|
|
|
class TestRequestApprovalScript(BaseTest):
|
|
|
|
def test_do_task(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':'lb3dp'}}
|
|
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(2, 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()
|
|
self.create_reference_document()
|
|
workflow = self.create_workflow('empty_workflow')
|
|
processor = WorkflowProcessor(workflow)
|
|
task = processor.next_task()
|
|
task.data = {"approvals": {'dhf8r':["invalid"], 'lb3dp':"invalid"}}
|
|
script = RequestApproval()
|
|
with self.assertRaises(ApiError):
|
|
script.do_task(task, workflow.study_id, workflow.id, "approvals")
|
|
|
|
def test_do_task_validate_only(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':'lb3dp'}}
|
|
|
|
script = RequestApproval()
|
|
script.do_task_validate_only(task, workflow.study_id, workflow.id, "study.approval1")
|
|
self.assertEquals(0, db.session.query(ApprovalModel).count())
|
|
|