|
6 | 6 | from django.db.models import Q |
7 | 7 | from django.test import Client |
8 | 8 |
|
| 9 | +import debug # pyflakes:ignore |
| 10 | + |
9 | 11 | from ietf.group.models import Role, Group |
| 12 | +from ietf.group.utils import get_group_role_emails, get_child_group_role_emails, get_group_ad_emails |
10 | 13 | from ietf.utils.test_data import make_test_data |
11 | 14 | from ietf.utils.test_utils import login_testing_unauthorized, TestCase, unicontent |
12 | 15 |
|
@@ -57,7 +60,7 @@ def test_stream_edit(self): |
57 | 60 |
|
58 | 61 |
|
59 | 62 | @skipIf(skip_dot_to_pdf, skip_message) |
60 | | -class GroupTests(TestCase): |
| 63 | +class GroupDocDependencyGraphTests(TestCase): |
61 | 64 |
|
62 | 65 | def test_group_document_dependency_dotfile(self): |
63 | 66 | make_test_data() |
@@ -85,3 +88,34 @@ def test_group_document_dependency_pdffile(self): |
85 | 88 | self.assertGreater(len(r.content), 0, "Pdf dependency graph for group " |
86 | 89 | "%s has no content"%group.acronym) |
87 | 90 |
|
| 91 | + |
| 92 | +class GroupRoleEmailTests(TestCase): |
| 93 | + |
| 94 | + def test_group_role_emails(self): |
| 95 | + make_test_data() |
| 96 | + wgs = Group.objects.filter(type='wg') |
| 97 | + for wg in wgs: |
| 98 | + chair_emails = get_group_role_emails(wg, ['chair']) |
| 99 | + secr_emails = get_group_role_emails(wg, ['secr']) |
| 100 | + self.assertIn("chairman", list(chair_emails)[0]) |
| 101 | + self.assertIn("secretary", list(secr_emails)[0]) |
| 102 | + both_emails = get_group_role_emails(wg, ['chair', 'secr']) |
| 103 | + self.assertEqual(secr_emails | chair_emails, both_emails) |
| 104 | + |
| 105 | + def test_child_group_role_emails(self): |
| 106 | + make_test_data() |
| 107 | + areas = Group.objects.filter(type='area') |
| 108 | + for area in areas: |
| 109 | + emails = get_child_group_role_emails(area, ['chair', 'secr']) |
| 110 | + self.assertGreater(len(emails), 0) |
| 111 | + for item in emails: |
| 112 | + self.assertIn('@', item) |
| 113 | + |
| 114 | + def test_group_ad_emails(self): |
| 115 | + make_test_data() |
| 116 | + wgs = Group.objects.filter(type='wg') |
| 117 | + for wg in wgs: |
| 118 | + emails = get_group_ad_emails(wg) |
| 119 | + self.assertGreater(len(emails), 0) |
| 120 | + for item in emails: |
| 121 | + self.assertIn('@', item) |
0 commit comments