diff options
| author | Barry Warsaw | 2007-06-19 11:13:09 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2007-06-19 11:13:09 -0400 |
| commit | 0514aa46113f1f44dcf86f2d8ae6f86b71e88a3d (patch) | |
| tree | 67fe896a40781ed0a64656c3f0fce0fd4278240f /Mailman/testing | |
| parent | c7d4e4c593d3bb1356fc099581d6f3e3deb0c1d4 (diff) | |
| download | mailman-0514aa46113f1f44dcf86f2d8ae6f86b71e88a3d.tar.gz mailman-0514aa46113f1f44dcf86f2d8ae6f86b71e88a3d.tar.zst mailman-0514aa46113f1f44dcf86f2d8ae6f86b71e88a3d.zip | |
Convert the tests for the CalcRecips handler to doc tests. There are
some XXX's in the doc test because digest recipients aren't tested
(though those may go in a different doctest), and neither are urgent
messages. This latter is for the same reason that the Approved
handler is not yet tested; which password do you use in that header?
The CalcRecips tests would also seem the natural place to test the
receive_list_copy preference, but that actually gets processed in the
AvoidDuplicates handler, so it isn't tested here.
Add delivery_status (of type enum DeliveryStatus) to preferences. I'm
not entirely sure that's the right place for it, but it lets me finish
converting the test for now.
Expose the rest of the preferences through the IMember interface.
Diffstat (limited to 'Mailman/testing')
| -rw-r--r-- | Mailman/testing/test_after_delivery.py | 2 | ||||
| -rw-r--r-- | Mailman/testing/test_calc_recips.py | 32 | ||||
| -rw-r--r-- | Mailman/testing/test_handlers.py | 98 |
3 files changed, 33 insertions, 99 deletions
diff --git a/Mailman/testing/test_after_delivery.py b/Mailman/testing/test_after_delivery.py index 0abad5d6e..ea4801b39 100644 --- a/Mailman/testing/test_after_delivery.py +++ b/Mailman/testing/test_after_delivery.py @@ -15,7 +15,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, # USA. -"""Doctest harness for testing booking done after message delivery.""" +"""Doctest harness for testing bookkeeping done after message delivery.""" import doctest import unittest diff --git a/Mailman/testing/test_calc_recips.py b/Mailman/testing/test_calc_recips.py new file mode 100644 index 000000000..7e876d428 --- /dev/null +++ b/Mailman/testing/test_calc_recips.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 testing the recipient calculation handler.""" + +import doctest +import unittest + +options = (doctest.ELLIPSIS + | doctest.NORMALIZE_WHITESPACE + | doctest.REPORT_NDIFF) + + +def test_suite(): + suite = unittest.TestSuite() + suite.addTest(doctest.DocFileSuite('../docs/calc-recips.txt', + optionflags=options)) + return suite diff --git a/Mailman/testing/test_handlers.py b/Mailman/testing/test_handlers.py index 9c236584f..bbc7f5ba8 100644 --- a/Mailman/testing/test_handlers.py +++ b/Mailman/testing/test_handlers.py @@ -39,7 +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 @@ -138,102 +137,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) @@ -1560,7 +1463,6 @@ Mailman rocks! def test_suite(): suite = unittest.TestSuite() 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)) |
