Commit e08eb954 authored by Arkadiusz Hiler's avatar Arkadiusz Hiler

Add option for sending test results to mailing list only

... and clarify descriptions of the other options.
Signed-off-by: Arkadiusz Hiler's avatarArkadiusz Hiler <arkadiusz.hiler@intel.com>
parent 8738d513
Pipeline #18908 failed with stages
in 4 minutes and 32 seconds
......@@ -747,11 +747,14 @@ class Test(models.Model):
RECIPIENT_MAILING_LIST = 2
# send mail to the addresses listed in the mail_to_list field only
RECIPIENT_TO_LIST = 3
# send mail to mailing list only
RECIPIENT_MAILING_LIST_ONLY = 4
RECIPIENT_CHOICES = (
(RECIPIENT_NONE, 'none'),
(RECIPIENT_SUBMITTER, 'submitter'),
(RECIPIENT_MAILING_LIST, 'mailing list'),
(RECIPIENT_MAILING_LIST, 'submitter and mailing list'),
(RECIPIENT_TO_LIST, 'recipient list'),
(RECIPIENT_MAILING_LIST_ONLY, 'mailing list only'),
)
# send result mail on any state (but pending)
......
......@@ -878,6 +878,17 @@ class TestResultTest(APITestBase):
mail.outbox = []
self._configure_test(url, 'super test',
Test.RECIPIENT_MAILING_LIST_ONLY,
Test.CONDITION_ALWAYS)
self._post_result(url, 'super test', 'success')
self.assertEqual(len(mail.outbox), 1)
email = mail.outbox[0]
self.assertEqual(email.cc, [])
self.assertEqual(email.to, [self.project.listemail])
mail.outbox = []
self._configure_test(url, 'super test',
Test.RECIPIENT_TO_LIST, Test.CONDITION_ALWAYS,
to_list=to_list, cc_list=cc_list)
......
......@@ -408,6 +408,8 @@ class ResultMixin(object):
elif instance.test.mail_recipient == Test.RECIPIENT_MAILING_LIST:
to.append(check_obj.submitter.email_name())
cc.append(check_obj.project.listemail)
elif instance.test.mail_recipient == Test.RECIPIENT_MAILING_LIST_ONLY:
to.append(check_obj.project.listemail)
if instance.test.mail_recipient != Test.RECIPIENT_NONE and \
(instance.test.mail_to_list or instance.test.mail_cc_list):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment