summaryrefslogtreecommitdiff
path: root/Mailman/testing
diff options
context:
space:
mode:
Diffstat (limited to 'Mailman/testing')
-rw-r--r--Mailman/testing/base.py34
-rw-r--r--Mailman/testing/test_acknowledge.py (renamed from Mailman/testing/test_mlist_rosters.py)9
-rw-r--r--Mailman/testing/test_address.py7
-rw-r--r--Mailman/testing/test_after_delivery.py28
-rw-r--r--Mailman/testing/test_avoid_duplicates.py27
-rw-r--r--Mailman/testing/test_calc_recips.py27
-rw-r--r--Mailman/testing/test_cleanse.py27
-rw-r--r--Mailman/testing/test_cook_headers.py32
-rw-r--r--Mailman/testing/test_decorate.py9
-rw-r--r--Mailman/testing/test_handlers.py654
-rw-r--r--Mailman/testing/test_listmanager.py5
-rw-r--r--Mailman/testing/test_membership.py5
-rw-r--r--Mailman/testing/test_mlist_addresses.py5
-rw-r--r--Mailman/testing/test_replybot.py9
-rw-r--r--Mailman/testing/test_user.py7
-rw-r--r--Mailman/testing/test_usermanager.py5
16 files changed, 194 insertions, 696 deletions
diff --git a/Mailman/testing/base.py b/Mailman/testing/base.py
index 562443b1e..c3f64554a 100644
--- a/Mailman/testing/base.py
+++ b/Mailman/testing/base.py
@@ -24,6 +24,7 @@ import pwd
import sys
import stat
import shutil
+import doctest
import difflib
import tempfile
import unittest
@@ -35,9 +36,11 @@ from Mailman import MailList
from Mailman import Utils
from Mailman.bin import rmlist
from Mailman.configuration import config
+from Mailman.database import flush
from Mailman.database.dbcontext import dbcontext
NL = '\n'
+COMMASPACE = ', '
@@ -79,3 +82,34 @@ class TestBase(unittest.TestCase):
path = os.path.join(config.LOCK_DIR, filename)
print >> sys.stderr, '@@@@@ removing:', path
os.unlink(path)
+
+
+
+def cleaning_teardown(testobj):
+ for user in config.user_manager.users:
+ config.user_manager.delete_user(user)
+ for address in config.user_manager.addresses:
+ config.user_manager.delete_address(address)
+ for mlist in config.list_manager.mailing_lists:
+ for member in mlist.members.members:
+ member.unsubscribe()
+ for admin in mlist.administrators.members:
+ admin.unsubscribe()
+ config.list_manager.delete(mlist)
+ flush()
+ assert not list(config.list_manager.mailing_lists), (
+ 'There should be no mailing lists left: %s' %
+ COMMASPACE.join(sorted(config.list_manager.names)))
+ assert not list(config.user_manager.users), (
+ 'There should be no users left!')
+ assert not list(config.user_manager.addresses), (
+ 'There should be no addresses left!')
+
+
+def make_docfile_suite(path):
+ return doctest.DocFileSuite(
+ path,
+ optionflags=(doctest.ELLIPSIS
+ | doctest.NORMALIZE_WHITESPACE
+ | doctest.REPORT_NDIFF),
+ tearDown=cleaning_teardown)
diff --git a/Mailman/testing/test_mlist_rosters.py b/Mailman/testing/test_acknowledge.py
index e8713b828..605c6edda 100644
--- a/Mailman/testing/test_mlist_rosters.py
+++ b/Mailman/testing/test_acknowledge.py
@@ -15,16 +15,13 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
-"""Doctest harness for the IMailingListRosters interface."""
+"""Doctest harness for testing message acknowledgment."""
-import doctest
import unittest
-
-options = doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE
+from Mailman.testing.base import make_docfile_suite
def test_suite():
suite = unittest.TestSuite()
- suite.addTest(doctest.DocFileSuite('../docs/mlist-rosters.txt',
- optionflags=options))
+ suite.addTest(make_docfile_suite('../docs/acknowledge.txt'))
return suite
diff --git a/Mailman/testing/test_address.py b/Mailman/testing/test_address.py
index a04b3e795..d66292c55 100644
--- a/Mailman/testing/test_address.py
+++ b/Mailman/testing/test_address.py
@@ -17,14 +17,11 @@
"""Doctest harness for testing IAddress interface."""
-import doctest
import unittest
-
-options = doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE
+from Mailman.testing.base import make_docfile_suite
def test_suite():
suite = unittest.TestSuite()
- suite.addTest(doctest.DocFileSuite('../docs/addresses.txt',
- optionflags=options))
+ suite.addTest(make_docfile_suite('../docs/addresses.txt'))
return suite
diff --git a/Mailman/testing/test_after_delivery.py b/Mailman/testing/test_after_delivery.py
new file mode 100644
index 000000000..a7d0f01f4
--- /dev/null
+++ b/Mailman/testing/test_after_delivery.py
@@ -0,0 +1,28 @@
+# Copyright (C) 2007 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.
+
+"""Doctest harness for testing bookkeeping done after message delivery."""
+
+import unittest
+
+from Mailman.testing.base import make_docfile_suite
+
+
+def test_suite():
+ suite = unittest.TestSuite()
+ suite.addTest(make_docfile_suite('../docs/after-delivery.txt'))
+ return suite
diff --git a/Mailman/testing/test_avoid_duplicates.py b/Mailman/testing/test_avoid_duplicates.py
new file mode 100644
index 000000000..b5de721e6
--- /dev/null
+++ b/Mailman/testing/test_avoid_duplicates.py
@@ -0,0 +1,27 @@
+# Copyright (C) 2007 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.
+
+"""Doctest harness for the AvoidDuplicates handler."""
+
+import unittest
+from Mailman.testing.base import make_docfile_suite
+
+
+def test_suite():
+ suite = unittest.TestSuite()
+ suite.addTest(make_docfile_suite('../docs/avoid-duplicates.txt'))
+ return suite
diff --git a/Mailman/testing/test_calc_recips.py b/Mailman/testing/test_calc_recips.py
new file mode 100644
index 000000000..da3929b65
--- /dev/null
+++ b/Mailman/testing/test_calc_recips.py
@@ -0,0 +1,27 @@
+# Copyright (C) 2007 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.
+
+"""Doctest harness for testing the recipient calculation handler."""
+
+import unittest
+from Mailman.testing.base import make_docfile_suite
+
+
+def test_suite():
+ suite = unittest.TestSuite()
+ suite.addTest(make_docfile_suite('../docs/calc-recips.txt'))
+ return suite
diff --git a/Mailman/testing/test_cleanse.py b/Mailman/testing/test_cleanse.py
new file mode 100644
index 000000000..e058c7bfa
--- /dev/null
+++ b/Mailman/testing/test_cleanse.py
@@ -0,0 +1,27 @@
+# Copyright (C) 2007 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.
+
+"""Doctest harness for the Cleanse handler."""
+
+import unittest
+from Mailman.testing.base import make_docfile_suite
+
+
+def test_suite():
+ suite = unittest.TestSuite()
+ suite.addTest(make_docfile_suite('../docs/cleanse.txt'))
+ return suite
diff --git a/Mailman/testing/test_cook_headers.py b/Mailman/testing/test_cook_headers.py
new file mode 100644
index 000000000..dd141aab9
--- /dev/null
+++ b/Mailman/testing/test_cook_headers.py
@@ -0,0 +1,32 @@
+# Copyright (C) 2007 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.
+
+"""Doctest harness for the CookHeaders handler."""
+
+import os
+import unittest
+
+from Mailman.testing.base import make_docfile_suite
+
+
+def test_suite():
+ suite = unittest.TestSuite()
+ for filename in ('ack-headers', 'cook-headers', 'subject-munging',
+ 'reply-to'):
+ path = os.path.join('..', 'docs', filename + '.txt')
+ suite.addTest(make_docfile_suite(path))
+ return suite
diff --git a/Mailman/testing/test_decorate.py b/Mailman/testing/test_decorate.py
index 23af0598c..1bbe84250 100644
--- a/Mailman/testing/test_decorate.py
+++ b/Mailman/testing/test_decorate.py
@@ -17,16 +17,11 @@
"""Doctest harness for testing message decoration."""
-import doctest
import unittest
-
-options = (doctest.ELLIPSIS
- | doctest.NORMALIZE_WHITESPACE
- | doctest.REPORT_NDIFF)
+from Mailman.testing.base import make_docfile_suite
def test_suite():
suite = unittest.TestSuite()
- suite.addTest(doctest.DocFileSuite('../docs/decorate.txt',
- optionflags=options))
+ suite.addTest(make_docfile_suite('../docs/decorate.txt'))
return suite
diff --git a/Mailman/testing/test_handlers.py b/Mailman/testing/test_handlers.py
index f4ad2ba4f..b44a1c2cc 100644
--- a/Mailman/testing/test_handlers.py
+++ b/Mailman/testing/test_handlers.py
@@ -39,9 +39,6 @@ from Mailman.testing.base import TestBase
from Mailman.Handlers import Acknowledge
from Mailman.Handlers import AfterDelivery
from Mailman.Handlers import Approve
-from Mailman.Handlers import CalcRecips
-from Mailman.Handlers import Cleanse
-from Mailman.Handlers import CookHeaders
from Mailman.Handlers import FileRecips
from Mailman.Handlers import Hold
from Mailman.Handlers import MimeDel
@@ -62,147 +59,6 @@ def password(cleartext):
-class TestAcknowledge(TestBase):
- def setUp(self):
- TestBase.setUp(self)
- # We're going to want to inspect this queue directory
- self._sb = Switchboard(config.VIRGINQUEUE_DIR)
- # Add a member
- self._mlist.addNewMember('aperson@example.org')
- self._mlist.personalize = False
-
- def tearDown(self):
- for f in os.listdir(config.VIRGINQUEUE_DIR):
- os.unlink(os.path.join(config.VIRGINQUEUE_DIR, f))
- TestBase.tearDown(self)
-
- def test_no_ack_msgdata(self):
- eq = self.assertEqual
- # Make sure there are no files in the virgin queue already
- eq(len(self._sb.files()), 0)
- msg = email.message_from_string("""\
-From: aperson@example.org
-
-""", Message.Message)
- Acknowledge.process(self._mlist, msg,
- {'original_sender': 'aperson@example.org'})
- eq(len(self._sb.files()), 0)
-
- def test_no_ack_not_a_member(self):
- eq = self.assertEqual
- # Make sure there are no files in the virgin queue already
- eq(len(self._sb.files()), 0)
- msg = email.message_from_string("""\
-From: bperson@example.com
-
-""", Message.Message)
- Acknowledge.process(self._mlist, msg,
- {'original_sender': 'bperson@example.com'})
- eq(len(self._sb.files()), 0)
-
- def test_no_ack_sender(self):
- eq = self.assertEqual
- eq(len(self._sb.files()), 0)
- msg = email.message_from_string("""\
-From: aperson@example.org
-
-""", Message.Message)
- Acknowledge.process(self._mlist, msg, {})
- eq(len(self._sb.files()), 0)
-
- def test_ack_no_subject(self):
- eq = self.assertEqual
- self._mlist.setMemberOption(
- 'aperson@example.org', config.AcknowledgePosts, 1)
- eq(len(self._sb.files()), 0)
- msg = email.message_from_string("""\
-From: aperson@example.org
-
-""", Message.Message)
- Acknowledge.process(self._mlist, msg, {})
- files = self._sb.files()
- eq(len(files), 1)
- qmsg, qdata = self._sb.dequeue(files[0])
- # Check the .db file
- eq(qdata.get('listname'), '_xtest@example.com')
- eq(qdata.get('recips'), ['aperson@example.org'])
- eq(qdata.get('version'), 3)
- # Check the .pck
- eq(str(qmsg['subject']), '_xtest post acknowledgement')
- eq(qmsg['to'], 'aperson@example.org')
- eq(qmsg['from'], '_xtest-bounces@example.com')
- eq(qmsg.get_content_type(), 'text/plain')
- eq(qmsg.get_param('charset'), 'us-ascii')
- msgid = qmsg['message-id']
- self.failUnless(msgid.startswith('<mailman.'))
- self.failUnless(msgid.endswith('._xtest@example.com>'))
- eq(qmsg.get_payload(), """\
-Your message entitled
-
- (no subject)
-
-was successfully received by the _xtest mailing list.
-
-List info page: http://www.example.com/mailman/listinfo/_xtest@example.com
-Your preferences: http://www.example.com/mailman/options/_xtest@example.com/aperson%40example.org
-""")
- # Make sure we dequeued the only message
- eq(len(self._sb.files()), 0)
-
- def test_ack_with_subject(self):
- eq = self.assertEqual
- self._mlist.setMemberOption(
- 'aperson@example.org', config.AcknowledgePosts, 1)
- eq(len(self._sb.files()), 0)
- msg = email.message_from_string("""\
-From: aperson@example.org
-Subject: Wish you were here
-
-""", Message.Message)
- Acknowledge.process(self._mlist, msg, {})
- files = self._sb.files()
- eq(len(files), 1)
- qmsg, qdata = self._sb.dequeue(files[0])
- # Check the .db file
- eq(qdata.get('listname'), '_xtest@example.com')
- eq(qdata.get('recips'), ['aperson@example.org'])
- eq(qdata.get('version'), 3)
- # Check the .pck
- eq(str(qmsg['subject']), '_xtest post acknowledgement')
- eq(qmsg['to'], 'aperson@example.org')
- eq(qmsg['from'], '_xtest-bounces@example.com')
- eq(qmsg.get_content_type(), 'text/plain')
- eq(qmsg.get_param('charset'), 'us-ascii')
- msgid = qmsg['message-id']
- self.failUnless(msgid.startswith('<mailman.'))
- self.failUnless(msgid.endswith('._xtest@example.com>'))
- eq(qmsg.get_payload(), """\
-Your message entitled
-
- Wish you were here
-
-was successfully received by the _xtest mailing list.
-
-List info page: http://www.example.com/mailman/listinfo/_xtest@example.com
-Your preferences: http://www.example.com/mailman/options/_xtest@example.com/aperson%40example.org
-""")
- # Make sure we dequeued the only message
- eq(len(self._sb.files()), 0)
-
-
-
-class TestAfterDelivery(TestBase):
- # Both msg and msgdata are ignored
- def test_process(self):
- mlist = self._mlist
- last_post_time = mlist.last_post_time
- post_id = mlist.post_id
- AfterDelivery.process(mlist, None, None)
- self.failUnless(mlist.last_post_time > last_post_time)
- self.assertEqual(mlist.post_id, post_id + 1)
-
-
-
class TestApprove(TestBase):
def test_short_circuit(self):
msgdata = {'approved': 1}
@@ -279,511 +135,6 @@ X-BeenThere: %s
-class TestCalcRecips(TestBase):
- def setUp(self):
- TestBase.setUp(self)
- # Add a bunch of regular members
- mlist = self._mlist
- mlist.addNewMember('aperson@example.org')
- mlist.addNewMember('bperson@example.com')
- mlist.addNewMember('cperson@example.com')
- # And a bunch of digest members
- mlist.addNewMember('dperson@example.com', digest=1)
- mlist.addNewMember('eperson@example.com', digest=1)
- mlist.addNewMember('fperson@example.com', digest=1)
-
- def test_short_circuit(self):
- msgdata = {'recips': 1}
- rtn = CalcRecips.process(self._mlist, None, msgdata)
- # Not really a great test, but there's little else to assert
- self.assertEqual(rtn, None)
-
- def test_simple_path(self):
- msgdata = {}
- msg = email.message_from_string("""\
-From: dperson@example.com
-
-""", Message.Message)
- CalcRecips.process(self._mlist, msg, msgdata)
- self.failUnless(msgdata.has_key('recips'))
- recips = msgdata['recips']
- recips.sort()
- self.assertEqual(recips, ['aperson@example.org', 'bperson@example.com',
- 'cperson@example.com'])
-
- def test_exclude_sender(self):
- msgdata = {}
- msg = email.message_from_string("""\
-From: cperson@example.com
-
-""", Message.Message)
- self._mlist.setMemberOption('cperson@example.com',
- config.DontReceiveOwnPosts, 1)
- CalcRecips.process(self._mlist, msg, msgdata)
- self.failUnless(msgdata.has_key('recips'))
- recips = msgdata['recips']
- recips.sort()
- self.assertEqual(recips, ['aperson@example.org', 'bperson@example.com'])
-
- def test_urgent_moderator(self):
- self._mlist.mod_password = password('xxXXxx')
- msgdata = {}
- msg = email.message_from_string("""\
-From: dperson@example.com
-Urgent: xxXXxx
-
-""", Message.Message)
- CalcRecips.process(self._mlist, msg, msgdata)
- self.failUnless(msgdata.has_key('recips'))
- recips = msgdata['recips']
- recips.sort()
- self.assertEqual(recips, ['aperson@example.org', 'bperson@example.com',
- 'cperson@example.com', 'dperson@example.com',
- 'eperson@example.com', 'fperson@example.com'])
-
- def test_urgent_admin(self):
- self._mlist.mod_password = password('yyYYyy')
- self._mlist.password = password('xxXXxx')
- msgdata = {}
- msg = email.message_from_string("""\
-From: dperson@example.com
-Urgent: xxXXxx
-
-""", Message.Message)
- CalcRecips.process(self._mlist, msg, msgdata)
- self.failUnless(msgdata.has_key('recips'))
- recips = msgdata['recips']
- recips.sort()
- self.assertEqual(recips, ['aperson@example.org', 'bperson@example.com',
- 'cperson@example.com', 'dperson@example.com',
- 'eperson@example.com', 'fperson@example.com'])
-
- def test_urgent_reject(self):
- self._mlist.mod_password = password('yyYYyy')
- self._mlist.password = password('xxXXxx')
- msgdata = {}
- msg = email.message_from_string("""\
-From: dperson@example.com
-Urgent: zzZZzz
-
-""", Message.Message)
- self.assertRaises(Errors.RejectMessage,
- CalcRecips.process,
- self._mlist, msg, msgdata)
-
- # BAW: must test the do_topic_filters() path...
-
-
-
-class TestCleanse(TestBase):
- def setUp(self):
- TestBase.setUp(self)
-
- def test_simple_cleanse(self):
- eq = self.assertEqual
- msg = email.message_from_string("""\
-From: aperson@example.org
-Approved: yes
-Urgent: indeed
-Reply-To: bperson@example.com
-Sender: asystem@example.com
-Return-Receipt-To: another@example.com
-Disposition-Notification-To: athird@example.com
-X-Confirm-Reading-To: afourth@example.com
-X-PMRQC: afifth@example.com
-Subject: a message to you
-
-""", Message.Message)
- Cleanse.process(self._mlist, msg, {})
- eq(msg['approved'], None)
- eq(msg['urgent'], None)
- eq(msg['return-receipt-to'], None)
- eq(msg['disposition-notification-to'], None)
- eq(msg['x-confirm-reading-to'], None)
- eq(msg['x-pmrqc'], None)
- eq(msg['from'], 'aperson@example.org')
- eq(msg['reply-to'], 'bperson@example.com')
- eq(msg['sender'], 'asystem@example.com')
- eq(msg['subject'], 'a message to you')
-
- def test_anon_cleanse(self):
- eq = self.assertEqual
- msg = email.message_from_string("""\
-From: aperson@example.org
-Approved: yes
-Urgent: indeed
-Reply-To: bperson@example.com
-Sender: asystem@example.com
-Return-Receipt-To: another@example.com
-Disposition-Notification-To: athird@example.com
-X-Confirm-Reading-To: afourth@example.com
-X-PMRQC: afifth@example.com
-Subject: a message to you
-
-""", Message.Message)
- self._mlist.anonymous_list = 1
- Cleanse.process(self._mlist, msg, {})
- eq(msg['approved'], None)
- eq(msg['urgent'], None)
- eq(msg['return-receipt-to'], None)
- eq(msg['disposition-notification-to'], None)
- eq(msg['x-confirm-reading-to'], None)
- eq(msg['x-pmrqc'], None)
- eq(len(msg.get_all('from')), 1)
- eq(len(msg.get_all('reply-to')), 1)
- eq(msg['from'], '_xtest@example.com')
- eq(msg['reply-to'], '_xtest@example.com')
- eq(msg['sender'], None)
- eq(msg['subject'], 'a message to you')
-
-
-
-class TestCookHeaders(TestBase):
- def test_transform_noack_to_xack(self):
- eq = self.assertEqual
- msg = email.message_from_string("""\
-X-Ack: yes
-
-""", Message.Message)
- CookHeaders.process(self._mlist, msg, {'noack': 1})
- eq(len(msg.get_all('x-ack')), 1)
- eq(msg['x-ack'], 'no')
-
- def test_original_sender(self):
- msg = email.message_from_string("""\
-From: aperson@example.org
-
-""", Message.Message)
- msgdata = {}
- CookHeaders.process(self._mlist, msg, msgdata)
- self.assertEqual(msgdata.get('original_sender'), 'aperson@example.org')
-
- def test_no_original_sender(self):
- msg = email.message_from_string("""\
-Subject: about this message
-
-""", Message.Message)
- msgdata = {}
- CookHeaders.process(self._mlist, msg, msgdata)
- self.assertEqual(msgdata.get('original_sender'), '')
-
- def test_xbeenthere(self):
- msg = email.message_from_string("""\
-From: aperson@example.org
-
-""", Message.Message)
- CookHeaders.process(self._mlist, msg, {})
- self.assertEqual(msg['x-beenthere'], '_xtest@example.com')
-
- def test_multiple_xbeentheres(self):
- eq = self.assertEqual
- msg = email.message_from_string("""\
-From: aperson@example.org
-X-BeenThere: alist@another.example.com
-
-""", Message.Message)
- CookHeaders.process(self._mlist, msg, {})
- eq(len(msg.get_all('x-beenthere')), 2)
- beentheres = msg.get_all('x-beenthere')
- beentheres.sort()
- eq(beentheres, ['_xtest@example.com', 'alist@another.example.com'])
-
- def test_nonexisting_mmversion(self):
- eq = self.assertEqual
- msg = email.message_from_string("""\
-From: aperson@example.org
-
-""", Message.Message)
- CookHeaders.process(self._mlist, msg, {})
- eq(msg['x-mailman-version'], Version.VERSION)
-
- def test_existing_mmversion(self):
- eq = self.assertEqual
- msg = email.message_from_string("""\
-From: aperson@example.org
-X-Mailman-Version: 3000
-
-""", Message.Message)
- CookHeaders.process(self._mlist, msg, {})
- eq(len(msg.get_all('x-mailman-version')), 1)
- eq(msg['x-mailman-version'], '3000')
-
- def test_nonexisting_precedence(self):
- eq = self.assertEqual
- msg = email.message_from_string("""\
-From: aperson@example.org
-
-""", Message.Message)
- CookHeaders.process(self._mlist, msg, {})
- eq(msg['precedence'], 'list')
-
- def test_existing_precedence(self):
- eq = self.assertEqual
- msg = email.message_from_string("""\
-From: aperson@example.org
-Precedence: junk
-
-""", Message.Message)
- CookHeaders.process(self._mlist, msg, {})
- eq(len(msg.get_all('precedence')), 1)
- eq(msg['precedence'], 'junk')
-
- def test_subject_munging_no_subject(self):
- self._mlist.subject_prefix = '[XTEST] '
- msg = email.message_from_string("""\
-From: aperson@example.org
-
-""", Message.Message)
- msgdata = {}
- CookHeaders.process(self._mlist, msg, msgdata)
- self.assertEqual(msgdata.get('origsubj'), '')
- self.assertEqual(str(msg['subject']), '[XTEST] (no subject)')
-
- def test_subject_munging(self):
- self._mlist.subject_prefix = '[XTEST] '
- msg = email.message_from_string("""\
-From: aperson@example.org
-Subject: About Mailman...
-
-""", Message.Message)
- CookHeaders.process(self._mlist, msg, {})
- self.assertEqual(msg['subject'], '[XTEST] About Mailman...')
-
- def test_no_subject_munging_for_digests(self):
- self._mlist.subject_prefix = '[XTEST] '
- msg = email.message_from_string("""\
-From: aperson@example.org
-Subject: About Mailman...
-
-""", Message.Message)
- CookHeaders.process(self._mlist, msg, {'isdigest': 1})
- self.assertEqual(msg['subject'], 'About Mailman...')
-
- def test_no_subject_munging_for_fasttrack(self):
- self._mlist.subject_prefix = '[XTEST] '
- msg = email.message_from_string("""\
-From: aperson@example.org
-Subject: About Mailman...
-
-""", Message.Message)
- CookHeaders.process(self._mlist, msg, {'_fasttrack': 1})
- self.assertEqual(msg['subject'], 'About Mailman...')
-
- def test_no_subject_munging_has_prefix(self):
- self._mlist.subject_prefix = '[XTEST] '
- msg = email.message_from_string("""\
-From: aperson@example.org
-Subject: Re: [XTEST] About Mailman...
-
-""", Message.Message)
- CookHeaders.process(self._mlist, msg, {})
- self.assertEqual(msg['subject'], 'Re: [XTEST] About Mailman...')
-
- def test_subject_munging_i18n(self):
- self._mlist.subject_prefix = '[XTEST]'
- msg = Message.Message()
- msg['Subject'] = '=?iso-2022-jp?b?GyRCJWEhPCVrJV4lcxsoQg==?='
- CookHeaders.process(self._mlist, msg, {})
- self.assertEqual(unicode(msg['subject']),
- u'[XTEST] \u30e1\u30fc\u30eb\u30de\u30f3')
- self.assertEqual(msg['subject'],
- '[XTEST] =?iso-2022-jp?b?GyRCJWEhPCVrJV4lcxsoQg==?=')
- self._mlist.subject_prefix = '[XTEST %d]'
- self._mlist.post_id = 456
- msg = Message.Message()
- msg['Subject'] = '=?iso-2022-jp?b?GyRCJWEhPCVrJV4lcxsoQg==?='
- CookHeaders.process(self._mlist, msg, {})
- self.assertEqual(unicode(msg['subject']),
- u'[XTEST 456] \u30e1\u30fc\u30eb\u30de\u30f3')
- self.assertEqual(msg['subject'],
- '[XTEST 456] =?iso-2022-jp?b?GyRCJWEhPCVrJV4lcxsoQg==?=')
- msg = Message.Message()
- msg['Subject'
- ] = 'Re: [XTEST 123] =?iso-2022-jp?b?GyRCJWEhPCVrJV4lcxsoQg==?='
- CookHeaders.process(self._mlist, msg, {})
- # next code suceeds if python email patch tracker #1681333 is applied.
- #self.assertEqual(unicode(msg['subject']),
- # u'[XTEST 456] Re: \u30e1\u30fc\u30eb\u30de\u30f3')
- self.assertEqual(msg['subject'],
- '[XTEST 456] Re: =?iso-2022-jp?b?GyRCJWEhPCVrJV4lcxsoQg==?=')
-
- def test_subject_munging_prefix_number(self):
- self._mlist.subject_prefix = '[XTEST %d]'
- self._mlist.post_id = 456
- msg = Message.Message()
- msg['Subject'] = 'About Mailman...'
- CookHeaders.process(self._mlist, msg, {})
- self.assertEqual(msg['subject'], '[XTEST 456] About Mailman...')
- msg = Message.Message()
- msg['Subject'] = 'Re: [XTEST 123] About Mailman...'
- CookHeaders.process(self._mlist, msg, {})
- self.assertEqual(msg['subject'], '[XTEST 456] Re: About Mailman...')
-
- def test_subject_munging_prefix_newstyle(self):
- self._mlist.subject_prefix = '[XTEST]'
- config.OLD_STYLE_PREFIXING = False
- msg = Message.Message()
- msg['Subject'] = 'Re: [XTEST] About Mailman...'
- CookHeaders.process(self._mlist, msg, {})
- self.assertEqual(msg['subject'], '[XTEST] Re: About Mailman...')
-
- def test_subject_munging_prefix_crooked(self):
- # In this test case, we get an extra space between the prefix and
- # the original subject. It's because the original is crooked.
- # Note that isubject starting by '\n ' is generated by some version of
- # Eudora Japanese edition.
- self._mlist.subject_prefix = '[XTEST]'
- msg = Message.Message()
- msg['Subject'] = '\n About Mailman...'
- CookHeaders.process(self._mlist, msg, {})
- self.assertEqual(str(msg['subject']), '[XTEST] About Mailman...')
- del msg['subject']
- msg['Subject'] = '\n =?iso-2022-jp?b?GyRCJWEhPCVrJV4lcxsoQg==?='
- CookHeaders.process(self._mlist, msg, {})
- self.assertEqual(str(msg['subject']),
- '[XTEST] =?iso-2022-jp?b?IBskQiVhITwlayVeJXMbKEI=?=')
-
- def test_reply_to_list(self):
- eq = self.assertEqual
- mlist = self._mlist
- mlist.reply_goes_to_list = 1
- msg = email.message_from_string("""\
-From: aperson@example.org
-
-""", Message.Message)
- CookHeaders.process(mlist, msg, {})
- eq(msg['reply-to'], '_xtest@example.com')
- eq(msg.get_all('reply-to'), ['_xtest@example.com'])
-
- def test_reply_to_list_with_strip(self):
- eq = self.assertEqual
- mlist = self._mlist
- mlist.reply_goes_to_list = 1
- mlist.first_strip_reply_to = 1
- msg = email.message_from_string("""\
-From: aperson@example.org
-Reply-To: bperson@example.com
-
-""", Message.Message)
- CookHeaders.process(mlist, msg, {})
- eq(msg['reply-to'], '_xtest@example.com')
- eq(msg.get_all('reply-to'), ['_xtest@example.com'])
-
- def test_reply_to_explicit(self):
- eq = self.assertEqual
- mlist = self._mlist
- mlist.reply_goes_to_list = 2
- mlist.reply_to_address = 'mlist@example.com'
- msg = email.message_from_string("""\
-From: aperson@example.org
-
-""", Message.Message)
- CookHeaders.process(mlist, msg, {})
- eq(msg['reply-to'], 'mlist@example.com')
- eq(msg.get_all('reply-to'), ['mlist@example.com'])
-
- def test_reply_to_explicit_with_strip(self):
- eq = self.assertEqual
- mlist = self._mlist
- mlist.reply_goes_to_list = 2
- mlist.first_strip_reply_to = 1
- mlist.reply_to_address = 'mlist@example.com'
- msg = email.message_from_string("""\
-From: aperson@example.org
-Reply-To: bperson@example.com
-
-""", Message.Message)
- CookHeaders.process(self._mlist, msg, {})
- eq(msg['reply-to'], 'mlist@example.com')
- eq(msg.get_all('reply-to'), ['mlist@example.com'])
-
- def test_reply_to_extends_to_list(self):
- eq = self.assertEqual
- mlist = self._mlist
- mlist.reply_goes_to_list = 1
- mlist.first_strip_reply_to = 0
- msg = email.message_from_string("""\
-From: aperson@example.org
-Reply-To: bperson@example.com
-
-""", Message.Message)
- CookHeaders.process(mlist, msg, {})
- eq(msg['reply-to'], 'bperson@example.com, _xtest@example.com')
-
- def test_reply_to_extends_to_explicit(self):
- eq = self.assertEqual
- mlist = self._mlist
- mlist.reply_goes_to_list = 2
- mlist.first_strip_reply_to = 0
- mlist.reply_to_address = 'mlist@example.com'
- msg = email.message_from_string("""\
-From: aperson@example.org
-Reply-To: bperson@example.com
-
-""", Message.Message)
- CookHeaders.process(mlist, msg, {})
- eq(msg['reply-to'], 'mlist@example.com, bperson@example.com')
-
- def test_list_headers_nolist(self):
- eq = self.assertEqual
- msg = email.message_from_string("""\
-From: aperson@example.org
-
-""", Message.Message)
- CookHeaders.process(self._mlist, msg, {'_nolist': 1})
- eq(msg['list-id'], None)
- eq(msg['list-help'], None)
- eq(msg['list-unsubscribe'], None)
- eq(msg['list-subscribe'], None)
- eq(msg['list-post'], None)
- eq(msg['list-archive'], None)
-
- def test_list_headers(self):
- eq = self.assertEqual
- self._mlist.archive = 1
- msg = email.message_from_string("""\
-From: aperson@example.org
-
-""", Message.Message)
- oldval = config.DEFAULT_URL_HOST
- config.DEFAULT_URL_HOST = 'www.example.com'
- try:
- CookHeaders.process(self._mlist, msg, {})
- finally:
- config.DEFAULT_URL_HOST = oldval
- eq(msg['list-id'], '<_xtest.example.com>')
- eq(msg['list-help'], '<mailto:_xtest-request@example.com?subject=help>')
- eq(msg['list-unsubscribe'],
- '<http://www.example.com/mailman/listinfo/_xtest@example.com>,'
- '\n\t<mailto:_xtest-request@example.com?subject=unsubscribe>')
- eq(msg['list-subscribe'],
- '<http://www.example.com/mailman/listinfo/_xtest@example.com>,'
- '\n\t<mailto:_xtest-request@example.com?subject=subscribe>')
- eq(msg['list-post'], '<mailto:_xtest@example.com>')
- eq(msg['list-archive'],
- '<http://www.example.com/pipermail/_xtest@example.com>')
-
- def test_list_headers_with_description(self):
- eq = self.assertEqual
- self._mlist.archive = 1
- self._mlist.description = 'A Test List'
- msg = email.message_from_string("""\
-From: aperson@example.org
-
-""", Message.Message)
- CookHeaders.process(self._mlist, msg, {})
- eq(unicode(msg['list-id']), u'A Test List <_xtest.example.com>')
- eq(msg['list-help'], '<mailto:_xtest-request@example.com?subject=help>')
- eq(msg['list-unsubscribe'],
- '<http://www.example.com/mailman/listinfo/_xtest@example.com>,'
- '\n\t<mailto:_xtest-request@example.com?subject=unsubscribe>')
- eq(msg['list-subscribe'],
- '<http://www.example.com/mailman/listinfo/_xtest@example.com>,'
- '\n\t<mailto:_xtest-request@example.com?subject=subscribe>')
- eq(msg['list-post'], '<mailto:_xtest@example.com>')
-
-
-
class TestFileRecips(TestBase):
def test_short_circuit(self):
msgdata = {'recips': 1}
@@ -1700,12 +1051,7 @@ Mailman rocks!
def test_suite():
suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(TestAcknowledge))
- suite.addTest(unittest.makeSuite(TestAfterDelivery))
suite.addTest(unittest.makeSuite(TestApprove))
- suite.addTest(unittest.makeSuite(TestCalcRecips))
- suite.addTest(unittest.makeSuite(TestCleanse))
- suite.addTest(unittest.makeSuite(TestCookHeaders))
suite.addTest(unittest.makeSuite(TestFileRecips))
suite.addTest(unittest.makeSuite(TestHold))
suite.addTest(unittest.makeSuite(TestMimeDel))
diff --git a/Mailman/testing/test_listmanager.py b/Mailman/testing/test_listmanager.py
index 165018fa6..e6e9d6a3b 100644
--- a/Mailman/testing/test_listmanager.py
+++ b/Mailman/testing/test_listmanager.py
@@ -17,12 +17,11 @@
"""Doctest harness for testing mailing list creation and deletion."""
-import doctest
import unittest
+from Mailman.testing.base import make_docfile_suite
def test_suite():
suite = unittest.TestSuite()
- suite.addTest(doctest.DocFileSuite('../docs/listmanager.txt',
- optionflags=doctest.ELLIPSIS))
+ suite.addTest(make_docfile_suite('../docs/listmanager.txt'))
return suite
diff --git a/Mailman/testing/test_membership.py b/Mailman/testing/test_membership.py
index 8e8285034..810a2fed9 100644
--- a/Mailman/testing/test_membership.py
+++ b/Mailman/testing/test_membership.py
@@ -28,7 +28,7 @@ from Mailman import passwords
from Mailman.Errors import NotAMemberError
from Mailman.UserDesc import UserDesc
from Mailman.configuration import config
-from Mailman.testing.base import TestBase
+from Mailman.testing.base import TestBase, make_docfile_suite
@@ -387,6 +387,5 @@ class TestMembers(TestBase):
def test_suite():
suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(TestNoMembers))
- suite.addTest(unittest.makeSuite(TestMembers))
+ suite.addTest(make_docfile_suite('../docs/membership.txt'))
return suite
diff --git a/Mailman/testing/test_mlist_addresses.py b/Mailman/testing/test_mlist_addresses.py
index fe32c12b2..1998f33ee 100644
--- a/Mailman/testing/test_mlist_addresses.py
+++ b/Mailman/testing/test_mlist_addresses.py
@@ -17,12 +17,11 @@
"""Doctest harness for the IMailingListAddresses interface."""
-import doctest
import unittest
+from Mailman.testing.base import make_docfile_suite
def test_suite():
suite = unittest.TestSuite()
- suite.addTest(doctest.DocFileSuite('../docs/mlist-addresses.txt',
- optionflags=doctest.ELLIPSIS))
+ suite.addTest(make_docfile_suite('../docs/mlist-addresses.txt'))
return suite
diff --git a/Mailman/testing/test_replybot.py b/Mailman/testing/test_replybot.py
index 6b371c9d0..9f5d454a6 100644
--- a/Mailman/testing/test_replybot.py
+++ b/Mailman/testing/test_replybot.py
@@ -17,16 +17,11 @@
"""Doctest harness for testing the replybot handler."""
-import doctest
import unittest
-
-options = (doctest.ELLIPSIS
- | doctest.NORMALIZE_WHITESPACE
- | doctest.REPORT_NDIFF)
+from Mailman.testing.base import make_docfile_suite
def test_suite():
suite = unittest.TestSuite()
- suite.addTest(doctest.DocFileSuite('../docs/replybot.txt',
- optionflags=options))
+ suite.addTest(make_docfile_suite('../docs/replybot.txt'))
return suite
diff --git a/Mailman/testing/test_user.py b/Mailman/testing/test_user.py
index 1c075a164..b66efac62 100644
--- a/Mailman/testing/test_user.py
+++ b/Mailman/testing/test_user.py
@@ -17,14 +17,11 @@
"""Doctest harness for testing users."""
-import doctest
import unittest
-
-options = doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE
+from Mailman.testing.base import make_docfile_suite
def test_suite():
suite = unittest.TestSuite()
- suite.addTest(doctest.DocFileSuite('../docs/users.txt',
- optionflags=options))
+ suite.addTest(make_docfile_suite('../docs/users.txt'))
return suite
diff --git a/Mailman/testing/test_usermanager.py b/Mailman/testing/test_usermanager.py
index fa115728e..9b98a6689 100644
--- a/Mailman/testing/test_usermanager.py
+++ b/Mailman/testing/test_usermanager.py
@@ -17,12 +17,11 @@
"""Doctest harness for testing mailing list creation and deletion."""
-import doctest
import unittest
+from Mailman.testing.base import make_docfile_suite
def test_suite():
suite = unittest.TestSuite()
- suite.addTest(doctest.DocFileSuite('../docs/usermanager.txt',
- optionflags=doctest.ELLIPSIS))
+ suite.addTest(make_docfile_suite('../docs/usermanager.txt'))
return suite