~rashi007/mailman/docsfix

« back to all changes in this revision

Viewing changes to src/mailman/handlers/tests/test_recipients.py

  • Committer: Barry Warsaw
  • Date: 2015-01-05 01:20:33 UTC
  • mfrom: (7264.4.66 py3)
  • Revision ID: barry@list.org-20150105012033-zdrw9c2odhpf22fz
Merge the Python 3 branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
"""Testing various recipients stuff."""
19
19
 
20
 
from __future__ import absolute_import, print_function, unicode_literals
21
 
 
22
 
__metaclass__ = type
23
20
__all__ = [
24
21
    'TestMemberRecipients',
25
22
    'TestOwnerRecipients',
28
25
 
29
26
import unittest
30
27
 
31
 
from zope.component import getUtility
32
28
from mailman.app.lifecycle import create_list
33
29
from mailman.config import config
34
30
from mailman.interfaces.member import DeliveryMode, DeliveryStatus, MemberRole
35
31
from mailman.interfaces.usermanager import IUserManager
36
 
from mailman.testing.helpers import specialized_message_from_string as mfs
 
32
from mailman.testing.helpers import (
 
33
    configuration, specialized_message_from_string as mfs)
37
34
from mailman.testing.layers import ConfigLayer
 
35
from zope.component import getUtility
38
36
 
39
37
 
40
38
 
199
197
        self._process(self._mlist, self._msg, msgdata)
200
198
        self.assertEqual(msgdata['recipients'], set(('noreply@example.com',)))
201
199
 
202
 
    def test_site_admin_unicode(self):
203
 
        # Since the config file is read as bytes, the site_owner is also a
204
 
        # bytes and must be converted to unicode when used as a fallback.
 
200
    @configuration('mailman', site_owner='siteadmin@example.com')
 
201
    def test_no_owners_site_owner_fallback(self):
 
202
        # The list has no owners or moderators, but there is a non-default
 
203
        # site owner defined.  That owner gets the message.
205
204
        self._cris.unsubscribe()
206
205
        self._dave.unsubscribe()
207
206
        self.assertEqual(self._mlist.administrators.member_count, 0)
208
207
        msgdata = {}
209
 
        # In order to properly mimic the testing environment, use
210
 
        # config.push()/config.pop() directly instead of using the
211
 
        # configuration() context manager.
212
 
        config.push('test_site_admin_unicode', b"""\
213
 
[mailman]
214
 
site_owner: siteadmin@example.com
215
 
""")
216
 
        try:
217
 
            self._process(self._mlist, self._msg, msgdata)
218
 
        finally:
219
 
            config.pop('test_site_admin_unicode')
220
 
        self.assertEqual(len(msgdata['recipients']), 1)
221
 
        self.assertIsInstance(list(msgdata['recipients'])[0], unicode)
 
208
        self._process(self._mlist, self._msg, msgdata)
 
209
        self.assertEqual(msgdata['recipients'],
 
210
                         set(('siteadmin@example.com',)))