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