summaryrefslogtreecommitdiff
path: root/src/mailman/testing
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailman/testing')
-rw-r--r--src/mailman/testing/helpers.py81
-rw-r--r--src/mailman/testing/layers.py8
-rw-r--r--src/mailman/testing/mailman-fr.mobin1945 -> 1992 bytes
-rw-r--r--src/mailman/testing/mailman-fr.po12
-rw-r--r--src/mailman/testing/mailman-xx.mobin509 -> 515 bytes
-rw-r--r--src/mailman/testing/mailman-xx.po4
-rw-r--r--src/mailman/testing/testing.cfg9
7 files changed, 101 insertions, 13 deletions
diff --git a/src/mailman/testing/helpers.py b/src/mailman/testing/helpers.py
index 58c72d6d9..3648a6710 100644
--- a/src/mailman/testing/helpers.py
+++ b/src/mailman/testing/helpers.py
@@ -1,3 +1,4 @@
+# Copyright (C) 2008-2012 by the Free Software Foundation, Inc.
#
# This file is part of GNU Mailman.
#
@@ -22,10 +23,13 @@ __metaclass__ = type
__all__ = [
'LogFileMark',
'TestableMaster',
+ 'body_line_iterator',
'call_api',
+ 'configuration',
'digest_mbox',
'event_subscribers',
'get_lmtp_client',
+ 'get_nntp_server',
'get_queue_messages',
'make_testable_runner',
'reset_the_world',
@@ -37,7 +41,9 @@ __all__ = [
import os
import json
+import mock
import time
+import uuid
import errno
import signal
import socket
@@ -66,6 +72,9 @@ from mailman.interfaces.usermanager import IUserManager
from mailman.utilities.mailbox import Mailbox
+NL = '\n'
+
+
def make_testable_runner(runner_class, name=None, predicate=None):
"""Create a runner that runs until its queue is empty.
@@ -246,6 +255,24 @@ def get_lmtp_client(quiet=False):
+def get_nntp_server(cleanups):
+ """Create and start an NNTP server mock.
+
+ This can be used to retrieve the posted message for verification.
+ """
+ patcher = mock.patch('nntplib.NNTP')
+ server_class = patcher.start()
+ cleanups.append(patcher.stop)
+ nntpd = server_class()
+ # A class for more convenient access to the posted message.
+ class NNTPProxy:
+ def get_message(self):
+ args = nntpd.post.call_args
+ return specialized_message_from_string(args[0][0].read())
+ return NNTPProxy()
+
+
+
def wait_for_webservice():
"""Wait for the REST server to start serving requests."""
until = datetime.datetime.now() + as_timedelta(config.devmode.wait)
@@ -329,6 +356,42 @@ def event_subscribers(*subscribers):
+class configuration:
+ """A decorator/context manager for temporarily setting configurations."""
+
+ def __init__(self, section, **kws):
+ self._section = section
+ self._values = kws.copy()
+ self._uuid = uuid.uuid4().hex
+
+ def _apply(self):
+ lines = ['[{0}]'.format(self._section)]
+ for key, value in self._values.items():
+ lines.append('{0}: {1}'.format(key, value))
+ config.push(self._uuid, NL.join(lines))
+
+ def _remove(self):
+ config.pop(self._uuid)
+
+ def __enter__(self):
+ self._apply()
+
+ def __exit__(self, *exc_info):
+ self._remove()
+ # Do not suppress exceptions.
+ return False
+
+ def __call__(self, func):
+ def wrapper(*args, **kws):
+ self._apply()
+ try:
+ return func(*args, **kws)
+ finally:
+ self._remove()
+ return wrapper
+
+
+
def subscribe(mlist, first_name, role=MemberRole.member):
"""Helper for subscribing a sample person to a mailing list."""
user_manager = getUtility(IUserManager)
@@ -379,6 +442,8 @@ def reset_the_world():
config.db.commit()
# Reset the global style manager.
getUtility(IStyleManager).populate()
+ # Remove all dynamic header-match rules.
+ config.chains['header-match'].flush()
@@ -412,3 +477,19 @@ class LogFileMark:
with open(self._filename) as fp:
fp.seek(self._filepos)
return fp.readline()
+
+
+
+# In Python 2.6, body_line_iterator() uses a cStringIO.StringIO() which cannot
+# handle unicode. In Python 2.7 this works fine. I hate version checks but
+# this is the easiest way to handle it. OTOH, we could just use the manual
+# way for all Python versions instead.
+import sys
+if sys.hexversion >= 0x2070000:
+ from email.iterators import body_line_iterator
+else:
+ def body_line_iterator(msg, decode=False):
+ payload = msg.get_payload(decode=decode)
+ bytes_payload = payload.encode('utf-8')
+ for line in bytes_payload.splitlines():
+ yield line
diff --git a/src/mailman/testing/layers.py b/src/mailman/testing/layers.py
index 04ab8f91f..41ef86935 100644
--- a/src/mailman/testing/layers.py
+++ b/src/mailman/testing/layers.py
@@ -17,6 +17,14 @@
"""Mailman test layers."""
+# XXX 2012-03-23 BAW: Layers really really suck. For example, the
+# test_owners_get_email() test requires that both the SMTPLayer and LMTPLayer
+# be set up, but there's apparently no way to do that and make zope.testing
+# happy. This causes no tests failures, but it does cause errors at the end
+# of the full test run. For now, I'll ignore that, but I do want to
+# eventually get rid of the zope.test* dependencies and use something like
+# testresources or some such.
+
from __future__ import absolute_import, unicode_literals
__metaclass__ = type
diff --git a/src/mailman/testing/mailman-fr.mo b/src/mailman/testing/mailman-fr.mo
index df721cb0f..5758baf60 100644
--- a/src/mailman/testing/mailman-fr.mo
+++ b/src/mailman/testing/mailman-fr.mo
Binary files differ
diff --git a/src/mailman/testing/mailman-fr.po b/src/mailman/testing/mailman-fr.po
index 5f8c910e2..ca4ce8c32 100644
--- a/src/mailman/testing/mailman-fr.po
+++ b/src/mailman/testing/mailman-fr.po
@@ -17,7 +17,7 @@ msgstr ""
#: templates/en/masthead.txt:1
msgid ""
-"Send $real_name mailing list submissions to\n"
+"Send $display_name mailing list submissions to\n"
"\t$got_list_email\n"
"\n"
"To subscribe or unsubscribe via the World Wide Web, visit\n"
@@ -29,9 +29,9 @@ msgid ""
"\t$got_owner_email\n"
"\n"
"When replying, please edit your Subject line so it is more specific than\n"
-"\"Re: Contents of $real_name digest...\""
+"\"Re: Contents of $display_name digest...\""
msgstr ""
-"Envoyez vos messages pour la liste $real_name à\n"
+"Envoyez vos messages pour la liste $display_name à\n"
"\t$got_list_email\n"
"\n"
"Pour vous (dés)abonner par le web, consultez\n"
@@ -45,11 +45,11 @@ msgstr ""
"\t$got_owner_email\n"
"\n"
"Si vous répondez, n'oubliez pas de changer l'objet du message afin\n"
-"qu'il soit plus spécifique que « Re: Contenu du groupe de $real_name... »"
+"qu'il soit plus spécifique que « Re: Contenu du groupe de $display_name... »"
#: Mailman/Handlers/ToDigest.py:159
-msgid "$realname Digest, Vol $volume, Issue $issue"
-msgstr "Groupe $realname, Vol. $volume, Parution $issue"
+msgid "$mlist.display_name Digest, Vol $volume, Issue $digest_number"
+msgstr "Groupe $mlist.display_name, Vol $volume, Parution $digest_number"
#: Mailman/Handlers/ToDigest.py:205
msgid "digest header"
diff --git a/src/mailman/testing/mailman-xx.mo b/src/mailman/testing/mailman-xx.mo
index ecbad0364..bfc2e0845 100644
--- a/src/mailman/testing/mailman-xx.mo
+++ b/src/mailman/testing/mailman-xx.mo
Binary files differ
diff --git a/src/mailman/testing/mailman-xx.po b/src/mailman/testing/mailman-xx.po
index e2ad28c33..c6543d3d5 100644
--- a/src/mailman/testing/mailman-xx.po
+++ b/src/mailman/testing/mailman-xx.po
@@ -13,5 +13,5 @@ msgstr ""
"Generated-By: pygettext.py 1.3\n"
#: src/mailman/app/bounces.py:227
-msgid "$mlist.real_name mailing list probe message"
-msgstr "ailing-may ist-lay $mlist.real_name obe-pray essage-may"
+msgid "$mlist.display_name mailing list probe message"
+msgstr "ailing-may ist-lay $mlist.display_name obe-pray essage-may"
diff --git a/src/mailman/testing/testing.cfg b/src/mailman/testing/testing.cfg
index 526093572..91613cc8d 100644
--- a/src/mailman/testing/testing.cfg
+++ b/src/mailman/testing/testing.cfg
@@ -22,6 +22,9 @@
#class: mailman.database.postgresql.PostgreSQLDatabase
#url: postgres://barry:barry@localhost/mailman
+[mailman]
+site_owner: noreply@example.com
+
[mta]
smtp_port: 9025
lmtp_port: 9024
@@ -45,7 +48,7 @@ max_restarts: 1
[runner.lmtp]
max_restarts: 1
-[runner.news]
+[runner.nntp]
max_restarts: 1
[runner.out]
@@ -71,10 +74,6 @@ enable: yes
base_url: http://go.mail-archive.dev/
recipient: archive@mail-archive.dev
-[archiver.pipermail]
-enable: yes
-base_url: http://www.example.com/pipermail/$listname
-
[archiver.mhonarc]
enable: yes
command: /bin/echo "/usr/bin/mhonarc -add -dbfile $PRIVATE_ARCHIVE_FILE_DIR/${listname}.mbox/mhonarc.db -outdir $VAR_DIR/mhonarc/${listname} -stderr $LOG_DIR/mhonarc -stdout $LOG_DIR/mhonarc -spammode -umask 022"