Merge lp:~barry/lazr.smtptest/393621-reset into lp:lazr.smtptest

Proposed by Barry Warsaw
Status: Merged
Merged at revision: not available
Proposed branch: lp:~barry/lazr.smtptest/393621-reset
Merge into: lp:lazr.smtptest
Diff against target: None lines
To merge this branch: bzr merge lp:~barry/lazr.smtptest/393621-reset
Reviewer Review Type Date Requested Status
Francis J. Lacoste (community) Approve
Review via email: mp+8037@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Barry Warsaw (barry) wrote :

Yet another small improvement; QueueServer can do a rest() to clear its queue.

Revision history for this message
Barry Warsaw (barry) wrote :

> Yet another small improvement; QueueServer can do a rest() to clear its queue.

Er, that's "reset()", i.e. SMTP RSET.

Revision history for this message
Francis J. Lacoste (flacoste) wrote :

Add a CHANGES.txt entry for this change and you are good to release!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/lazr/smtptest/__init__.py'
2--- src/lazr/smtptest/__init__.py 2009-06-24 15:10:31 +0000
3+++ src/lazr/smtptest/__init__.py 2009-06-30 00:40:38 +0000
4@@ -17,4 +17,4 @@
5 "The lazr.smtptest package."
6
7
8-__version__ = '1.1'
9+__version__ = '1.2'
10
11=== modified file 'src/lazr/smtptest/controller.py'
12--- src/lazr/smtptest/controller.py 2009-06-24 15:10:31 +0000
13+++ src/lazr/smtptest/controller.py 2009-06-30 00:40:38 +0000
14@@ -99,6 +99,7 @@
15 :type port: int
16 """
17 self.queue = Queue()
18+ self.server = None
19 self._make_server(host, port)
20 super(QueueController, self).__init__(self.server)
21
22
23=== modified file 'src/lazr/smtptest/docs/queue.txt'
24--- src/lazr/smtptest/docs/queue.txt 2009-06-18 13:19:51 +0000
25+++ src/lazr/smtptest/docs/queue.txt 2009-06-30 00:40:38 +0000
26@@ -154,6 +154,42 @@
27 ... print message['message-id']
28 <kangaroo>
29
30+
31+Resetting
32+=========
33+
34+Queue servers support a RSET (reset) method, which empties the queue.
35+
36+ >>> smtpd.sendmail('wperson@example.com', ['xperson@example.com'], """\
37+ ... From: Wynn Person <wperson@example.com>
38+ ... To: Xerx Person <xperson@example.com>
39+ ... Subject: A test
40+ ... Message-ID: <llama>
41+ ...
42+ ... This is a test.
43+ ... """)
44+ {}
45+
46+ >>> smtpd.sendmail('yperson@example.com', ['zperson@example.com'], """\
47+ ... From: Yikes Person <yperson@example.com>
48+ ... To: Zell Person <zperson@example.com>
49+ ... Subject: A test
50+ ... Message-ID: <moose>
51+ ...
52+ ... This is a test.
53+ ... """)
54+ {}
55+
56+ >>> controller.queue.qsize()
57+ 2
58+ >>> controller.reset()
59+ >>> controller.queue.qsize()
60+ 0
61+
62+
63+Clean up
64+========
65+
66 We're done with this controller.
67
68 >>> controller.stop()
69
70=== modified file 'src/lazr/smtptest/server.py'
71--- src/lazr/smtptest/server.py 2009-06-18 05:12:56 +0000
72+++ src/lazr/smtptest/server.py 2009-06-30 00:40:38 +0000
73@@ -28,6 +28,7 @@
74 import logging
75 import asyncore
76
77+from Queue import Empty
78 from email import message_from_string
79
80
81@@ -139,7 +140,7 @@
82 :type port: int
83 :param queue: The queue to put messages in.
84 :type queue: object with a .put() method taking a single message
85- object.
86+ object.
87 """
88 Server.__init__(self, host, port)
89 self.queue = queue
90@@ -147,3 +148,11 @@
91 def handle_message(self, message):
92 """See `Server.handle_message()`."""
93 self.queue.put(message)
94+
95+ def reset(self):
96+ """See `Server.reset()`."""
97+ while True:
98+ try:
99+ self.queue.get_nowait()
100+ except Empty:
101+ break

Subscribers

People subscribed via source and target branches

to all changes: