diff --git a/Pipfile b/Pipfile index 0a498025..0791a851 100644 --- a/Pipfile +++ b/Pipfile @@ -39,7 +39,7 @@ requests = "*" sentry-sdk = {extras = ["flask"],version = "==0.14.4"} sphinx = "*" swagger-ui-bundle = "*" -spiffworkflow = {git = "https://github.com/sartography/SpiffWorkflow.git",ref = "master"} +spiffworkflow = {git = "https://github.com/sartography/SpiffWorkflow.git",ref = "cancel-event"} webtest = "*" werkzeug = "*" xlrd = "*" diff --git a/Pipfile.lock b/Pipfile.lock index 87d27348..e6cdfb0e 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "621d57ec513f24c665dd34e08ae5a19fc27784e87c55bb4d2a91a1d48a473081" + "sha256": "263e8627b483ddc81a2016eb4da3e6738140b449c9c4be13a7a62a9191f171cd" }, "pipfile-spec": 6, "requires": { @@ -47,10 +47,10 @@ }, "babel": { "hashes": [ - "sha256:1aac2ae2d0d8ea368fa90906567f5c08463d98ade155c0c4bfedd6a0f7160e38", - "sha256:d670ea0b10f8b723672d3a6abeb87b565b244da220d76b4dba1b66269ec152d4" + "sha256:9d35c22fcc79893c3ecc85ac4a56cde1ecf3f19c540bba0922308a6c06ca6fa5", + "sha256:da031ab54472314f210b0adcff1588ee5d1d1d0ba4dbd07b94dba82bde791e05" ], - "version": "==2.8.0" + "version": "==2.9.0" }, "bcrypt": { "hashes": [ @@ -80,10 +80,10 @@ }, "certifi": { "hashes": [ - "sha256:5930595817496dd21bb8dc35dad090f1c2cd0adfaf21204bf6732ca5d8ee34d3", - "sha256:8fc0819f1f30ba15bdb34cceffb9ef04d99f420f68eb75d901e9560b8749fc41" + "sha256:1f422849db327d534e3d0c5f02a263458c3955ec0aae4ff09b95f195c59f4edd", + "sha256:f05def092c44fbf25834a51509ef6e631dc19765ab8a57b4e7ab85531f0a9cf4" ], - "version": "==2020.6.20" + "version": "==2020.11.8" }, "cffi": { "hashes": [ @@ -221,11 +221,11 @@ }, "docxtpl": { "hashes": [ - "sha256:5c98ea92ce31bcf24357a03d193d5096f16b9618d2d6b9b3f8fff01a4081eaf0", - "sha256:b5f1823de88b1762cfb1fa86fed6e088ab87aa22f7c157b23b2d1bffb38272f9" + "sha256:aa12f454f798daa43b52c41f1c90f890f0405b128f1dadd5aeee501d7e347855", + "sha256:dd2fc41f682c0d8f9e8479af167b3b8e781cc0a7b343af37a9a5aaff6dd035d7" ], "index": "pypi", - "version": "==0.11.1" + "version": "==0.11.2" }, "et-xmlfile": { "hashes": [ @@ -471,11 +471,11 @@ }, "marshmallow": { "hashes": [ - "sha256:4bc31ab18133083b12893c61f2fc38b93c390d3fd6ae2ac61980b7dc936a1afa", - "sha256:97ad6acaf727be986330969cff16040fce051510759ca709de9cd48093c55d04" + "sha256:73facc37462dfc0b27f571bdaffbef7709e19f7a616beb3802ea425b07843f4e", + "sha256:e26763201474b588d144dae9a32bdd945cd26a06c943bc746a6882e850475378" ], "index": "pypi", - "version": "==3.9.0" + "version": "==3.9.1" }, "marshmallow-enum": { "hashes": [ @@ -487,11 +487,11 @@ }, "marshmallow-sqlalchemy": { "hashes": [ - "sha256:098d4486374d0c63b4a947269c36d8850eedf35c59f172c5a1da28c070af64f4", - "sha256:cf0c7fead0b30ad66892a0cefcb39151591842ab16ca48ffa5bd816719b2491e" + "sha256:93f47b880ac7070f7b34c8ac0a71eeec3f8582a22e5c0330c1c436e3f5f99a37", + "sha256:d051cf013c075c43e1ee5c4b01f8fab6dd6b140dab6825be45875f674a0d289c" ], "index": "pypi", - "version": "==0.24.0" + "version": "==0.24.1" }, "numpy": { "hashes": [ @@ -746,11 +746,11 @@ }, "requests": { "hashes": [ - "sha256:b3559a131db72c33ee969480840fff4bb6dd111de7dd27c8ee1f820f4f00231b", - "sha256:fe75cc94a9443b9246fc7049224f75604b113c36acb93f87b80ed42c44cbb898" + "sha256:7f1a0b932f4a60a1a65caa4263921bb7d9ee911957e0ae4a23a6dd08185ad5f8", + "sha256:e786fa28d8c9154e6a4de5d46a1d921b8749f8b74e28bde23768e5e16eece998" ], "index": "pypi", - "version": "==2.24.0" + "version": "==2.25.0" }, "sentry-sdk": { "extras": [ @@ -787,11 +787,11 @@ }, "sphinx": { "hashes": [ - "sha256:1c21e7c5481a31b531e6cbf59c3292852ccde175b504b00ce2ff0b8f4adc3649", - "sha256:3abdb2c57a65afaaa4f8573cbabd5465078eb6fd282c1e4f87f006875a7ec0c7" + "sha256:1e8d592225447104d1172be415bc2972bd1357e3e12fdc76edf2261105db4300", + "sha256:d4e59ad4ea55efbb3c05cde3bfc83bfc14f0c95aa95c3d75346fcce186a47960" ], "index": "pypi", - "version": "==3.3.0" + "version": "==3.3.1" }, "sphinxcontrib-applehelp": { "hashes": [ @@ -837,7 +837,7 @@ }, "spiffworkflow": { "git": "https://github.com/sartography/SpiffWorkflow.git", - "ref": "a1d5c2feedc2a9490110d5a182ee260c76ed6e66" + "ref": "54c75ba9503a3e4bded34da7ed2d87b2a6b3e6cb" }, "sqlalchemy": { "hashes": [ @@ -892,10 +892,10 @@ }, "urllib3": { "hashes": [ - "sha256:8d7eaa5a82a1cac232164990f04874c594c9453ec55eef02eab885aa02fc17a2", - "sha256:f5321fbe4bf3fefa0efd0bfe7fb14e90909eb62a48ccda331726b4319897dd5e" + "sha256:19188f96923873c92ccb987120ec4acaa12f0461fa9ce5d3d0772bc965a39e08", + "sha256:d8ff90d979214d7b4f8ce956e80f4028fc6860e4431f731ea4a8c08f23f99473" ], - "version": "==1.25.11" + "version": "==1.26.2" }, "waitress": { "hashes": [ diff --git a/crc/api/workflow.py b/crc/api/workflow.py index 223f280f..a148328a 100644 --- a/crc/api/workflow.py +++ b/crc/api/workflow.py @@ -147,6 +147,9 @@ def set_current_task(workflow_id, task_id): raise ApiError("invalid_state", "You may not move the token to a task who's state is not " "currently set to COMPLETE or READY.") + # If we have an interrupt task, run it. + processor.bpmn_workflow.cancel_notify() + # Only reset the token if the task doesn't already have it. if spiff_task.state == spiff_task.COMPLETED: spiff_task.reset_token(reset_data=True) # Don't try to copy the existing data back into this task. diff --git a/tests/data/message_event/message_event.bpmn b/tests/data/message_event/message_event.bpmn new file mode 100644 index 00000000..4b4b8857 --- /dev/null +++ b/tests/data/message_event/message_event.bpmn @@ -0,0 +1,123 @@ + + + + + Flow_0xym55y + + + + Flow_16q1uec + update_study("title:'New Title'") +print('New Title') + + + + + + + + Flow_1rvh899 + Flow_1n1fs6z + + + Flow_07i0gvv + Flow_1c2tudh + [print(formdata) for _ in range(how_many)] +printdata = formdata + + + Flow_1c2tudh + + + + + + Flow_0xym55y + Flow_1rvh899 + print('Hello'); printdata=''; test_message='' + + + + + + + + + Flow_1n1fs6z + Flow_07i0gvv + + + + Flow_16q1uec + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/test_message_event.py b/tests/test_message_event.py new file mode 100644 index 00000000..60ab0ac9 --- /dev/null +++ b/tests/test_message_event.py @@ -0,0 +1,34 @@ +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) + workflow = self.get_workflow_api(workflow) + self.complete_form(workflow, first_task, {'formdata': 'asdf'}) + workflow = self.get_workflow_api(workflow) + self.assertEqual('Activity_HowMany', workflow.next_task.name) + + # 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") + + # set_current_task should call the interupt (signal) task + # which should run the script in our task + # + # test to see if our changes made it to the DB + study_result = db.session.query(StudyModel).filter(StudyModel.id == study_id).first() + self.assertEqual('New Title', study_result.title)