Merge lp:~postfuturist/mailman/retry-test into lp:mailman

Proposed by Stephen A. Goss
Status: Merged
Merged at revision: 7061
Proposed branch: lp:~postfuturist/mailman/retry-test
Merge into: lp:mailman
Diff against target: 82 lines (+66/-1)
2 files modified
src/mailman/runners/retry.py (+1/-1)
src/mailman/runners/tests/test_retry.py (+65/-0)
To merge this branch: bzr merge lp:~postfuturist/mailman/retry-test
Reviewer Review Type Date Requested Status
Mailman Coders Pending
Review via email: mp+80267@code.launchpad.net

Description of the change

The RetryRunner has a simple but fatal bug. This branch includes a fix, plus a unit test that tests the basic function of the RetryRunner.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/mailman/runners/retry.py'
2--- src/mailman/runners/retry.py 2011-05-29 16:45:19 +0000
3+++ src/mailman/runners/retry.py 2011-10-24 20:32:23 +0000
4@@ -37,7 +37,7 @@
5
6 def _dispose(self, mlist, msg, msgdata):
7 # Move the message to the out queue for another try.
8- config.switchboards['outgoing'].enqueue(msg, msgdata)
9+ config.switchboards['out'].enqueue(msg, msgdata)
10 return False
11
12 def _snooze(self, filecnt):
13
14=== added file 'src/mailman/runners/tests/test_retry.py'
15--- src/mailman/runners/tests/test_retry.py 1970-01-01 00:00:00 +0000
16+++ src/mailman/runners/tests/test_retry.py 2011-10-24 20:32:23 +0000
17@@ -0,0 +1,65 @@
18+# Copyright (C) 2011 by the Free Software Foundation, Inc.
19+#
20+# This file is part of GNU Mailman.
21+#
22+# GNU Mailman is free software: you can redistribute it and/or modify it under
23+# the terms of the GNU General Public License as published by the Free
24+# Software Foundation, either version 3 of the License, or (at your option)
25+# any later version.
26+#
27+# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
28+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
29+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
30+# more details.
31+#
32+# You should have received a copy of the GNU General Public License along with
33+# GNU Mailman. If not, see <http://www.gnu.org/licenses/>.
34+
35+"""Test the retry runner."""
36+
37+from __future__ import absolute_import, unicode_literals
38+
39+__metaclass__ = type
40+__all__ = [
41+ 'test_suite',
42+ ]
43+
44+import unittest
45+
46+from zope.component import getUtility
47+
48+from mailman.app.lifecycle import create_list
49+from mailman.config import config
50+from mailman.runners.retry import RetryRunner
51+from mailman.testing.helpers import (
52+ get_queue_messages,
53+ make_testable_runner,
54+ specialized_message_from_string as message_from_string)
55+from mailman.testing.layers import ConfigLayer
56+
57+
58
59+class TestRetryRunner(unittest.TestCase):
60+ """Test the retry runner."""
61+
62+ layer = ConfigLayer
63+
64+ def setUp(self):
65+ self._mlist = create_list('test@example.com')
66+ self._retryq = config.switchboards['retry']
67+ self._outq = config.switchboards['out']
68+ self._runner = make_testable_runner(RetryRunner, 'retry')
69+ self._msg = message_from_string("""\
70+From: anne@example.com
71+To: test@example.com
72+Message-Id: <first>
73+
74+""")
75+ self._msgdata = dict(listname='test@example.com')
76+
77+ def tearDown(self):
78+ pass
79+
80+ def test_message_put_in_outgoing_queue(self):
81+ self._retryq.enqueue(self._msg, self._msgdata)
82+ self._runner.run()
83+ self.assertEqual(len(get_queue_messages('out')), 1)