|
| 1 | +# Copyright The IETF Trust 2015-2019, All Rights Reserved |
| 2 | +# -*- coding: utf-8 -*- |
| 3 | + |
| 4 | + |
| 5 | +from __future__ import absolute_import, print_function, unicode_literals |
| 6 | + |
| 7 | +from ietf.doc.factories import WgDraftFactory |
| 8 | +from ietf.mailtrigger.models import MailTrigger |
| 9 | +from .utils import gather_address_lists |
| 10 | +from ietf.utils.test_utils import TestCase |
| 11 | +import six |
| 12 | + |
| 13 | + |
| 14 | +class GatherAddressListsTests(TestCase): |
| 15 | + def setUp(self): |
| 16 | + self.doc = WgDraftFactory(group__acronym='mars', rev='01') |
| 17 | + self.author_address = self.doc.name + '@ietf.org' |
| 18 | + |
| 19 | + def test_regular_trigger(self): |
| 20 | + to, cc = gather_address_lists('doc_pulled_from_rfc_queue', doc=self.doc) |
| 21 | + # Despite its name, assertCountEqual also compares content, but does not care for ordering |
| 22 | + six.assertCountEqual(self, to, ['iana@iana.org', 'rfc-editor@rfc-editor.org']) |
| 23 | + six.assertCountEqual(self, cc, ['The IESG <iesg@ietf.org>', self.author_address, |
| 24 | + 'mars-chairs@ietf.org', 'iesg-secretary@ietf.org']) |
| 25 | + |
| 26 | + def test_skipped_recipient(self): |
| 27 | + to, cc = gather_address_lists('doc_pulled_from_rfc_queue', doc=self.doc, |
| 28 | + skipped_recipients=['mars-chairs@ietf.org', 'iana@iana.org']) |
| 29 | + six.assertCountEqual(self, to, ['rfc-editor@rfc-editor.org']) |
| 30 | + six.assertCountEqual(self, cc, ['The IESG <iesg@ietf.org>', self.author_address, |
| 31 | + 'iesg-secretary@ietf.org']) |
| 32 | + |
| 33 | + def test_trigger_does_not_exist(self): |
| 34 | + with self.assertRaises(MailTrigger.DoesNotExist): |
| 35 | + gather_address_lists('this-does-not-exist______', doc=self.doc) |
| 36 | + |
| 37 | + def test_create_if_not_exists(self): |
| 38 | + new_slug = 'doc_pulled_from_rfc_special_autocreated' |
| 39 | + new_desc = 'Autocreated mailtrigger from doc_pulled_from_rfc_queue' |
| 40 | + to, cc = gather_address_lists(new_slug, doc=self.doc, desc_if_not_exists=new_desc, |
| 41 | + create_from_slug_if_not_exists='doc_pulled_from_rfc_queue') |
| 42 | + six.assertCountEqual(self, to, ['iana@iana.org', 'rfc-editor@rfc-editor.org']) |
| 43 | + six.assertCountEqual(self, cc, ['The IESG <iesg@ietf.org>', self.author_address, |
| 44 | + 'mars-chairs@ietf.org', 'iesg-secretary@ietf.org']) |
| 45 | + new_trigger = MailTrigger.objects.get(slug=new_slug) |
| 46 | + self.assertEqual(new_trigger.desc, new_desc) |
0 commit comments