2020-11-04 19:37:53 +00:00
|
|
|
from tests.base_test import BaseTest
|
|
|
|
from crc.models.study import StudyModel
|
|
|
|
from crc import db
|
|
|
|
|
|
|
|
|
|
|
|
class TestMessageEvent(BaseTest):
|
|
|
|
|
|
|
|
def test_message_event(self):
|
|
|
|
|
|
|
|
workflow = self.create_workflow('message_event')
|
|
|
|
study_id = workflow.study_id
|
|
|
|
|
|
|
|
# Start the workflow.
|
|
|
|
first_task = self.get_workflow_api(workflow).next_task
|
|
|
|
self.assertEqual('Activity_GetData', first_task.name)
|
2021-04-26 12:58:09 +00:00
|
|
|
|
2020-11-04 19:37:53 +00:00
|
|
|
self.complete_form(workflow, first_task, {'formdata': 'asdf'})
|
2021-04-26 12:58:09 +00:00
|
|
|
workflow_api = self.get_workflow_api(workflow)
|
|
|
|
self.assertEqual('Activity_HowMany', workflow_api.next_task.name)
|
2020-11-04 19:37:53 +00:00
|
|
|
|
|
|
|
# reset the workflow
|
|
|
|
# this ultimately calls crc.api.workflow.set_current_task
|
|
|
|
self.app.put('/v1.0/workflow/%i/task/%s/set_token' % (
|
|
|
|
workflow.id,
|
|
|
|
first_task.id),
|
|
|
|
headers=self.logged_in_headers(),
|
|
|
|
content_type="application/json")
|
|
|
|
|
2021-03-02 15:03:53 +00:00
|
|
|
# set_current_task should call the interrupt (signal) task
|
2020-11-04 19:37:53 +00:00
|
|
|
# which should run the script in our task
|
|
|
|
#
|
|
|
|
# test to see if our changes made it to the DB
|
2020-11-18 20:33:44 +00:00
|
|
|
study_result = db.session.query(StudyModel).filter(StudyModel.id == study_id).first()
|
|
|
|
self.assertEqual('New Title', study_result.title)
|