From 82bf25cbc666a946d2d0832e50b9082c1fdca123 Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Thu, 15 Jul 2021 13:10:51 -0400 Subject: [PATCH] Test that we set file data_store values correctly when using the file_data property --- .../IRB_HSR_Application_Type.xlsx | Bin 0 -> 8645 bytes tests/data/enum_file_data/enum_file_data.bpmn | 68 ++++++++++++++++++ tests/test_file_datastore.py | 37 +++++++--- 3 files changed, 97 insertions(+), 8 deletions(-) create mode 100644 tests/data/enum_file_data/IRB_HSR_Application_Type.xlsx create mode 100644 tests/data/enum_file_data/enum_file_data.bpmn diff --git a/tests/data/enum_file_data/IRB_HSR_Application_Type.xlsx b/tests/data/enum_file_data/IRB_HSR_Application_Type.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..55230977a91f1da667dee78232feb67c46316320 GIT binary patch literal 8645 zcmeHN1y@|lvL4(CA-EGffnb9Lm*8%J;4-+o+u#t~CAd2T3l`j62X_)ASb!jbH#u@o zPR@D1;NG6KcCWp9SMAuw+HHtED@HhZO05Sjopah8U3Jhw)001%Y0KgLfGOU)U zt&J1N#z{}r-45ia^TN&AiXs;tmOdK*3w{27?Z0>h$`j;lx>&G+t`a>$29}<&Iw`5) z`oHo`Vp9GLv+O3qNV0T>j$^YHmZKJ=2uPGG@9{bIb}`{gE7wY|pvXO~#OXGqV6#h{ z?;DjlW%V39eifXbp+3h;-;1ay+c*C@4?+ttDR={l-hAH>$*2j2>zX+513%cD#$m8>cSVKz6M4fppJT}9-Qp9`f`S*rM7 z&erZcp=S|OBq9b_SjYC|s`X{YWZ~t>cAs=ntlY<)KE~X9z+mHlh>o#}f`4kwxE|!% z!oi=kT#S5^`P8+q7v|pM%HD28Ht*2@DbB{7$~T4!`Aj6v07*oTi0@pnOUHK~+blvV zJ2*bULD*L4wrrvP^zZ-&Q2ZMx6}{v;FQFr{P|Tr0L8<2evT|g8@#FeGF#Z=K@TX6Y zj2oARW5o(N4mifzT^(%*2n8-hAh(6hAQ8kv1P^U!si!}9dx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?>Xz?Uo_McTD0dlK0s&J`k6#L-q~^sbH8r)xbK^+Zc&GRl551KXy=tcnYpw3#V$V7 zOuuihFtAL}jN!i*%>OjzpZ&j-&lP3TA{gveYC5nRgpHKe><^5I5-(&1wIskwPLIB_&5%*W|zi*H~ fiz}1-B>u;CsVIX0wJrdF3jO&(gE}+$kGuZ^YvK;+ literal 0 HcmV?d00001 diff --git a/tests/data/enum_file_data/enum_file_data.bpmn b/tests/data/enum_file_data/enum_file_data.bpmn new file mode 100644 index 00000000..599bfe05 --- /dev/null +++ b/tests/data/enum_file_data/enum_file_data.bpmn @@ -0,0 +1,68 @@ + + + + + Flow_1kvuzs1 + + + + + + + + + + + + + + + + + + + + + Flow_1kvuzs1 + Flow_0han7ki + + + + # Enum + Flow_0han7ki + Flow_0h5cdg9 + + + Flow_0h5cdg9 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/test_file_datastore.py b/tests/test_file_datastore.py index 1a10eea7..571639e7 100644 --- a/tests/test_file_datastore.py +++ b/tests/test_file_datastore.py @@ -1,18 +1,17 @@ -import json +from tests.base_test import BaseTest +from crc import db +from crc.models.data_store import DataStoreModel from crc.services.file_service import FileService from crc.services.workflow_processor import WorkflowProcessor -from tests.base_test import BaseTest -from crc.models.workflow import WorkflowStatus -from crc import db -from crc.api.common import ApiError -from crc.models.task_event import TaskEventModel, TaskEventSchema -from crc.services.workflow_service import WorkflowService + +from io import BytesIO + +import json class TestFileDatastore(BaseTest): - def test_file_datastore_workflow(self): self.load_example_data() self.create_reference_document() @@ -32,3 +31,25 @@ class TestFileDatastore(BaseTest): self.assertEqual(task_data['output'], 'me') self.assertEqual(task_data['output2'], 'nope') + def test_file_data_store_file_data_property(self): + self.load_example_data() + workflow = self.create_workflow('enum_file_data') + workflow_api = self.get_workflow_api(workflow) + task = workflow_api.next_task + + # upload the file + correct_name = task.form['fields'][1]['id'] + data = {'file': (BytesIO(b"abcdef"), 'test_file.txt')} + rv = self.app.post('/v1.0/file?study_id=%i&workflow_id=%s&task_id=%s&form_field_key=%s' % + (workflow.study_id, workflow.id, task.id, correct_name), data=data, follow_redirects=True, + content_type='multipart/form-data', headers=self.logged_in_headers()) + self.assert_success(rv) + file_id = json.loads(rv.get_data())['id'] + + # process the form that sets the datastore values + self.complete_form(workflow, task, {'Study_App_Doc': {'id': file_id}, + 'IRB_HSR_Application_Type': {'label': 'Expedited Application'}}) + data_store = db.session.query(DataStoreModel).filter(DataStoreModel.file_id==file_id).first() + self.assertEqual('IRB_HSR_Application_Type', data_store.key) + self.assertEqual('Expedited Application', data_store.value) + print('test_file_data_store_file_data_property')