summaryrefslogtreecommitdiff
path: root/src/mailman/runners/tests
diff options
context:
space:
mode:
authorBarry Warsaw2015-01-04 20:20:33 -0500
committerBarry Warsaw2015-01-04 20:20:33 -0500
commit4a612db8e89afed74173b93f3b64fa567b8417a3 (patch)
tree81a687d113079a25f93279f35c7eee2aa2572510 /src/mailman/runners/tests
parent84af79988a4e916604cba31843778206efb7d1b8 (diff)
parentde181c1a40965a3a7deedd56a034a946f45b6984 (diff)
downloadmailman-4a612db8e89afed74173b93f3b64fa567b8417a3.tar.gz
mailman-4a612db8e89afed74173b93f3b64fa567b8417a3.tar.zst
mailman-4a612db8e89afed74173b93f3b64fa567b8417a3.zip
Merge the Python 3 branch.
Diffstat (limited to 'src/mailman/runners/tests')
-rw-r--r--src/mailman/runners/tests/test_archiver.py25
-rw-r--r--src/mailman/runners/tests/test_bounce.py16
-rw-r--r--src/mailman/runners/tests/test_confirm.py23
-rw-r--r--src/mailman/runners/tests/test_digest.py83
-rw-r--r--src/mailman/runners/tests/test_incoming.py10
-rw-r--r--src/mailman/runners/tests/test_join.py22
-rw-r--r--src/mailman/runners/tests/test_lmtp.py40
-rw-r--r--src/mailman/runners/tests/test_nntp.py39
-rw-r--r--src/mailman/runners/tests/test_outgoing.py60
-rw-r--r--src/mailman/runners/tests/test_owner.py14
-rw-r--r--src/mailman/runners/tests/test_pipeline.py13
-rw-r--r--src/mailman/runners/tests/test_rest.py3
-rw-r--r--src/mailman/runners/tests/test_retry.py8
13 files changed, 203 insertions, 153 deletions
diff --git a/src/mailman/runners/tests/test_archiver.py b/src/mailman/runners/tests/test_archiver.py
index e11b6c805..9e3d9626c 100644
--- a/src/mailman/runners/tests/test_archiver.py
+++ b/src/mailman/runners/tests/test_archiver.py
@@ -17,9 +17,6 @@
"""Test the archive runner."""
-from __future__ import absolute_import, print_function, unicode_literals
-
-__metaclass__ = type
__all__ = [
'TestArchiveRunner',
]
@@ -29,19 +26,17 @@ import os
import unittest
from email import message_from_file
-from zope.interface import implementer
-
from mailman.app.lifecycle import create_list
from mailman.config import config
from mailman.interfaces.archiver import IArchiver
from mailman.interfaces.mailinglist import IListArchiverSet
from mailman.runners.archive import ArchiveRunner
from mailman.testing.helpers import (
- configuration,
- make_testable_runner,
+ configuration, make_testable_runner,
specialized_message_from_string as mfs)
from mailman.testing.layers import ConfigLayer
from mailman.utilities.datetime import RFC822_DATE_FMT, factory, now
+from zope.interface import implementer
@@ -110,7 +105,7 @@ First post!
# Ensure that the archive runner ends up archiving the message.
self._archiveq.enqueue(
self._msg, {},
- listname=self._mlist.fqdn_listname,
+ listid=self._mlist.list_id,
received_time=now())
self._runner.run()
# There should now be a copy of the message in the file system.
@@ -126,7 +121,7 @@ First post!
self._msg['Date'] = now(strip_tzinfo=False).strftime(RFC822_DATE_FMT)
self._archiveq.enqueue(
self._msg, {},
- listname=self._mlist.fqdn_listname,
+ listid=self._mlist.list_id,
received_time=now())
self._runner.run()
# There should now be a copy of the message in the file system.
@@ -144,7 +139,7 @@ First post!
self._msg['Date'] = now(strip_tzinfo=False).strftime(RFC822_DATE_FMT)
self._archiveq.enqueue(
self._msg, {},
- listname=self._mlist.fqdn_listname,
+ listid=self._mlist.list_id,
received_time=now())
self._runner.run()
# There should now be a copy of the message in the file system.
@@ -163,7 +158,7 @@ First post!
# again), fast forward a few days.
self._archiveq.enqueue(
self._msg, {},
- listname=self._mlist.fqdn_listname,
+ listid=self._mlist.list_id,
received_time=now(strip_tzinfo=False))
self._runner.run()
# There should now be a copy of the message in the file system.
@@ -182,7 +177,7 @@ First post!
# again as will happen in the runner), fast forward a few days.
self._archiveq.enqueue(
self._msg, {},
- listname=self._mlist.fqdn_listname)
+ listid=self._mlist.list_id)
factory.fast_forward(days=4)
self._runner.run()
# There should now be a copy of the message in the file system.
@@ -205,7 +200,7 @@ First post!
# again as will happen in the runner), fast forward a few days.
self._archiveq.enqueue(
self._msg, {},
- listname=self._mlist.fqdn_listname)
+ listid=self._mlist.list_id)
factory.fast_forward(days=4)
self._runner.run()
# There should now be a copy of the message in the file system.
@@ -228,7 +223,7 @@ First post!
# again as will happen in the runner), fast forward a few days.
self._archiveq.enqueue(
self._msg, {},
- listname=self._mlist.fqdn_listname)
+ listid=self._mlist.list_id)
factory.fast_forward(days=4)
self._runner.run()
# There should now be a copy of the message in the file system.
@@ -249,6 +244,6 @@ First post!
config.db.store.commit()
self._archiveq.enqueue(
self._msg, {},
- listname=self._mlist.fqdn_listname)
+ listid=self._mlist.list_id)
self._runner.run()
self.assertEqual(os.listdir(config.MESSAGES_DIR), [])
diff --git a/src/mailman/runners/tests/test_bounce.py b/src/mailman/runners/tests/test_bounce.py
index 315a81c22..875437dc2 100644
--- a/src/mailman/runners/tests/test_bounce.py
+++ b/src/mailman/runners/tests/test_bounce.py
@@ -17,9 +17,6 @@
"""Test the bounce runner."""
-from __future__ import absolute_import, print_function, unicode_literals
-
-__metaclass__ = type
__all__ = [
'TestBounceRunner',
'TestBounceRunnerBug876774',
@@ -29,9 +26,6 @@ __all__ = [
import unittest
-from zope.component import getUtility
-from zope.interface import implementer
-
from mailman.app.bounces import send_probe
from mailman.app.lifecycle import create_list
from mailman.config import config
@@ -42,11 +36,11 @@ from mailman.interfaces.styles import IStyle, IStyleManager
from mailman.interfaces.usermanager import IUserManager
from mailman.runners.bounce import BounceRunner
from mailman.testing.helpers import (
- LogFileMark,
- get_queue_messages,
- make_testable_runner,
+ LogFileMark, get_queue_messages, make_testable_runner,
specialized_message_from_string as message_from_string)
from mailman.testing.layers import ConfigLayer
+from zope.component import getUtility
+from zope.interface import implementer
@@ -69,7 +63,7 @@ To: test-bounces+anne=example.com@example.com
Message-Id: <first>
""")
- self._msgdata = dict(listname='test@example.com')
+ self._msgdata = dict(listid='test.example.com')
self._processor = getUtility(IBounceProcessor)
config.push('site owner', """
[mailman]
@@ -284,7 +278,7 @@ To: test-bounces+anne=example.com@example.com
Message-Id: <first>
""")
- self._bounceq.enqueue(bounce, dict(listname='test@example.com'))
+ self._bounceq.enqueue(bounce, dict(listid='test.example.com'))
self.assertEqual(len(self._bounceq.files), 1)
self._runner.run()
self.assertEqual(len(get_queue_messages('bounces')), 0)
diff --git a/src/mailman/runners/tests/test_confirm.py b/src/mailman/runners/tests/test_confirm.py
index 40fae368f..11514044a 100644
--- a/src/mailman/runners/tests/test_confirm.py
+++ b/src/mailman/runners/tests/test_confirm.py
@@ -17,9 +17,6 @@
"""Test the `confirm` command."""
-from __future__ import absolute_import, print_function, unicode_literals
-
-__metaclass__ = type
__all__ = [
'TestConfirm',
]
@@ -29,8 +26,6 @@ import unittest
from datetime import datetime
from email.iterators import body_line_iterator
-from zope.component import getUtility
-
from mailman.app.lifecycle import create_list
from mailman.config import config
from mailman.database.transaction import transaction
@@ -38,10 +33,10 @@ from mailman.interfaces.registrar import IRegistrar
from mailman.interfaces.usermanager import IUserManager
from mailman.runners.command import CommandRunner
from mailman.testing.helpers import (
- get_queue_messages,
- make_testable_runner,
+ get_queue_messages, make_testable_runner,
specialized_message_from_string as mfs)
from mailman.testing.layers import ConfigLayer
+from zope.component import getUtility
@@ -68,7 +63,7 @@ To: test-confirm@example.com
""")
msg['Subject'] = subject
- self._commandq.enqueue(msg, dict(listname='test@example.com'))
+ self._commandq.enqueue(msg, dict(listid='test.example.com'))
self._runner.run()
# Anne is now a confirmed member so her user record and email address
# should exist in the database.
@@ -88,7 +83,7 @@ To: test-confirm@example.com
""")
msg['Subject'] = subject
- self._commandq.enqueue(msg, dict(listname='test@example.com'))
+ self._commandq.enqueue(msg, dict(listid='test.example.com'))
self._runner.run()
# Anne is now a confirmed member so her user record and email address
# should exist in the database.
@@ -144,7 +139,7 @@ Franziskanerstra=C3=9Fe
""")
msg['Subject'] = subject
msg['To'] = to
- self._commandq.enqueue(msg, dict(listname='test@example.com'))
+ self._commandq.enqueue(msg, dict(listid='test.example.com'))
self._runner.run()
# Anne is now a confirmed member so her user record and email address
# should exist in the database.
@@ -177,7 +172,7 @@ Franziskanerstra=C3=9Fe
""")
msg['Subject'] = subject
msg['To'] = to
- self._commandq.enqueue(msg, dict(listname='test@example.com'))
+ self._commandq.enqueue(msg, dict(listid='test.example.com'))
self._runner.run()
# Anne is now a confirmed member so her user record and email address
# should exist in the database.
@@ -208,7 +203,7 @@ From: Anne Person <anne@example.org>
""")
msg['Subject'] = subject
msg['To'] = to
- self._commandq.enqueue(msg, dict(listname='test@example.com',
+ self._commandq.enqueue(msg, dict(listid='test.example.com',
subaddress='confirm'))
self._runner.run()
# Anne is now a confirmed member so her user record and email address
@@ -223,7 +218,7 @@ From: Anne Person <anne@example.org>
# one 'Confirmation email' line.
confirmation_lines = []
in_results = False
- for line in body_line_iterator(messages[0].msg, decode=True):
+ for line in body_line_iterator(messages[0].msg):
line = line.strip()
if in_results:
if line.startswith('- Done'):
@@ -253,7 +248,7 @@ From: Anne Person <anne@example.org>
""")
msg['Subject'] = subject
msg['To'] = to
- self._commandq.enqueue(msg, dict(listname='test@example.com',
+ self._commandq.enqueue(msg, dict(listid='test.example.com',
subaddress='confirm'))
self._runner.run()
# Now there's a email command notification and a welcome message. All
diff --git a/src/mailman/runners/tests/test_digest.py b/src/mailman/runners/tests/test_digest.py
index fb1bb7071..83156f04e 100644
--- a/src/mailman/runners/tests/test_digest.py
+++ b/src/mailman/runners/tests/test_digest.py
@@ -17,26 +17,25 @@
"""Test the digest runner."""
-from __future__ import absolute_import, print_function, unicode_literals
-
-__metaclass__ = type
__all__ = [
'TestDigest',
+ 'TestI18nDigest',
]
import unittest
-from StringIO import StringIO
from email.iterators import _structure as structure
from email.mime.text import MIMEText
+from io import StringIO
from mailman.app.lifecycle import create_list
from mailman.config import config
from mailman.email.message import Message
from mailman.runners.digest import DigestRunner
from mailman.testing.helpers import (
LogFileMark, digest_mbox, get_queue_messages, make_digest_messages,
- make_testable_runner, message_from_string)
+ make_testable_runner, message_from_string,
+ specialized_message_from_string as mfs)
from mailman.testing.layers import ConfigLayer
from string import Template
@@ -140,3 +139,77 @@ multipart/mixed
text/plain
text/plain
""")
+
+
+
+class TestI18nDigest(unittest.TestCase):
+ layer = ConfigLayer
+ maxDiff = None
+
+ def setUp(self):
+ config.push('french', """
+ [mailman]
+ default_language: fr
+ """)
+ self.addCleanup(config.pop, 'french')
+ self._mlist = create_list('test@example.com')
+ self._mlist.preferred_language = 'fr'
+ self._mlist.digest_size_threshold = 0
+ self._process = config.handlers['to-digest'].process
+ self._runner = make_testable_runner(DigestRunner)
+
+ def test_multilingual_digest(self):
+ # When messages come in with a content-type character set different
+ # than that of the list's preferred language, recipients will get an
+ # internationalized digest.
+ msg = mfs("""\
+From: aperson@example.org
+To: test@example.com
+Subject: =?iso-2022-jp?b?GyRCMGxIVhsoQg==?=
+MIME-Version: 1.0
+Content-Type: text/plain; charset=iso-2022-jp
+Content-Transfer-Encoding: 7bit
+
+\x1b$B0lHV\x1b(B
+""")
+ self._process(self._mlist, msg, {})
+ self._runner.run()
+ # There are two digests in the virgin queue; one is the MIME digest
+ # and the other is the RFC 1153 digest.
+ messages = get_queue_messages('virgin')
+ self.assertEqual(len(messages), 2)
+ if messages[0].msg.is_multipart():
+ mime, rfc1153 = messages[0].msg, messages[1].msg
+ else:
+ rfc1153, mime = messages[0].msg, messages[1].msg
+ # The MIME version contains a mix of French and Japanese. The digest
+ # chrome added by Mailman is in French.
+ self.assertEqual(mime['subject'].encode(),
+ '=?iso-8859-1?q?Groupe_Test=2C_Vol_1=2C_Parution_1?=')
+ self.assertEqual(str(mime['subject']),
+ 'Groupe Test, Vol 1, Parution 1')
+ # The first subpart contains the iso-8859-1 masthead.
+ masthead = mime.get_payload(0).get_payload(decode=True).decode(
+ 'iso-8859-1')
+ self.assertMultiLineEqual(masthead.splitlines()[0],
+ 'Envoyez vos messages pour la liste Test à')
+ # The second subpart contains the utf-8 table of contents.
+ self.assertEqual(mime.get_payload(1)['content-description'],
+ "Today's Topics (1 messages)")
+ toc = mime.get_payload(1).get_payload(decode=True).decode('utf-8')
+ self.assertMultiLineEqual(toc.splitlines()[0], 'Thèmes du jour :')
+ # The third subpart contains the posted message in Japanese.
+ self.assertEqual(mime.get_payload(2).get_content_type(),
+ 'message/rfc822')
+ post = mime.get_payload(2).get_payload(0)
+ self.assertEqual(post['subject'], '=?iso-2022-jp?b?GyRCMGxIVhsoQg==?=')
+ # Compare the bytes so that this module doesn't contain string
+ # literals in multiple incompatible character sets.
+ self.assertEqual(post.get_payload(decode=True), b'\x1b$B0lHV\x1b(B\n')
+ # The RFC 1153 digest will have the same subject, but its payload will
+ # be recast into utf-8.
+ self.assertEqual(str(rfc1153['subject']),
+ 'Groupe Test, Vol 1, Parution 1')
+ self.assertEqual(rfc1153.get_charset(), 'utf-8')
+ lines = rfc1153.get_payload(decode=True).decode('utf-8').splitlines()
+ self.assertEqual(lines[0], 'Envoyez vos messages pour la liste Test à')
diff --git a/src/mailman/runners/tests/test_incoming.py b/src/mailman/runners/tests/test_incoming.py
index 9830fedb9..77fe2da02 100644
--- a/src/mailman/runners/tests/test_incoming.py
+++ b/src/mailman/runners/tests/test_incoming.py
@@ -17,9 +17,6 @@
"""Test the incoming queue runner."""
-from __future__ import absolute_import, print_function, unicode_literals
-
-__metaclass__ = type
__all__ = [
'TestIncoming',
]
@@ -32,8 +29,7 @@ from mailman.chains.base import TerminalChainBase
from mailman.config import config
from mailman.runners.incoming import IncomingRunner
from mailman.testing.helpers import (
- get_queue_messages,
- make_testable_runner,
+ get_queue_messages, make_testable_runner,
specialized_message_from_string as mfs)
from mailman.testing.layers import ConfigLayer
@@ -76,7 +72,7 @@ To: test@example.com
def test_posting(self):
# A message posted to the list goes through the posting chain.
- msgdata = dict(listname='test@example.com')
+ msgdata = dict(listid='test.example.com')
config.switchboards['in'].enqueue(self._msg, msgdata)
self._in.run()
messages = get_queue_messages('out')
@@ -85,7 +81,7 @@ To: test@example.com
def test_owner(self):
# A message posted to the list goes through the posting chain.
- msgdata = dict(listname='test@example.com',
+ msgdata = dict(listid='test.example.com',
to_owner=True)
config.switchboards['in'].enqueue(self._msg, msgdata)
self._in.run()
diff --git a/src/mailman/runners/tests/test_join.py b/src/mailman/runners/tests/test_join.py
index fbea9e661..df24bc06b 100644
--- a/src/mailman/runners/tests/test_join.py
+++ b/src/mailman/runners/tests/test_join.py
@@ -17,9 +17,6 @@
"""Test mailing list joins."""
-from __future__ import absolute_import, print_function, unicode_literals
-
-__metaclass__ = type
__all__ = [
'TestJoin',
'TestJoinWithDigests',
@@ -29,8 +26,6 @@ __all__ = [
import unittest
from email.iterators import body_line_iterator
-from zope.component import getUtility
-
from mailman.app.lifecycle import create_list
from mailman.config import config
from mailman.interfaces.member import DeliveryMode
@@ -42,6 +37,7 @@ from mailman.testing.helpers import (
get_queue_messages, make_testable_runner, reset_the_world,
specialized_message_from_string as mfs)
from mailman.testing.layers import ConfigLayer
+from zope.component import getUtility
@@ -72,7 +68,7 @@ subscribe
# Adding the subaddress to the metadata dictionary mimics what happens
# when the above email message is first processed by the lmtp runner.
# For convenience, we skip that step in this test.
- self._commandq.enqueue(msg, dict(listname='test@example.com',
+ self._commandq.enqueue(msg, dict(listid='test.example.com',
subaddress='join'))
self._runner.run()
# There will be two messages in the queue. The first one is a reply
@@ -87,7 +83,7 @@ subscribe
# one 'Confirmation email' line.
confirmation_lines = []
in_results = False
- for line in body_line_iterator(messages[0].msg, decode=True):
+ for line in body_line_iterator(messages[0].msg):
line = line.strip()
if in_results:
if line.startswith('- Done'):
@@ -112,7 +108,7 @@ To: test-join@example.com
Subject: join
""")
- self._commandq.enqueue(msg, dict(listname='test@example.com'))
+ self._commandq.enqueue(msg, dict(listid='test.example.com'))
self._runner.run()
# There will be one message in the queue - a reply to Anne notifying
# her of the status of her command email. Because Anne is already
@@ -125,7 +121,7 @@ Subject: join
# one 'Confirmation email' line.
confirmation_lines = []
in_results = False
- for line in body_line_iterator(messages[0].msg, decode=True):
+ for line in body_line_iterator(messages[0].msg):
line = line.strip()
if in_results:
if line.startswith('- Done'):
@@ -181,7 +177,7 @@ To: test-request@example.com
join
""")
- self._commandq.enqueue(msg, dict(listname='test@example.com'))
+ self._commandq.enqueue(msg, dict(listid='test.example.com'))
self._runner.run()
anne = self._confirm()
self.assertEqual(anne.address.email, 'anne@example.org')
@@ -195,7 +191,7 @@ To: test-request@example.com
join digest=no
""")
- self._commandq.enqueue(msg, dict(listname='test@example.com'))
+ self._commandq.enqueue(msg, dict(listid='test.example.com'))
self._runner.run()
anne = self._confirm()
self.assertEqual(anne.address.email, 'anne@example.org')
@@ -209,7 +205,7 @@ To: test-request@example.com
join digest=mime
""")
- self._commandq.enqueue(msg, dict(listname='test@example.com'))
+ self._commandq.enqueue(msg, dict(listid='test.example.com'))
self._runner.run()
anne = self._confirm()
self.assertEqual(anne.address.email, 'anne@example.org')
@@ -223,7 +219,7 @@ To: test-request@example.com
join digest=plain
""")
- self._commandq.enqueue(msg, dict(listname='test@example.com'))
+ self._commandq.enqueue(msg, dict(listid='test.example.com'))
self._runner.run()
anne = self._confirm()
self.assertEqual(anne.address.email, 'anne@example.org')
diff --git a/src/mailman/runners/tests/test_lmtp.py b/src/mailman/runners/tests/test_lmtp.py
index 26308548c..44b6a0889 100644
--- a/src/mailman/runners/tests/test_lmtp.py
+++ b/src/mailman/runners/tests/test_lmtp.py
@@ -17,9 +17,6 @@
"""Tests for the LMTP server."""
-from __future__ import absolute_import, print_function, unicode_literals
-
-__metaclass__ = type
__all__ = [
'TestLMTP',
]
@@ -30,7 +27,6 @@ import smtplib
import unittest
from datetime import datetime
-
from mailman.config import config
from mailman.app.lifecycle import create_list
from mailman.database.transaction import transaction
@@ -67,7 +63,7 @@ Subject: This has no Message-ID header
# reasons)
self.assertEqual(cm.exception.smtp_code, 550)
self.assertEqual(cm.exception.smtp_error,
- 'No Message-ID header provided')
+ b'No Message-ID header provided')
def test_message_id_hash_is_added(self):
self._lmtp.sendmail('anne@example.com', ['test@example.com'], """\
@@ -118,6 +114,36 @@ Message-ID: <ant>
queue_directory = os.path.join(config.QUEUE_DIR, 'lmtp')
self.assertFalse(os.path.isdir(queue_directory))
+ def test_nonexistent_mailing_list(self):
+ # Trying to post to a nonexistent mailing list is an error.
+ with self.assertRaises(smtplib.SMTPDataError) as cm:
+ self._lmtp.sendmail('anne@example.com',
+ ['notalist@example.com'], """\
+From: anne.person@example.com
+To: notalist@example.com
+Subject: An interesting message
+Message-ID: <aardvark>
+
+""")
+ self.assertEqual(cm.exception.smtp_code, 550)
+ self.assertEqual(cm.exception.smtp_error,
+ b'Requested action not taken: mailbox unavailable')
+
+ def test_missing_subaddress(self):
+ # Trying to send a message to a bogus subaddress is an error.
+ with self.assertRaises(smtplib.SMTPDataError) as cm:
+ self._lmtp.sendmail('anne@example.com',
+ ['test-bogus@example.com'], """\
+From: anne.person@example.com
+To: test-bogus@example.com
+Subject: An interesting message
+Message-ID: <aardvark>
+
+""")
+ self.assertEqual(cm.exception.smtp_code, 550)
+ self.assertEqual(cm.exception.smtp_error,
+ b'Requested action not taken: mailbox unavailable')
+
class TestBugs(unittest.TestCase):
@@ -142,5 +168,5 @@ Message-ID: <alpha>
""")
messages = get_queue_messages('in')
self.assertEqual(len(messages), 1)
- self.assertEqual(messages[0].msgdata['listname'],
- 'my-list@example.com')
+ self.assertEqual(messages[0].msgdata['listid'],
+ 'my-list.example.com')
diff --git a/src/mailman/runners/tests/test_nntp.py b/src/mailman/runners/tests/test_nntp.py
index 3570d1a6f..e3218af33 100644
--- a/src/mailman/runners/tests/test_nntp.py
+++ b/src/mailman/runners/tests/test_nntp.py
@@ -17,9 +17,6 @@
"""Test the NNTP runner and related utilities."""
-from __future__ import absolute_import, print_function, unicode_literals
-
-__metaclass__ = type
__all__ = [
'TestPrepareMessage',
'TestNNTPRunner',
@@ -36,10 +33,7 @@ from mailman.config import config
from mailman.interfaces.nntp import NewsgroupModeration
from mailman.runners import nntp
from mailman.testing.helpers import (
- LogFileMark,
- configuration,
- get_queue_messages,
- make_testable_runner,
+ LogFileMark, configuration, get_queue_messages, make_testable_runner,
specialized_message_from_string as mfs)
from mailman.testing.layers import ConfigLayer
@@ -257,7 +251,7 @@ Testing
@mock.patch('nntplib.NNTP')
def test_connect(self, class_mock):
# Test connection to the NNTP server with default values.
- self._nntpq.enqueue(self._msg, {}, listname='test@example.com')
+ self._nntpq.enqueue(self._msg, {}, listid='test.example.com')
self._runner.run()
class_mock.assert_called_once_with(
'', 119, user='', password='', readermode=True)
@@ -267,7 +261,7 @@ Testing
@mock.patch('nntplib.NNTP')
def test_connect_with_configuration(self, class_mock):
# Test connection to the NNTP server with specific values.
- self._nntpq.enqueue(self._msg, {}, listname='test@example.com')
+ self._nntpq.enqueue(self._msg, {}, listid='test.example.com')
self._runner.run()
class_mock.assert_called_once_with(
'nntp.example.com', 2112,
@@ -276,7 +270,7 @@ Testing
@mock.patch('nntplib.NNTP')
def test_post(self, class_mock):
# Test that the message is posted to the NNTP server.
- self._nntpq.enqueue(self._msg, {}, listname='test@example.com')
+ self._nntpq.enqueue(self._msg, {}, listid='test.example.com')
self._runner.run()
# Get the mocked instance, which was used in the runner.
conn_mock = class_mock()
@@ -295,7 +289,7 @@ Testing
def test_connection_got_quit(self, class_mock):
# The NNTP connection gets closed after a successful post.
# Test that the message is posted to the NNTP server.
- self._nntpq.enqueue(self._msg, {}, listname='test@example.com')
+ self._nntpq.enqueue(self._msg, {}, listid='test.example.com')
self._runner.run()
# Get the mocked instance, which was used in the runner.
conn_mock = class_mock()
@@ -304,18 +298,19 @@ Testing
# and make some simple checks that the message is what we expected.
conn_mock.quit.assert_called_once_with()
- @mock.patch('nntplib.NNTP', side_effect=nntplib.error_temp)
+ @mock.patch('nntplib.NNTP', side_effect=nntplib.NNTPTemporaryError)
def test_connect_with_nntplib_failure(self, class_mock):
- self._nntpq.enqueue(self._msg, {}, listname='test@example.com')
+ self._nntpq.enqueue(self._msg, {}, listid='test.example.com')
mark = LogFileMark('mailman.error')
self._runner.run()
log_message = mark.readline()[:-1]
- self.assertTrue(log_message.endswith(
- 'NNTP error for test@example.com'))
+ self.assertTrue(
+ log_message.endswith('NNTP error for test@example.com'),
+ log_message)
@mock.patch('nntplib.NNTP', side_effect=socket.error)
def test_connect_with_socket_failure(self, class_mock):
- self._nntpq.enqueue(self._msg, {}, listname='test@example.com')
+ self._nntpq.enqueue(self._msg, {}, listid='test.example.com')
mark = LogFileMark('mailman.error')
self._runner.run()
log_message = mark.readline()[:-1]
@@ -330,7 +325,7 @@ Testing
# I.e. stop immediately, since the queue will not be empty.
return True
runner = make_testable_runner(nntp.NNTPRunner, 'nntp', predicate=once)
- self._nntpq.enqueue(self._msg, {}, listname='test@example.com')
+ self._nntpq.enqueue(self._msg, {}, listid='test.example.com')
mark = LogFileMark('mailman.error')
runner.run()
log_message = mark.readline()[:-1]
@@ -338,14 +333,14 @@ Testing
'NNTP unexpected exception for test@example.com'))
messages = get_queue_messages('nntp')
self.assertEqual(len(messages), 1)
- self.assertEqual(messages[0].msgdata['listname'], 'test@example.com')
+ self.assertEqual(messages[0].msgdata['listid'], 'test.example.com')
self.assertEqual(messages[0].msg['subject'], 'A newsgroup posting')
- @mock.patch('nntplib.NNTP', side_effect=nntplib.error_temp)
+ @mock.patch('nntplib.NNTP', side_effect=nntplib.NNTPTemporaryError)
def test_connection_never_gets_quit_after_failures(self, class_mock):
# The NNTP connection doesn't get closed after a unsuccessful
# connection, since there's nothing to close.
- self._nntpq.enqueue(self._msg, {}, listname='test@example.com')
+ self._nntpq.enqueue(self._msg, {}, listid='test.example.com')
self._runner.run()
# Get the mocked instance, which was used in the runner. Turn off the
# exception raising side effect first though!
@@ -361,8 +356,8 @@ Testing
# The NNTP connection does get closed after a unsuccessful post.
# Add a side-effect to the instance mock's .post() method.
conn_mock = class_mock()
- conn_mock.post.side_effect = nntplib.error_temp
- self._nntpq.enqueue(self._msg, {}, listname='test@example.com')
+ conn_mock.post.side_effect = nntplib.NNTPTemporaryError
+ self._nntpq.enqueue(self._msg, {}, listid='test.example.com')
self._runner.run()
# The connection object's post() method was called once with a
# file-like object containing the message's bytes. Read those bytes
diff --git a/src/mailman/runners/tests/test_outgoing.py b/src/mailman/runners/tests/test_outgoing.py
index 62f6776b1..8f51c4ce2 100644
--- a/src/mailman/runners/tests/test_outgoing.py
+++ b/src/mailman/runners/tests/test_outgoing.py
@@ -17,10 +17,11 @@
"""Test the outgoing runner."""
-from __future__ import absolute_import, print_function, unicode_literals
-
-__metaclass__ = type
__all__ = [
+ 'TestOnce',
+ 'TestSocketError',
+ 'TestSomeRecipientsFailed',
+ 'TestVERPSettings',
]
@@ -32,8 +33,6 @@ import unittest
from contextlib import contextmanager
from datetime import datetime, timedelta
from lazr.config import as_timedelta
-from zope.component import getUtility
-
from mailman.app.bounces import send_probe
from mailman.app.lifecycle import create_list
from mailman.config import config
@@ -45,12 +44,11 @@ from mailman.interfaces.pending import IPendings
from mailman.interfaces.usermanager import IUserManager
from mailman.runners.outgoing import OutgoingRunner
from mailman.testing.helpers import (
- LogFileMark,
- get_queue_messages,
- make_testable_runner,
+ LogFileMark, get_queue_messages, make_testable_runner,
specialized_message_from_string as message_from_string)
from mailman.testing.layers import ConfigLayer, SMTPLayer
from mailman.utilities.datetime import factory, now
+from zope.component import getUtility
@@ -96,7 +94,7 @@ Message-Id: <first>
deliver_after = now() + timedelta(days=10)
self._msgdata['deliver_after'] = deliver_after
self._outq.enqueue(self._msg, self._msgdata,
- tolist=True, listname='test@example.com')
+ tolist=True, listid='test.example.com')
self._runner.run()
items = get_queue_messages('out')
self.assertEqual(len(items), 1)
@@ -149,20 +147,20 @@ Message-Id: <first>
def test_delivery_callback(self):
# Test that the configuration variable calls the appropriate callback.
- self._outq.enqueue(self._msg, {}, listname='test@example.com')
+ self._outq.enqueue(self._msg, {}, listid='test.example.com')
self._runner.run()
self.assertEqual(captured_mlist, self._mlist)
self.assertEqual(captured_msg.as_string(), self._msg.as_string())
# Of course, the message metadata will contain a bunch of keys added
# by the processing. We don't really care about the details, so this
# test is a good enough stand-in.
- self.assertEqual(captured_msgdata['listname'], 'test@example.com')
+ self.assertEqual(captured_msgdata['listid'], 'test.example.com')
def test_verp_in_metadata(self):
# Test that if the metadata has a 'verp' key, it is unchanged.
marker = 'yepper'
msgdata = dict(verp=marker)
- self._outq.enqueue(self._msg, msgdata, listname='test@example.com')
+ self._outq.enqueue(self._msg, msgdata, listid='test.example.com')
self._runner.run()
self.assertEqual(captured_msgdata['verp'], marker)
@@ -171,7 +169,7 @@ Message-Id: <first>
# indicates, messages will be VERP'd.
msgdata = {}
self._mlist.personalize = Personalization.individual
- self._outq.enqueue(self._msg, msgdata, listname='test@example.com')
+ self._outq.enqueue(self._msg, msgdata, listid='test.example.com')
with temporary_config('personalize', """
[mta]
verp_personalized_deliveries: yes
@@ -184,7 +182,7 @@ Message-Id: <first>
# indicates, messages will be VERP'd.
msgdata = {}
self._mlist.personalize = Personalization.full
- self._outq.enqueue(self._msg, msgdata, listname='test@example.com')
+ self._outq.enqueue(self._msg, msgdata, listid='test.example.com')
with temporary_config('personalize', """
[mta]
verp_personalized_deliveries: yes
@@ -197,14 +195,14 @@ Message-Id: <first>
# does not indicate, messages will not be VERP'd.
msgdata = {}
self._mlist.personalize = Personalization.full
- self._outq.enqueue(self._msg, msgdata, listname='test@example.com')
+ self._outq.enqueue(self._msg, msgdata, listid='test.example.com')
self._runner.run()
self.assertFalse('verp' in captured_msgdata)
def test_verp_never(self):
# Never VERP when the interval is zero.
msgdata = {}
- self._outq.enqueue(self._msg, msgdata, listname='test@example.com')
+ self._outq.enqueue(self._msg, msgdata, listid='test.example.com')
with temporary_config('personalize', """
[mta]
verp_delivery_interval: 0
@@ -215,7 +213,7 @@ Message-Id: <first>
def test_verp_always(self):
# Always VERP when the interval is one.
msgdata = {}
- self._outq.enqueue(self._msg, msgdata, listname='test@example.com')
+ self._outq.enqueue(self._msg, msgdata, listid='test.example.com')
with temporary_config('personalize', """
[mta]
verp_delivery_interval: 1
@@ -227,7 +225,7 @@ Message-Id: <first>
# VERP every so often, when the post_id matches.
self._mlist.post_id = 5
msgdata = {}
- self._outq.enqueue(self._msg, msgdata, listname='test@example.com')
+ self._outq.enqueue(self._msg, msgdata, listid='test.example.com')
with temporary_config('personalize', """
[mta]
verp_delivery_interval: 5
@@ -239,7 +237,7 @@ Message-Id: <first>
# VERP every so often, when the post_id matches.
self._mlist.post_id = 4
msgdata = {}
- self._outq.enqueue(self._msg, msgdata, listname='test@example.com')
+ self._outq.enqueue(self._msg, msgdata, listid='test.example.com')
with temporary_config('personalize', """
[mta]
verp_delivery_interval: 5
@@ -287,7 +285,7 @@ Message-Id: <first>
error_log = logging.getLogger('mailman.error')
filename = error_log.handlers[0].filename
filepos = os.stat(filename).st_size
- self._outq.enqueue(self._msg, {}, listname='test@example.com')
+ self._outq.enqueue(self._msg, {}, listid='test.example.com')
with temporary_config('port 0', """
[mta]
smtp_port: 0
@@ -308,7 +306,7 @@ Message-Id: <first>
# that is a log message. Start by opening the error log and reading
# the current file position.
mark = LogFileMark('mailman.error')
- self._outq.enqueue(self._msg, {}, listname='test@example.com')
+ self._outq.enqueue(self._msg, {}, listid='test.example.com')
with temporary_config('port 0', """
[mta]
smtp_port: 2112
@@ -369,7 +367,7 @@ Message-Id: <first>
token = send_probe(member, self._msg)
msgdata = dict(probe_token=token)
permanent_failures.append('anne@example.com')
- self._outq.enqueue(self._msg, msgdata, listname='test@example.com')
+ self._outq.enqueue(self._msg, msgdata, listid='test.example.com')
self._runner.run()
events = list(self._processor.unprocessed)
self.assertEqual(len(events), 1)
@@ -390,7 +388,7 @@ Message-Id: <first>
getUtility(IPendings).confirm(token)
msgdata = dict(probe_token=token)
permanent_failures.append('anne@example.com')
- self._outq.enqueue(self._msg, msgdata, listname='test@example.com')
+ self._outq.enqueue(self._msg, msgdata, listid='test.example.com')
self._runner.run()
events = list(self._processor.unprocessed)
self.assertEqual(len(events), 0)
@@ -404,7 +402,7 @@ Message-Id: <first>
getUtility(IPendings).confirm(token)
msgdata = dict(probe_token=token)
temporary_failures.append('anne@example.com')
- self._outq.enqueue(self._msg, msgdata, listname='test@example.com')
+ self._outq.enqueue(self._msg, msgdata, listid='test.example.com')
self._runner.run()
events = list(self._processor.unprocessed)
self.assertEqual(len(events), 0)
@@ -412,7 +410,7 @@ Message-Id: <first>
def test_one_permanent_failure(self):
# Normal (i.e. non-probe) permanent failures just get registered.
permanent_failures.append('anne@example.com')
- self._outq.enqueue(self._msg, {}, listname='test@example.com')
+ self._outq.enqueue(self._msg, {}, listid='test.example.com')
self._runner.run()
events = list(self._processor.unprocessed)
self.assertEqual(len(events), 1)
@@ -423,7 +421,7 @@ Message-Id: <first>
# Two normal (i.e. non-probe) permanent failures just get registered.
permanent_failures.append('anne@example.com')
permanent_failures.append('bart@example.com')
- self._outq.enqueue(self._msg, {}, listname='test@example.com')
+ self._outq.enqueue(self._msg, {}, listid='test.example.com')
self._runner.run()
events = list(self._processor.unprocessed)
self.assertEqual(len(events), 2)
@@ -437,7 +435,7 @@ Message-Id: <first>
# put in the retry queue, but with some metadata to prevent infinite
# retries.
temporary_failures.append('cris@example.com')
- self._outq.enqueue(self._msg, {}, listname='test@example.com')
+ self._outq.enqueue(self._msg, {}, listid='test.example.com')
self._runner.run()
events = list(self._processor.unprocessed)
self.assertEqual(len(events), 0)
@@ -458,7 +456,7 @@ Message-Id: <first>
# retries.
temporary_failures.append('cris@example.com')
temporary_failures.append('dave@example.com')
- self._outq.enqueue(self._msg, {}, listname='test@example.com')
+ self._outq.enqueue(self._msg, {}, listid='test.example.com')
self._runner.run()
events = list(self._processor.unprocessed)
self.assertEqual(len(events), 0)
@@ -476,7 +474,7 @@ Message-Id: <first>
permanent_failures.append('fred@example.com')
temporary_failures.append('gwen@example.com')
temporary_failures.append('herb@example.com')
- self._outq.enqueue(self._msg, {}, listname='test@example.com')
+ self._outq.enqueue(self._msg, {}, listid='test.example.com')
self._runner.run()
# Let's look at the permanent failures.
events = list(self._processor.unprocessed)
@@ -503,7 +501,7 @@ Message-Id: <first>
as_timedelta(config.mta.delivery_retry_period))
msgdata = dict(last_recip_count=2,
deliver_until=deliver_until)
- self._outq.enqueue(self._msg, msgdata, listname='test@example.com')
+ self._outq.enqueue(self._msg, msgdata, listid='test.example.com')
self._runner.run()
# The retry queue should have our message waiting to be retried.
items = get_queue_messages('retry')
@@ -522,7 +520,7 @@ Message-Id: <first>
deliver_until = datetime(2005, 8, 1, 7, 49, 23) + retry_period
msgdata = dict(last_recip_count=2,
deliver_until=deliver_until)
- self._outq.enqueue(self._msg, msgdata, listname='test@example.com')
+ self._outq.enqueue(self._msg, msgdata, listid='test.example.com')
# Before the runner runs, several days pass.
factory.fast_forward(retry_period.days + 1)
mark = LogFileMark('mailman.smtp')
diff --git a/src/mailman/runners/tests/test_owner.py b/src/mailman/runners/tests/test_owner.py
index 6c68e91cc..15ca07c2e 100644
--- a/src/mailman/runners/tests/test_owner.py
+++ b/src/mailman/runners/tests/test_owner.py
@@ -22,9 +22,6 @@
# tests. They're not exactly integration tests, but they do touch lots of
# parts of the system.
-from __future__ import absolute_import, print_function, unicode_literals
-
-__metaclass__ = type
__all__ = [
'TestEmailToOwner',
]
@@ -32,22 +29,19 @@ __all__ = [
import unittest
-from operator import itemgetter
-from zope.component import getUtility
-
from mailman.app.lifecycle import create_list
from mailman.config import config
from mailman.database.transaction import transaction
from mailman.interfaces.member import MemberRole
from mailman.interfaces.usermanager import IUserManager
from mailman.testing.helpers import (
- TestableMaster,
- get_lmtp_client,
- make_testable_runner)
+ TestableMaster, get_lmtp_client, make_testable_runner)
from mailman.runners.incoming import IncomingRunner
from mailman.runners.outgoing import OutgoingRunner
from mailman.runners.pipeline import PipelineRunner
from mailman.testing.layers import SMTPLayer
+from operator import itemgetter
+from zope.component import getUtility
@@ -89,7 +83,7 @@ class TestEmailToOwner(unittest.TestCase):
# get a copy of the message.
lmtp = get_lmtp_client(quiet=True)
lmtp.lhlo('remote.example.org')
- lmtp.sendmail('zuzu@example.org', ['test-owner@example.com'], """\
+ lmtp.sendmail('zuzu@example.org', ['test-owner@example.com'], b"""\
From: Zuzu Person <zuzu@example.org>
To: test-owner@example.com
Message-ID: <ant>
diff --git a/src/mailman/runners/tests/test_pipeline.py b/src/mailman/runners/tests/test_pipeline.py
index 50ec6cb9a..347bde16b 100644
--- a/src/mailman/runners/tests/test_pipeline.py
+++ b/src/mailman/runners/tests/test_pipeline.py
@@ -17,9 +17,6 @@
"""Test the pipeline runner."""
-from __future__ import absolute_import, print_function, unicode_literals
-
-__metaclass__ = type
__all__ = [
'TestPipelineRunner',
]
@@ -27,17 +24,15 @@ __all__ = [
import unittest
-from zope.interface import implementer
-
from mailman.app.lifecycle import create_list
from mailman.config import config
from mailman.interfaces.handler import IHandler
from mailman.interfaces.pipeline import IPipeline
from mailman.runners.pipeline import PipelineRunner
from mailman.testing.helpers import (
- make_testable_runner,
- specialized_message_from_string as mfs)
+ make_testable_runner, specialized_message_from_string as mfs)
from mailman.testing.layers import ConfigLayer
+from zope.interface import implementer
@@ -101,7 +96,7 @@ To: test@example.com
def test_posting(self):
# A message accepted for posting gets processed through the posting
# pipeline.
- msgdata = dict(listname='test@example.com')
+ msgdata = dict(listid='test.example.com')
config.switchboards['pipeline'].enqueue(self._msg, msgdata)
self._pipeline.run()
self.assertEqual(len(self._markers), 1)
@@ -110,7 +105,7 @@ To: test@example.com
def test_owner(self):
# A message accepted for posting to a list's owners gets processed
# through the owner pipeline.
- msgdata = dict(listname='test@example.com',
+ msgdata = dict(listid='test.example.com',
to_owner=True)
config.switchboards['pipeline'].enqueue(self._msg, msgdata)
self._pipeline.run()
diff --git a/src/mailman/runners/tests/test_rest.py b/src/mailman/runners/tests/test_rest.py
index bbe026ad6..96ca19089 100644
--- a/src/mailman/runners/tests/test_rest.py
+++ b/src/mailman/runners/tests/test_rest.py
@@ -17,9 +17,6 @@
"""Test the REST runner."""
-from __future__ import absolute_import, print_function, unicode_literals
-
-__metaclass__ = type
__all__ = [
'TestRESTRunner',
]
diff --git a/src/mailman/runners/tests/test_retry.py b/src/mailman/runners/tests/test_retry.py
index 28289bc05..0a0929991 100644
--- a/src/mailman/runners/tests/test_retry.py
+++ b/src/mailman/runners/tests/test_retry.py
@@ -17,9 +17,6 @@
"""Test the retry runner."""
-from __future__ import absolute_import, print_function, unicode_literals
-
-__metaclass__ = type
__all__ = [
'TestRetryRunner',
]
@@ -31,8 +28,7 @@ from mailman.app.lifecycle import create_list
from mailman.config import config
from mailman.runners.retry import RetryRunner
from mailman.testing.helpers import (
- get_queue_messages,
- make_testable_runner,
+ get_queue_messages, make_testable_runner,
specialized_message_from_string as message_from_string)
from mailman.testing.layers import ConfigLayer
@@ -54,7 +50,7 @@ To: test@example.com
Message-Id: <first>
""")
- self._msgdata = dict(listname='test@example.com')
+ self._msgdata = dict(listid='test.example.com')
def test_message_put_in_outgoing_queue(self):
self._retryq.enqueue(self._msg, self._msgdata)