diff options
| -rw-r--r-- | Mailman/Handlers/AfterDelivery.py | 4 | ||||
| -rw-r--r-- | Mailman/database/model/mailinglist.py | 2 | ||||
| -rw-r--r-- | Mailman/docs/acknowledge.txt | 10 | ||||
| -rw-r--r-- | Mailman/docs/after-delivery.txt | 43 | ||||
| -rw-r--r-- | Mailman/testing/test_after_delivery.py | 32 | ||||
| -rw-r--r-- | Mailman/testing/test_handlers.py | 14 |
6 files changed, 88 insertions, 17 deletions
diff --git a/Mailman/Handlers/AfterDelivery.py b/Mailman/Handlers/AfterDelivery.py index 5f01c9d49..16caf5773 100644 --- a/Mailman/Handlers/AfterDelivery.py +++ b/Mailman/Handlers/AfterDelivery.py @@ -20,10 +20,10 @@ This module must appear after the delivery module in the message pipeline. """ -import time +import datetime def process(mlist, msg, msgdata): - mlist.last_post_time = time.time() + mlist.last_post_time = datetime.datetime.now() mlist.post_id += 1 diff --git a/Mailman/database/model/mailinglist.py b/Mailman/database/model/mailinglist.py index 4c7492310..cdea9d9f6 100644 --- a/Mailman/database/model/mailinglist.py +++ b/Mailman/database/model/mailinglist.py @@ -50,7 +50,7 @@ class MailingList(Entity): has_field('digest_last_sent_at', Float), has_field('one_last_digest', PickleType), has_field('volume', Integer), - has_field('last_post_time', Float), + has_field('last_post_time', DateTime), # Attributes which are directly modifiable via the web u/i. The more # complicated attributes are currently stored as pickles, though that # will change as the schema and implementation is developed. diff --git a/Mailman/docs/acknowledge.txt b/Mailman/docs/acknowledge.txt index 6c7e3c28f..6f47fd64d 100644 --- a/Mailman/docs/acknowledge.txt +++ b/Mailman/docs/acknowledge.txt @@ -174,3 +174,13 @@ If there is no subject, then the receipt will use a generic message. List info page: http://lists.example.com/listinfo/_xtest@example.com Your preferences: http://example.com/aperson@example.com <BLANKLINE> + + +Clean up +-------- + + >>> for mlist in config.list_manager.mailing_lists: + ... config.list_manager.delete(mlist) + >>> flush() + >>> list(config.list_manager.mailing_lists) + [] diff --git a/Mailman/docs/after-delivery.txt b/Mailman/docs/after-delivery.txt new file mode 100644 index 000000000..ac2472745 --- /dev/null +++ b/Mailman/docs/after-delivery.txt @@ -0,0 +1,43 @@ +After delivery +============== + +After a message is delivered, or more correctly, after it has been processed +by the rest of the handlers in the incoming queue pipeline, a couple of +bookkeeping pieces of information are updated. + + >>> import datetime + >>> from email import message_from_string + >>> from Mailman.Message import Message + >>> from Mailman.Handlers.AfterDelivery import process + >>> from Mailman.configuration import config + >>> from Mailman.database import flush + >>> mlist = config.list_manager.create('_xtest@example.com') + >>> post_time = datetime.datetime.now() - datetime.timedelta(minutes=10) + >>> mlist.last_post_time = post_time + >>> mlist.post_id = 10 + >>> flush() + +Processing a message with this handler updates the last_post_time and post_id +attributes. + + >>> msg = message_from_string("""\ + ... From: aperson@example.com + ... + ... Something interesting. + ... """, Message) + >>> process(mlist, msg, {}) + >>> flush() + >>> mlist.last_post_time > post_time + True + >>> mlist.post_id + 11 + + +Clean up +-------- + + >>> for mlist in config.list_manager.mailing_lists: + ... config.list_manager.delete(mlist) + >>> flush() + >>> list(config.list_manager.mailing_lists) + [] diff --git a/Mailman/testing/test_after_delivery.py b/Mailman/testing/test_after_delivery.py new file mode 100644 index 000000000..0abad5d6e --- /dev/null +++ b/Mailman/testing/test_after_delivery.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 booking done after message delivery.""" + +import doctest +import unittest + +options = (doctest.ELLIPSIS + | doctest.NORMALIZE_WHITESPACE + | doctest.REPORT_NDIFF) + + +def test_suite(): + suite = unittest.TestSuite() + suite.addTest(doctest.DocFileSuite('../docs/after-delivery.txt', + optionflags=options)) + return suite diff --git a/Mailman/testing/test_handlers.py b/Mailman/testing/test_handlers.py index a0a196dae..9c236584f 100644 --- a/Mailman/testing/test_handlers.py +++ b/Mailman/testing/test_handlers.py @@ -62,18 +62,6 @@ def password(cleartext): -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} @@ -1571,8 +1559,6 @@ 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)) |
