mirror of
https://github.com/sartography/cr-connect-workflow.git
synced 2025-02-22 20:58:28 +00:00
Added tests for failing conditions
This commit is contained in:
parent
c6b1fd4e52
commit
33cef2bd2a
@ -1,7 +1,7 @@
|
||||
from tests.base_test import BaseTest
|
||||
from crc.api.common import ApiError
|
||||
from crc.services.file_service import FileService
|
||||
from crc.scripts.is_file_uploaded import IsFileUploaded
|
||||
import io
|
||||
|
||||
|
||||
class TestDeleteIRBDocument(BaseTest):
|
||||
@ -16,6 +16,7 @@ class TestDeleteIRBDocument(BaseTest):
|
||||
workflow_api = self.get_workflow_api(workflow)
|
||||
first_task = workflow_api.next_task
|
||||
|
||||
# Should not have any files yet
|
||||
files = FileService.get_files_for_study(study_id)
|
||||
self.assertEqual(0, len(files))
|
||||
self.assertEqual(False, IsFileUploaded.do_task(IsFileUploaded, first_task, study_id, workflow.id, irb_code))
|
||||
@ -24,16 +25,57 @@ class TestDeleteIRBDocument(BaseTest):
|
||||
FileService.add_workflow_file(workflow_id=workflow.id,
|
||||
name="filename.txt", content_type="text",
|
||||
binary_data=b'1234', irb_doc_code=irb_code)
|
||||
# Assert we have the file
|
||||
self.assertEqual(True, IsFileUploaded.do_task(IsFileUploaded, first_task, study_id, workflow.id, irb_code))
|
||||
|
||||
# The workflow checks whether the file is uploaded,
|
||||
# and prints the result in documentation
|
||||
self.complete_form(workflow, first_task, {'irb_document': irb_code})
|
||||
workflow_api = self.get_workflow_api(workflow)
|
||||
second_task = workflow_api.next_task
|
||||
self.assertEqual('# Is file uploaded\nuploaded: True', second_task.documentation)
|
||||
|
||||
# It then deletes the file, checks if file is deleted,
|
||||
# and prints the result in documentation
|
||||
self.complete_form(workflow, second_task, {})
|
||||
workflow_api = self.get_workflow_api(workflow)
|
||||
third_task = workflow_api.next_task
|
||||
self.assertEqual('# Is file deleted\ndeleted: True', third_task.documentation)
|
||||
|
||||
print('test_delete_irb_document')
|
||||
def test_delete_irb_document_no_document(self):
|
||||
self.load_example_data()
|
||||
irb_code = 'Study_Protocol_Document'
|
||||
|
||||
workflow = self.create_workflow('add_delete_irb_document')
|
||||
|
||||
workflow_api = self.get_workflow_api(workflow)
|
||||
first_task = workflow_api.next_task
|
||||
|
||||
# The workflow checks whether the file is uploaded,
|
||||
# and prints the result in documentation
|
||||
self.complete_form(workflow, first_task, {'irb_document': irb_code})
|
||||
workflow_api = self.get_workflow_api(workflow)
|
||||
second_task = workflow_api.next_task
|
||||
self.assertEqual('# Is file uploaded\nuploaded: False', second_task.documentation)
|
||||
|
||||
# There is no document to delete, so we get an error
|
||||
with self.assertRaises(AssertionError) as ex:
|
||||
self.complete_form(workflow, second_task, {})
|
||||
|
||||
def test_delete_irb_document_bad_document(self):
|
||||
self.load_example_data()
|
||||
# This is a bad document code
|
||||
irb_code = 'Study_Protocol_Doc'
|
||||
|
||||
workflow = self.create_workflow('add_delete_irb_document')
|
||||
|
||||
workflow_api = self.get_workflow_api(workflow)
|
||||
first_task = workflow_api.next_task
|
||||
|
||||
self.complete_form(workflow, first_task, {'irb_document': irb_code})
|
||||
workflow_api = self.get_workflow_api(workflow)
|
||||
second_task = workflow_api.next_task
|
||||
self.assertEqual('# Is file uploaded\nuploaded: False', second_task.documentation)
|
||||
|
||||
with self.assertRaises(AssertionError):
|
||||
self.complete_form(workflow, second_task, {})
|
||||
|
Loading…
x
Reference in New Issue
Block a user