summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Mailman/queue/docs/incoming.txt131
-rw-r--r--Mailman/tests/helpers.py64
-rw-r--r--docs/NEWS.txt5
3 files changed, 198 insertions, 2 deletions
diff --git a/Mailman/queue/docs/incoming.txt b/Mailman/queue/docs/incoming.txt
index 12ff3d3d1..04c0cfa04 100644
--- a/Mailman/queue/docs/incoming.txt
+++ b/Mailman/queue/docs/incoming.txt
@@ -16,6 +16,10 @@ above.
>>> mlist.start_chain
u'built-in'
+
+Accepted messages
+-----------------
+
We have a message that is going to be sent to the mailing list. This message
is so perfectly fine for posting that it will be accepted and forward to the
prep queue.
@@ -49,6 +53,9 @@ And now the message is in the prep queue.
>>> prep_queue = Switchboard(config.PREPQUEUE_DIR)
>>> len(prep_queue.files)
1
+ >>> incoming_queue = Switchboard(config.INQUEUE_DIR)
+ >>> len(incoming_queue.files)
+ 0
>>> from Mailman.tests.helpers import get_queue_messages
>>> item = get_queue_messages(prep_queue)[0]
>>> print item.msg.as_string()
@@ -65,3 +72,127 @@ And now the message is in the prep queue.
<BLANKLINE>
>>> sorted(item.msgdata.items())
[...('envsender', u'noreply@example.com')...('tolist', True)...]
+
+
+Held messages
+-------------
+
+The list moderator sets the emergency flag on the mailing list. The built-in
+chain will now hold all posted messages, so nothing will show up in the prep
+queue.
+
+ # XXX This checks the vette log file because there is no other evidence
+ # that this chain has done anything.
+ >>> import os
+ >>> fp = open(os.path.join(config.LOG_DIR, 'vette'))
+ >>> fp.seek(0, 2)
+
+ >>> mlist.emergency = True
+ >>> mlist.web_page_url = u'http://archives.example.com/'
+ >>> inject(u'_xtest@example.com', msg)
+ >>> file_pos = fp.tell()
+ >>> incoming.run()
+ >>> len(prep_queue.files)
+ 0
+ >>> len(incoming_queue.files)
+ 0
+ >>> fp.seek(file_pos)
+ >>> print 'LOG:', fp.read()
+ LOG: ... HOLD: _xtest@example.com post from aperson@example.com held,
+ message-id=<first>: n/a
+ <BLANKLINE>
+
+ >>> mlist.emergency = False
+
+
+Discarded messages
+------------------
+
+Another possibility is that the message would get immediately discarded. The
+built-in chain does not have such a disposition by default, so let's craft a
+new chain and set it as the mailing list's start chain.
+
+ >>> from Mailman.chains.base import Chain, Link
+ >>> from Mailman.interfaces import LinkAction
+ >>> truth_rule = config.rules['truth']
+ >>> discard_chain = config.chains['discard']
+ >>> test_chain = Chain('always-discard', u'Testing discards')
+ >>> link = Link(truth_rule, LinkAction.jump, discard_chain)
+ >>> test_chain.append_link(link)
+ >>> mlist.start_chain = u'always-discard'
+
+ >>> inject(u'_xtest@example.com', msg)
+ >>> file_pos = fp.tell()
+ >>> incoming.run()
+ >>> len(prep_queue.files)
+ 0
+ >>> len(incoming_queue.files)
+ 0
+ >>> fp.seek(file_pos)
+ >>> print 'LOG:', fp.read()
+ LOG: ... DISCARD: <first>
+ <BLANKLINE>
+
+ >>> del config.chains['always-discard']
+
+
+Rejected messages
+-----------------
+
+Similar to discarded messages, a message can be rejected, or bounced back to
+the original sender. Again, the built-in chain doesn't support this so we'll
+just create a new chain that does.
+
+ >>> reject_chain = config.chains['reject']
+ >>> test_chain = Chain('always-reject', u'Testing rejections')
+ >>> link = Link(truth_rule, LinkAction.jump, reject_chain)
+ >>> test_chain.append_link(link)
+ >>> mlist.start_chain = u'always-reject'
+
+The virgin queue needs to be cleared out due to artifacts from the previous
+tests above.
+
+ >>> virgin_queue = Switchboard(config.VIRGINQUEUE_DIR)
+ >>> ignore = get_queue_messages(virgin_queue)
+
+ >>> inject(u'_xtest@example.com', msg)
+ >>> file_pos = fp.tell()
+ >>> incoming.run()
+ >>> len(prep_queue.files)
+ 0
+ >>> len(incoming_queue.files)
+ 0
+
+ >>> len(virgin_queue.files)
+ 1
+ >>> item = get_queue_messages(virgin_queue)[0]
+ >>> print item.msg.as_string()
+ Subject: My first post
+ From: _xtest-owner@example.com
+ To: aperson@example.com
+ ...
+ Content-Type: text/plain; charset="us-ascii"
+ MIME-Version: 1.0
+ Content-Transfer-Encoding: 7bit
+ <BLANKLINE>
+ [No bounce details are available]
+ ...
+ Content-Type: message/rfc822
+ MIME-Version: 1.0
+ <BLANKLINE>
+ From: aperson@example.com
+ To: _xtest@example.com
+ Subject: My first post
+ Message-ID: <first>
+ <BLANKLINE>
+ First post!
+ <BLANKLINE>
+ ...
+ >>> sorted(item.msgdata.items())
+ [...('recips', [u'aperson@example.com'])...]
+ >>> fp.seek(file_pos)
+ >>> print 'LOG:', fp.read()
+ LOG: ... REJECT: <first>
+ <BLANKLINE>
+
+ >>> del config.chains['always-reject']
diff --git a/Mailman/tests/helpers.py b/Mailman/tests/helpers.py
new file mode 100644
index 000000000..1b24f11e6
--- /dev/null
+++ b/Mailman/tests/helpers.py
@@ -0,0 +1,64 @@
+# Copyright (C) 2008 by the Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA.
+
+"""Various test helpers."""
+
+__metaclass__ = type
+__all__ = [
+ 'get_queue_messages',
+ 'make_testable_runner',
+ ]
+
+
+
+def make_testable_runner(runner_class):
+ """Create a queue runner that runs until its queue is empty.
+
+ :param runner_class: An IRunner
+ :return: A runner instance.
+ """
+
+ class EmptyingRunner(runner_class):
+ """Stop processing when the queue is empty."""
+
+ def _doperiodic(self):
+ """Stop when the queue is empty."""
+ self._stop = (len(self._switchboard.files) == 0)
+
+ return EmptyingRunner()
+
+
+
+class _Bag:
+ def __init__(self, **kws):
+ for key, value in kws.items():
+ setattr(self, key, value)
+
+
+def get_queue_messages(queue):
+ """Return and clear all the messages in the given queue.
+
+ :param queue: An ISwitchboard
+ :return: A list of 2-tuples where each item contains the message and
+ message metadata.
+ """
+ messages = []
+ for filebase in queue.files:
+ msg, msgdata = queue.dequeue(filebase)
+ messages.append(_Bag(msg=msg, msgdata=msgdata))
+ queue.finish(filebase)
+ return messages
diff --git a/docs/NEWS.txt b/docs/NEWS.txt
index 2cc28963e..d0ebf99d7 100644
--- a/docs/NEWS.txt
+++ b/docs/NEWS.txt
@@ -1,10 +1,11 @@
Mailman - The GNU Mailing List Management System
-Copyright (C) 1998-2007 by the Free Software Foundation, Inc.
+Copyright (C) 1998-2008 by the Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
Here is a history of user visible changes to Mailman.
-3.0 alpha 1 (XX-XXX-200X)
+3.0 alpha 1 -- "Leave That Thing Alone"
+(XX-XXX-200X)
User visible changes