From 8c752170423542a40c01ceaa8ad94ea60a8e9730 Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Tue, 9 Mar 2021 06:50:20 -0500 Subject: [PATCH] Test and workflow for associated user emails --- .../associated_email/associated_email.bpmn | 112 ++++++++++++++++++ .../test_workflow_associated_email.py | 19 +++ 2 files changed, 131 insertions(+) create mode 100644 tests/data/associated_email/associated_email.bpmn create mode 100644 tests/workflow/test_workflow_associated_email.py diff --git a/tests/data/associated_email/associated_email.bpmn b/tests/data/associated_email/associated_email.bpmn new file mode 100644 index 00000000..e01965af --- /dev/null +++ b/tests/data/associated_email/associated_email.bpmn @@ -0,0 +1,112 @@ + + + + <H1>Welcome</H1> +<div><p>This workflow asks for an email address and sends an email to that address.</p></div> + + Flow_1rmzlhd + + + + + + + + Flow_0b5st2e + Flow_0vf43xo + + + + Greetings, + + + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vitae volutpat dui. Quisque vitae orci sit amet nisl luctus porttitor id ac lorem. + + +- Proin vulputate arcu nisi, id pharetra nisi laoreet a. Cras nec lacus magna. +- Maecenas at eros feugiat, sagittis metus sit amet, luctus sem. +- Integer ut mollis erat. +- Ut euismod, massa non dignissim varius, nibh metus faucibus sem, quis gravida lorem dui eu enim. + + +Curabitur eget odio tristique, maximus libero pharetra, tincidunt ex. Nulla facilisi. Vivamus euismod sapien massa, vitae sagittis sem dictum nec. Vivamus vel erat consectetur, tincidunt mi ut, pellentesque dolor. Phasellus nisl dui, mollis vitae consectetur non, volutpat sed arcu. +Donec porttitor est ut massa rutrum euismod. Vestibulum massa leo, cursus nec erat et, lacinia lacinia eros. Vestibulum tempus, ligula quis sodales consectetur, enim mi dignissim purus, eget euismod nulla magna et ex. +Nam vulputate nibh lorem, nec finibus massa fermentum semper. Curabitur maximus sollicitudin arcu sollicitudin aliquet. Aliquam erat volutpat. Nullam gravida feugiat ante, vel ullamcorper orci. Nulla ac pretium justo. Interdum et malesuada fames ac ante ipsum primis in faucibus. Suspendisse pharetra justo ac odio accumsan tincidunt. In hac habitasse platea dictumst. + + +Praesent in odio neque. Mauris hendrerit, urna nec tincidunt faucibus, nunc lectus molestie magna, eget varius dolor enim et turpis. Ut efficitur lacus consequat vehicula cursus. Sed sem velit, sagittis a molestie vitae, lobortis interdum orci. + + +Phasellus non sapien sit amet velit vestibulum blandit ac at quam. Suspendisse potenti. Nunc eget sagittis nisi. Pellentesque ac felis risus. Maecenas libero nibh, vulputate non mauris vitae, ornare auctor dui. + +Later, +The Big Sender + Flow_0vf43xo + Flow_1p951bc + subject = 'test email' +recipients = 'associated' +email(subject=subject, recipients=recipients) + + + + <H1>Thank you</H1> +<div><p>You should receive an email message at {{ address }}.</p></div> + Flow_1p951bc + Flow_00wbedu + + + Flow_00wbedu + + + + + + Flow_1rmzlhd + Flow_0b5st2e + update_study_associates([{'uid':'dhf8r','role':'Chief Bee Keeper', 'send_email': True, 'access':True},{'uid':'lb3dp','role':'Chief Cat Herder', 'send_email': True, 'access':True}]) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/workflow/test_workflow_associated_email.py b/tests/workflow/test_workflow_associated_email.py new file mode 100644 index 00000000..211b2c7c --- /dev/null +++ b/tests/workflow/test_workflow_associated_email.py @@ -0,0 +1,19 @@ +from tests.base_test import BaseTest +from crc import mail + + +class TestAssociatedEmail(BaseTest): + + def test_associated_email(self): + # Only dhf8r is in testing DB. + # We want to test multiple associates, and lb3dp is already in testing LDAP + self.create_user(uid='lb3dp', email='lb3dp@virginia.edu', display_name='Laura Barnes') + with mail.record_messages() as outbox: + workflow = self.create_workflow('associated_email') + workflow_api = self.get_workflow_api(workflow) + # The workflow has a script task that adds two associates to the study; dhf8r and lb3dp + first_task = workflow_api.next_task + # This should send an email to both dhf8r and lb3dp + self.complete_form(workflow_api, first_task, {}) + self.assertIn(outbox[0].recipients[0], ['dhf8r@virginia.edu', 'lb3dp@virginia.edu']) + self.assertIn(outbox[0].recipients[1], ['dhf8r@virginia.edu', 'lb3dp@virginia.edu'])