summaryrefslogtreecommitdiff
path: root/src/mailman/testing/layers.py
diff options
context:
space:
mode:
authorBarry Warsaw2012-03-13 21:03:01 -0700
committerBarry Warsaw2012-03-13 21:03:01 -0700
commit80ac803cb2816dde0503671fd117ed134680de53 (patch)
treeed2d40855f6b45dedf421a7a98bd83d95b6e3b40 /src/mailman/testing/layers.py
parent07685642934fe934098927a9a9d20c17080f3dab (diff)
downloadmailman-80ac803cb2816dde0503671fd117ed134680de53.tar.gz
mailman-80ac803cb2816dde0503671fd117ed134680de53.tar.zst
mailman-80ac803cb2816dde0503671fd117ed134680de53.zip
Diffstat (limited to 'src/mailman/testing/layers.py')
-rw-r--r--src/mailman/testing/layers.py35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/mailman/testing/layers.py b/src/mailman/testing/layers.py
index 5cee8c8d2..04ab8f91f 100644
--- a/src/mailman/testing/layers.py
+++ b/src/mailman/testing/layers.py
@@ -22,6 +22,7 @@ from __future__ import absolute_import, unicode_literals
__metaclass__ = type
__all__ = [
'ConfigLayer',
+ 'LMTPLayer',
'MockAndMonkeyLayer',
'RESTLayer',
'SMTPLayer',
@@ -48,7 +49,8 @@ from mailman.core import initialize
from mailman.core.initialize import INHIBIT_CONFIG_FILE
from mailman.core.logging import get_handler
from mailman.interfaces.domain import IDomainManager
-from mailman.testing.helpers import TestableMaster, reset_the_world
+from mailman.testing.helpers import (
+ TestableMaster, get_lmtp_client, reset_the_world)
from mailman.testing.mta import ConnectionCountingController
from mailman.utilities.string import expand
@@ -250,6 +252,8 @@ class SMTPLayer(ConfigLayer):
@classmethod
def testSetUp(cls):
+ # Make sure we don't call our superclass's testSetUp(), otherwise the
+ # example.com domain will get added twice.
pass
@classmethod
@@ -259,6 +263,35 @@ class SMTPLayer(ConfigLayer):
+class LMTPLayer(ConfigLayer):
+ """Layer for starting, stopping, and accessing a test LMTP server."""
+
+ lmtpd = None
+
+ @staticmethod
+ def _wait_for_lmtp_server():
+ get_lmtp_client(quiet=True)
+
+ @classmethod
+ def setUp(cls):
+ assert cls.lmtpd is None, 'Layer already set up'
+ cls.lmtpd = TestableMaster(cls._wait_for_lmtp_server)
+ cls.lmtpd.start('lmtp')
+
+ @classmethod
+ def tearDown(cls):
+ assert cls.lmtpd is not None, 'Layer not set up'
+ cls.lmtpd.stop()
+ cls.lmtpd = None
+
+ @classmethod
+ def testSetUp(cls):
+ # Make sure we don't call our superclass's testSetUp(), otherwise the
+ # example.com domain will get added twice.
+ pass
+
+
+
class RESTLayer(SMTPLayer):
"""Layer for starting, stopping, and accessing the test REST layer."""