workflow_tests: check all email recipients (#90035)
gitea/wcs/pipeline/head This commit looks good Details

This commit is contained in:
Valentin Deniaud 2024-04-25 15:49:56 +02:00
parent a2a4b1536b
commit d8cb5e4737
2 changed files with 4 additions and 4 deletions

View File

@ -620,7 +620,7 @@ def test_workflow_tests_sendmail(mocked_send_email, pub):
end_status = workflow.add_status(name='End status')
sendmail = new_status.add_action('sendmail')
sendmail.to = ['test@example.org']
sendmail.to = ['test@example.org', 'test2@example.org']
sendmail.subject = 'In new status'
sendmail.body = 'xxx'
@ -687,7 +687,7 @@ def test_workflow_tests_sendmail(mocked_send_email, pub):
with pytest.raises(WorkflowTestError) as excinfo:
testdef.run(formdef)
assert str(excinfo.value) == 'Email was not sent to address "other@example.org".'
assert 'Email addresses: test@example.org' in excinfo.value.details
assert 'Email addresses: test2@example.org, test@example.org' in excinfo.value.details
testdef.workflow_tests.actions = [
workflow_tests.ButtonClick(button_name='Go to end status'),

View File

@ -504,8 +504,8 @@ class AssertEmail(WorkflowTestAction):
raise WorkflowTestError(_('No email was sent.'))
for address in self.addresses:
details = [_('Email addresses: %s') % ', '.join(email.email_msg.to)]
if address not in email.email_msg.to:
details = [_('Email addresses: %s') % ', '.join(sorted(email.email_msg.recipients()))]
if address not in email.email_msg.recipients():
raise WorkflowTestError(_('Email was not sent to address "%s".') % address, details=details)
for subject in self.subject_strings: