diff options
| author | Barry Warsaw | 2012-04-02 13:07:21 -0600 |
|---|---|---|
| committer | Barry Warsaw | 2012-04-02 13:07:21 -0600 |
| commit | 2c4779c884d2bb09bed6838b7b5cd938d5755f2e (patch) | |
| tree | d72e1b7db3922a02b579b56ee11e0c22c6111ad6 /src/mailman/testing | |
| parent | acd5b05d06248b66752122d4c74cac0f5352f815 (diff) | |
| download | mailman-2c4779c884d2bb09bed6838b7b5cd938d5755f2e.tar.gz mailman-2c4779c884d2bb09bed6838b7b5cd938d5755f2e.tar.zst mailman-2c4779c884d2bb09bed6838b7b5cd938d5755f2e.zip | |
Diffstat (limited to 'src/mailman/testing')
| -rw-r--r-- | src/mailman/testing/helpers.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/mailman/testing/helpers.py b/src/mailman/testing/helpers.py index ca0b14b18..8295ef3a8 100644 --- a/src/mailman/testing/helpers.py +++ b/src/mailman/testing/helpers.py @@ -29,6 +29,7 @@ __all__ = [ 'digest_mbox', 'event_subscribers', 'get_lmtp_client', + 'get_nntp_server', 'get_queue_messages', 'make_testable_runner', 'reset_the_world', @@ -40,6 +41,7 @@ __all__ = [ import os import json +import mock import time import uuid import errno @@ -253,6 +255,24 @@ def get_lmtp_client(quiet=False): +def get_nntp_server(cleanups): + """Create and start an NNTP server mock. + + This can be used to retrieve the posted message for verification. + """ + patcher = mock.patch('nntplib.NNTP') + server_class = patcher.start() + cleanups.append(patcher.stop) + nntpd = server_class() + # A class for more convenient access to the posted message. + class NNTPProxy: + def get_message(self): + args = nntpd.post.call_args + return specialized_message_from_string(args[0][0].read()) + return NNTPProxy() + + + def wait_for_webservice(): """Wait for the REST server to start serving requests.""" until = datetime.datetime.now() + as_timedelta(config.devmode.wait) |
