diff --git a/tests/data/email/email.bpmn b/tests/data/email/email.bpmn index bd9b7d8c..367c3185 100644 --- a/tests/data/email/email.bpmn +++ b/tests/data/email/email.bpmn @@ -1,5 +1,5 @@ - + Flow_1synsig @@ -22,7 +22,8 @@ Email content to be delivered to {{ ApprvlApprvr1 }} Flow_1xlrgne subject="Camunda Email Subject" recipients=[ApprvlApprvr1,PIComputingID] -email(subject=subject,recipients=recipients) +email_id = email(subject=subject,recipients=recipients) + diff --git a/tests/data/get_email_data/get_email_data.bpmn b/tests/data/get_email_data/get_email_data.bpmn new file mode 100644 index 00000000..0c6a44fe --- /dev/null +++ b/tests/data/get_email_data/get_email_data.bpmn @@ -0,0 +1,81 @@ + + + + + Flow_1erkgz2 + + + + + + + + + + Flow_1erkgz2 + Flow_1ira7x5 + + + + Flow_1ira7x5 + Flow_1bt23l3 + email_data = None +if 'email_id' in globals(): + email_id = globals()['email_id'] + email_data = get_email_data(email_id=email_id) +elif 'workflow_id' in globals(): + workflow_id = globals()['workflow_id'] + email_data = get_email_data(workflow_id=workflow_id) +else: + email_data = 'nothing' +print(email_data) + + + + # Email Data +{{ email_data }} + + Flow_1bt23l3 + Flow_0uujrj4 + + + Flow_0uujrj4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/emails/test_email_script.py b/tests/emails/test_email_script.py index 1a6c6860..ae16d215 100644 --- a/tests/emails/test_email_script.py +++ b/tests/emails/test_email_script.py @@ -16,7 +16,7 @@ class TestEmailScript(BaseTest): with mail.record_messages() as outbox: - self.complete_form(workflow, task, task_data) + workflow_api = self.complete_form(workflow, task, task_data) self.assertEqual(len(outbox), 1) self.assertEqual(outbox[0].subject, 'Camunda Email Subject') diff --git a/tests/scripts/test_get_email_data.py b/tests/scripts/test_get_email_data.py new file mode 100644 index 00000000..44faf246 --- /dev/null +++ b/tests/scripts/test_get_email_data.py @@ -0,0 +1,24 @@ +from tests.base_test import BaseTest +from crc import mail, session +from crc.models.study import StudyModel +from crc.services.email_service import EmailService + + +class TestGetEmailData(BaseTest): + + def test_get_email_data(self): + self.load_example_data() + study = session.query(StudyModel).first() + with mail.record_messages() as outbox: + email_model = EmailService.add_email(subject='My Email Subject', + sender='sender@example.com', + recipients=['joe@example.com'], + content='asdf', content_html=None, study_id=study.id) + + workflow = self.create_workflow('get_email_data') + workflow_api = self.get_workflow_api(workflow) + task = workflow_api.next_task + + workflow_api = self.complete_form(workflow, task, {'email_id': email_model.id}) + + print('test_get_email_data') \ No newline at end of file