cr-connect-workflow/tests/emails/test_email_script.py

34 lines
1.0 KiB
Python
Raw Normal View History

2020-12-14 15:29:53 +00:00
from tests.base_test import BaseTest
from crc import mail
2020-06-25 04:23:31 +00:00
from crc.models.email import EmailModel
2020-06-17 00:42:36 +00:00
class TestEmailScript(BaseTest):
def test_do_task(self):
workflow = self.create_workflow('email')
task_data = {
2020-12-14 15:29:53 +00:00
'PIComputingID': 'dhf8r@virginia.edu',
'ApprvlApprvr1': 'lb3dp@virginia.edu'
2020-06-17 00:42:36 +00:00
}
task = self.get_workflow_api(workflow).next_task
2020-06-25 04:23:31 +00:00
with mail.record_messages() as outbox:
2020-06-25 04:23:31 +00:00
self.complete_form(workflow, task, task_data)
2020-06-17 00:42:36 +00:00
2020-06-25 04:23:31 +00:00
self.assertEqual(len(outbox), 1)
self.assertEqual(outbox[0].subject, 'Camunda Email Subject')
2020-06-17 23:00:16 +00:00
2020-06-25 04:23:31 +00:00
# PI is present
self.assertIn(task_data['PIComputingID'], outbox[0].body)
self.assertIn(task_data['PIComputingID'], outbox[0].html)
# Approver is present
self.assertIn(task_data['ApprvlApprvr1'], outbox[0].body)
self.assertIn(task_data['ApprvlApprvr1'], outbox[0].html)
db_emails = EmailModel.query.count()
self.assertEqual(db_emails, 1)