Merge remote-tracking branch 'origin/dev' into bug/missing_pi_name_246

# Conflicts:
#	crc/models/study.py
#	crc/services/study_service.py
#	crc/services/workflow_service.py
#	tests/study/test_study_associate_script.py
This commit is contained in:
nilez 2021-08-12 12:39:04 -04:00
commit e32c1db4c8
12 changed files with 250 additions and 108 deletions

2
Pipfile.lock generated
View File

@ -979,7 +979,7 @@
},
"spiffworkflow": {
"git": "https://github.com/sartography/SpiffWorkflow.git",
"ref": "1df28b940ec0d32b672e59e3d17e7a804cb2b186"
"ref": "0b4a878f9b6d4f7fc320c26f59ca5e458a6130e8"
},
"sqlalchemy": {
"hashes": [

View File

@ -80,8 +80,9 @@ def get_study(study_id, update_status=False):
raise ApiError("unknown_study", 'The study "' + study_id + '" is not recognized.', status_code=404)
return StudySchema().dump(study)
def get_study_associates(study_id):
return StudyService.get_study_associates(study_id)
return StudyAssociatedSchema(many=True).dump(StudyService.get_study_associates(study_id))
def delete_study(study_id):

View File

@ -80,8 +80,10 @@ class StudyAssociated(db.Model):
send_email = db.Column(db.Boolean, nullable=True)
access = db.Column(db.Boolean, nullable=True)
class StudyAssociatedSchema(ma.Schema):
class Meta:
fields=['uid', 'role', 'send_email', 'access']
model = StudyAssociated
unknown = INCLUDE

View File

@ -114,7 +114,7 @@ email (subject="My Subject", recipients=["dhf8r@virginia.edu", pi.email], cc='as
associated_emails = []
associates = StudyService.get_study_associates(study_id)
for associate in associates:
if associate['send_email'] is True:
user_info = LdapService.user_info(associate['uid'])
if associate.send_email is True:
user_info = LdapService.user_info(associate.uid)
associated_emails.append(user_info.email_address)
return associated_emails

View File

@ -1,24 +1,24 @@
from crc.api.common import ApiError
from crc.models.study import StudyAssociatedSchema
from crc.scripts.script import Script
from crc.services.study_service import StudyService
class GetStudyAssociates(Script):
class GetStudyAssociate(Script):
def get_description(self):
return """
Returns people associated with a study or an error if one is not associated.
Returns how a single person is associated with a study and what access they need,
or raises an error if the person is not associated with the study.
example : get_study_associate('sbp3ey') => {'uid':'sbp3ey','role':'Unicorn Herder', 'send_email': False,
'access':True}
"""
def do_task_validate_only(self, task, study_id, workflow_id, *args, **kwargs):
if len(args) < 1:
raise ApiError('no_user_id_specified', 'A uva uid is the sole argument to this function')
return {'uid': 'sbp3ey', 'role': 'Unicorn Herder', 'send_email': False, 'access': True}
def do_task(self, task, study_id, workflow_id, *args, **kwargs):
@ -26,4 +26,5 @@ example : get_study_associate('sbp3ey') => {'uid':'sbp3ey','role':'Unicorn Herde
raise ApiError('no_user_id_specified', 'A uva uid is the sole argument to this function')
if not isinstance(args[0], str):
raise ApiError('argument_should_be_string', 'A uva uid is always a string, please check type')
return StudyService.get_study_associate(study_id=study_id, uid=args[0])
associate = StudyService.get_study_associate(study_id=study_id, uid=args[0])
return StudyAssociatedSchema().dump(associate)

View File

@ -1,4 +1,5 @@
from crc.api.common import ApiError
from crc.models.study import StudyAssociatedSchema
from crc.scripts.script import Script
from crc.services.study_service import StudyService
@ -26,7 +27,6 @@ example : get_study_associates() => [{'uid':'sbp3ey','role':'Unicorn Herder', 's
return study_associates
def do_task(self, task, study_id, workflow_id, *args, **kwargs):
return StudyService.get_study_associates(study_id)
return StudyAssociatedSchema(many=True).dump(StudyService.get_study_associates(study_id))

View File

@ -24,7 +24,6 @@ from crc.models.task_event import TaskEventModel, TaskEvent
from crc.models.workflow import WorkflowSpecCategoryModel, WorkflowModel, WorkflowSpecModel, WorkflowState, \
WorkflowStatus, WorkflowSpecDependencyFile
from crc.services.document_service import DocumentService
from crc.services.file_service import FileService
from crc.services.ldap_service import LdapService
from crc.services.lookup_service import LookupService
@ -112,7 +111,7 @@ class StudyService(object):
@staticmethod
def get_study_associate(study_id=None, uid=None):
"""
gets all associated people for a study from the database
gets details on how one uid is related to a study, returns a StudyAssociated model
"""
study = db.session.query(StudyModel).filter(StudyModel.id == study_id).first()
@ -123,18 +122,13 @@ class StudyService(object):
raise ApiError('uid not specified', 'A valid uva uid is required for this function')
if uid == study.user_uid:
return {'uid': uid, 'role': 'owner', 'send_email': True, 'access': True}
return StudyAssociated(uid=uid, role='owner', send_email=True, access=True)
person = db.session.query(StudyAssociated).filter((StudyAssociated.study_id == study_id)&(
StudyAssociated.uid == uid)).first()
if person:
newAssociate = {'uid': person.uid}
newAssociate['role'] = person.role
newAssociate['send_email'] = person.send_email
newAssociate['access'] = person.access
return newAssociate
people = db.session.query(StudyAssociated).filter((StudyAssociated.study_id == study_id) &
(StudyAssociated.uid == uid)).first()
if people:
return people
else:
raise ApiError('uid_not_associated_with_study', "user id %s was not associated with study number %d" % (uid,
study_id))
@ -148,19 +142,10 @@ class StudyService(object):
if study is None:
raise ApiError('study_not_found', 'No study found with id = %d' % study_id)
ownerid = study.user_uid
people = db.session.query(StudyAssociated).filter(StudyAssociated.study_id == study_id)
people_list = [{'uid':ownerid,'role':'owner','send_email':True,'access':True}]
for person in people:
newAssociate = {'uid':person.uid}
newAssociate['role'] = person.role
newAssociate['send_email'] = person.send_email
newAssociate['access'] = person.access
people_list.append(newAssociate)
return people_list
people = db.session.query(StudyAssociated).filter(StudyAssociated.study_id == study_id).all()
owner = StudyAssociated(uid=study.user_uid, role='owner', send_email=True, access=True)
people.append(owner)
return people
@staticmethod
def update_study_associates(study_id, associates):
@ -186,7 +171,6 @@ class StudyService(object):
if study is None:
raise ApiError('study_id not found', "A study with id# %d was not found" % study_id)
db.session.query(StudyAssociated).filter(StudyAssociated.study_id == study_id).delete()
for person in associates:
newAssociate = StudyAssociated()
@ -226,7 +210,6 @@ class StudyService(object):
session.commit()
return True
@staticmethod
def delete_study(study_id):
session.query(TaskEventModel).filter_by(study_id=study_id).delete()
@ -237,7 +220,6 @@ class StudyService(object):
for workflow in session.query(WorkflowModel).filter_by(study_id=study_id):
StudyService.delete_workflow(workflow.id)
study = session.query(StudyModel).filter_by(id=study_id).first()
study = session.query(StudyModel).filter_by(id=study_id).first()
session.delete(study)
session.commit()
@ -393,6 +375,7 @@ class StudyService(object):
in sync with the studies available in protocol builder. """
if ProtocolBuilderService.is_enabled():
app.logger.info("The Protocol Builder is enabled. app.config['PB_ENABLED'] = " +
str(app.config['PB_ENABLED']))
@ -408,11 +391,10 @@ class StudyService(object):
for pb_study in pb_studies:
new_status = None
db_study = next((s for s in db_studies if s.id == pb_study.STUDYID), None)
if not db_study: # Create a Study
if not db_study:
db_study = StudyModel(id=pb_study.STUDYID)
db_study.status = None # Force a new sa
new_status = StudyStatus.in_progress
session.add(db_study)
db_studies.append(db_study)

View File

@ -312,7 +312,7 @@ class WorkflowService(object):
data = {}
if field.has_property(Task.FIELD_PROP_FILE_DATA) and \
field.get_property(Task.FIELD_PROP_FILE_DATA) in data and \
field.id in data:
field.id in data and data[field.id]:
file_id = data[field.get_property(Task.FIELD_PROP_FILE_DATA)]["id"]
if field.type == 'enum':
data_args = (field.id, data[field.id]['label'])
@ -325,10 +325,19 @@ class WorkflowService(object):
expression = field.get_property(property_name)
data = task.data
if field.has_property(Task.FIELD_PROP_REPEAT):
# Then you must evaluate the expression based on the data within the group only.
# Then you must evaluate the expression based on the data within the group, if that data exists.
# There may not be data available in the group, if no groups where added
group = field.get_property(Task.FIELD_PROP_REPEAT)
if group in task.data:
# Here we must make the current group data top level (as it would be in a repeat section) but
# make all other top level task data available as well.
new_data = copy.deepcopy(task.data)
del(new_data[group])
data = task.data[group][0]
data.update(new_data)
else:
return None # We may not have enough information to process this
try:
return task.workflow.script_engine.eval(expression, data)
except Exception as e:
@ -770,7 +779,8 @@ class WorkflowService(object):
else:
if not hasattr(spiff_task.task_spec, 'lane') or spiff_task.task_spec.lane is None:
associated = StudyService.get_study_associates(processor.workflow_model.study.id)
return [user['uid'] for user in associated if user.get("access")]
return [user.uid for user in associated if user.access]
if spiff_task.task_spec.lane not in spiff_task.data:
return [] # No users are assignable to the task at this moment
lane_users = spiff_task.data[spiff_task.task_spec.lane]

View File

@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_ef382ee" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.5.0">
<bpmn:process id="Process_eea3627" name="Test Empty Hidden Field" isExecutable="true">
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>Flow_0eg42kv</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:userTask id="Activity_FileUpload" name="File Upload" camunda:formKey="UploadFile">
<bpmn:extensionElements>
<camunda:formData>
<camunda:formField id="UploadFile" label="Select File" type="file" />
<camunda:formField id="Name" label="Enter Name" type="string">
<camunda:properties>
<camunda:property id="file_data" value="UploadFile" />
</camunda:properties>
</camunda:formField>
<camunda:formField id="ExtraField" label="Could Be Hidden" type="string" defaultValue="Extra Field String">
<camunda:properties>
<camunda:property id="hide_expression" value="hide_field" />
<camunda:property id="file_data" value="UploadFile" />
</camunda:properties>
</camunda:formField>
</camunda:formData>
</bpmn:extensionElements>
<bpmn:incoming>Flow_074gk91</bpmn:incoming>
<bpmn:outgoing>Flow_1gseke4</bpmn:outgoing>
</bpmn:userTask>
<bpmn:sequenceFlow id="Flow_0eg42kv" sourceRef="StartEvent_1" targetRef="Activity_AddData" />
<bpmn:sequenceFlow id="Flow_074gk91" sourceRef="Activity_AddData" targetRef="Activity_FileUpload" />
<bpmn:sequenceFlow id="Flow_1gseke4" sourceRef="Activity_FileUpload" targetRef="Activity_ViewData" />
<bpmn:endEvent id="Event_0qcduja">
<bpmn:incoming>Flow_04ozqju</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="Flow_04ozqju" sourceRef="Activity_ViewData" targetRef="Event_0qcduja" />
<bpmn:manualTask id="Activity_ViewData" name="View Data">
<bpmn:incoming>Flow_1gseke4</bpmn:incoming>
<bpmn:outgoing>Flow_04ozqju</bpmn:outgoing>
</bpmn:manualTask>
<bpmn:userTask id="Activity_AddData" name="Add Data" camunda:formKey="HideData">
<bpmn:extensionElements>
<camunda:formData>
<camunda:formField id="hide_field" label="Hide Field?" type="boolean">
<camunda:validation>
<camunda:constraint name="required" config="True" />
</camunda:validation>
</camunda:formField>
</camunda:formData>
</bpmn:extensionElements>
<bpmn:incoming>Flow_0eg42kv</bpmn:incoming>
<bpmn:outgoing>Flow_074gk91</bpmn:outgoing>
</bpmn:userTask>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_eea3627">
<bpmndi:BPMNEdge id="Flow_04ozqju_di" bpmnElement="Flow_04ozqju">
<di:waypoint x="690" y="117" />
<di:waypoint x="752" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1gseke4_di" bpmnElement="Flow_1gseke4">
<di:waypoint x="530" y="117" />
<di:waypoint x="590" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_074gk91_di" bpmnElement="Flow_074gk91">
<di:waypoint x="370" y="117" />
<di:waypoint x="430" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0eg42kv_di" bpmnElement="Flow_0eg42kv">
<di:waypoint x="215" y="117" />
<di:waypoint x="270" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="179" y="99" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0zui1g5_di" bpmnElement="Activity_FileUpload">
<dc:Bounds x="430" y="77" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_0qcduja_di" bpmnElement="Event_0qcduja">
<dc:Bounds x="752" y="99" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1fkiik9_di" bpmnElement="Activity_ViewData">
<dc:Bounds x="590" y="77" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="UserTask_0wc78yf_di" bpmnElement="Activity_AddData">
<dc:Bounds x="270" y="77" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_0kmksnn" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.5.0">
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_0kmksnn" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.7.3">
<bpmn:process id="Process_0exnnpv" isExecutable="true">
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>SequenceFlow_1nfe5m9</bpmn:outgoing>
@ -32,7 +32,7 @@ out4 = get_study_associate('lb3dp')</bpmn:script>
<bpmn:outgoing>Flow_1vlh6s0</bpmn:outgoing>
<bpmn:script>uids = []
for assoc in out:
uids.append(assoc['uid'])
uids.append(assoc.uid)
update_study_associates([{'uid':'lb3dp','role':'SuperGal','send_email':False,'access':True}])</bpmn:script>
</bpmn:scriptTask>
<bpmn:sequenceFlow id="Flow_1vlh6s0" sourceRef="Activity_0run091" targetRef="Activity_0d8iftx" />
@ -46,6 +46,22 @@ out2 = get_study_associate('lb3dp')</bpmn:script>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_0exnnpv">
<bpmndi:BPMNEdge id="Flow_14n3ixy_di" bpmnElement="Flow_14n3ixy">
<di:waypoint x="680" y="117" />
<di:waypoint x="750" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1vlh6s0_di" bpmnElement="Flow_1vlh6s0">
<di:waypoint x="850" y="117" />
<di:waypoint x="900" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0cttkwp_di" bpmnElement="Flow_0cttkwp">
<di:waypoint x="1000" y="117" />
<di:waypoint x="1042" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_09cika8_di" bpmnElement="Flow_09cika8">
<di:waypoint x="540" y="117" />
<di:waypoint x="580" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_1bqiin0_di" bpmnElement="SequenceFlow_1bqiin0">
<di:waypoint x="370" y="117" />
<di:waypoint x="440" y="117" />
@ -60,10 +76,6 @@ out2 = get_study_associate('lb3dp')</bpmn:script>
<bpmndi:BPMNShape id="ScriptTask_1mp6xid_di" bpmnElement="Task_Script_Load_Study_Sponsors">
<dc:Bounds x="270" y="77" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_09cika8_di" bpmnElement="Flow_09cika8">
<di:waypoint x="540" y="117" />
<di:waypoint x="580" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="Activity_0wnwluq_di" bpmnElement="Activity_0cm6tn2">
<dc:Bounds x="440" y="77" width="100" height="80" />
</bpmndi:BPMNShape>
@ -73,24 +85,12 @@ out2 = get_study_associate('lb3dp')</bpmn:script>
<bpmndi:BPMNShape id="Event_0c8gcuh_di" bpmnElement="Event_0c8gcuh">
<dc:Bounds x="1042" y="99" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_0cttkwp_di" bpmnElement="Flow_0cttkwp">
<di:waypoint x="1000" y="117" />
<di:waypoint x="1042" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="Activity_0run091_di" bpmnElement="Activity_0run091">
<dc:Bounds x="750" y="77" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_1vlh6s0_di" bpmnElement="Flow_1vlh6s0">
<di:waypoint x="850" y="117" />
<di:waypoint x="900" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="Activity_14td33q_di" bpmnElement="Activity_14td33q">
<dc:Bounds x="580" y="77" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_14n3ixy_di" bpmnElement="Flow_14n3ixy">
<di:waypoint x="680" y="117" />
<di:waypoint x="750" y="117" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>

View File

@ -53,19 +53,18 @@ class TestSudySponsorsScript(BaseTest):
self.assertIn('sponsors', data)
self.assertIn('out', data)
print(data['out'])
self.assertEqual([{'uid': 'dhf8r', 'role': 'owner', 'send_email': True, 'access': True},
{'uid': 'lb3dp', 'role': 'SuperDude', 'send_email': False, 'access': True}]
, data['out'])
self.assertEqual({'uid': 'lb3dp', 'role': 'SuperDude', 'send_email': False, 'access': True}
, data['out2'])
self.assertEqual([{'uid': 'dhf8r', 'role': 'owner', 'send_email': True, 'access': True},
{'uid': 'lb3dp', 'role': 'SuperGal', 'send_email': False, 'access': True}]
, data['out3'])
self.assertEqual({'uid': 'lb3dp', 'role': 'SuperGal', 'send_email': False, 'access': True}
, data['out4'])
self.assertDictEqual({'uid': 'dhf8r', 'role': 'owner', 'send_email': True, 'access': True},
data['out'][1])
self.assertDictEqual({'uid': 'lb3dp', 'role': 'SuperDude', 'send_email': False, 'access': True},
data['out'][0])
self.assertDictEqual({'uid': 'lb3dp', 'role': 'SuperDude', 'send_email': False, 'access': True},
data['out2'])
self.assertDictEqual({'uid': 'dhf8r', 'role': 'owner', 'send_email': True, 'access': True},
data['out3'][1])
self.assertDictEqual({'uid': 'lb3dp', 'role': 'SuperGal', 'send_email': False, 'access': True},
data['out3'][0])
self.assertDictEqual({'uid': 'lb3dp', 'role': 'SuperGal', 'send_email': False, 'access': True},
data['out4'])
self.assertEqual(3, len(data['sponsors']))

View File

@ -0,0 +1,60 @@
from tests.base_test import BaseTest
from io import BytesIO
import json
class TestHiddenFileDataField(BaseTest):
def test_hidden_file_data_field(self):
self.load_example_data()
workflow = self.create_workflow('hidden_file_data_field')
workflow_api = self.get_workflow_api(workflow)
task = workflow_api.next_task
self.complete_form(workflow, task, {'hide_field': True})
workflow_api = self.get_workflow_api(workflow)
task = workflow_api.next_task
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, 'Study_App_Doc'), 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']
self.complete_form(workflow, task, {'UploadFile': {'id': file_id},
'Name': 'Some Name String'})
workflow_api = self.get_workflow_api(workflow)
new_task = workflow_api.next_task
self.assertEqual('Activity_ViewData', new_task.name)
self.assertEqual('Some Name String', new_task.data['Name'])
self.assertNotIn('ExtraField', new_task.data)
def test_not_hidden_file_data_field(self):
self.load_example_data()
workflow = self.create_workflow('hidden_file_data_field')
workflow_api = self.get_workflow_api(workflow)
task = workflow_api.next_task
self.complete_form(workflow, task, {'hide_field': False})
workflow_api = self.get_workflow_api(workflow)
task = workflow_api.next_task
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, 'Study_App_Doc'), 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']
self.complete_form(workflow, task, {'UploadFile': {'id': file_id},
'Name': 'Some Name String',
'ExtraField': 'Some Extra String'})
workflow_api = self.get_workflow_api(workflow)
new_task = workflow_api.next_task
self.assertEqual('Activity_ViewData', new_task.name)
self.assertEqual('Some Name String', new_task.data['Name'])
self.assertIn('ExtraField', new_task.data)
self.assertEqual('Some Extra String', new_task.data['ExtraField'])