cr-connect-workflow/tests/test_tools_api.py
Dan Funk 7194d7d374 Standardizing the script tasks that can be executed on the server, adding tons of error messages for when things go wrong. All scripts must exist in side of the crc/scripts directory.
Adding a new script that script tasks can use to add in data about the study.

Moving all the test workflow specifications out of the main load.

fixing a pile of tests so they can find workflow specs that are now moved into the test directory.
2020-03-03 13:52:45 -05:00

35 lines
1.5 KiB
Python

import json
import os
from datetime import datetime, timezone
from crc import session, app
from crc.models.study import StudyModel, StudyModelSchema
from crc.models.protocol_builder import ProtocolBuilderStatus
from crc.models.workflow import WorkflowSpecModel, WorkflowSpecModelSchema, WorkflowModel, WorkflowStatus, \
WorkflowApiSchema
from tests.base_test import BaseTest
class TestStudyApi(BaseTest):
def test_render_markdown(self):
template = "My name is {{name}}"
data = {"name": "Dan"}
rv = self.app.get('/v1.0/render_markdown?template=%s&data=%s' %
(template, json.dumps(data)))
self.assert_success(rv)
self.assertEqual("My name is Dan", rv.get_data(as_text=True))
def test_render_docx(self):
filepath = os.path.join(app.root_path, '..', 'tests', 'data', 'table.docx')
template_data = {"hippa": [
{"option": "Name", "selected": True, "stored": ["Record at UVA", "Stored Long Term"]},
{"option": "Address", "selected": False},
{"option": "Phone", "selected": True, "stored": ["Send or Transmit outside of UVA"]}]}
with open(filepath, 'rb') as f:
file_data = {'file': (f, 'my_new_file.bpmn')}
rv = self.app.put('/v1.0/render_docx?data=%s' % json.dumps(template_data),
data=file_data, follow_redirects=True,
content_type='multipart/form-data')
self.assert_success(rv)