diff options
| author | Barry Warsaw | 2009-07-10 21:55:26 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2009-07-10 21:55:26 -0400 |
| commit | ac3af23142c9b2417759f90837d68e15866b6793 (patch) | |
| tree | 8c40fb498d2835750eef6277312b20568340b8c1 /src/mailman/testing/layers.py | |
| parent | c01da236a31f104b3752351ae93956f87b79d821 (diff) | |
| download | mailman-ac3af23142c9b2417759f90837d68e15866b6793.tar.gz mailman-ac3af23142c9b2417759f90837d68e15866b6793.tar.zst mailman-ac3af23142c9b2417759f90837d68e15866b6793.zip | |
Diffstat (limited to 'src/mailman/testing/layers.py')
| -rw-r--r-- | src/mailman/testing/layers.py | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/mailman/testing/layers.py b/src/mailman/testing/layers.py index 9e4364a7a..1765efc4e 100644 --- a/src/mailman/testing/layers.py +++ b/src/mailman/testing/layers.py @@ -32,20 +32,23 @@ import os import sys import shutil import logging +import datetime import tempfile from pkg_resources import resource_string from textwrap import dedent +from urllib2 import urlopen, URLError from mailman.config import config from mailman.core import initialize from mailman.core.logging import get_handler from mailman.i18n import _ -from mailman.testing.helpers import SMTPServer +from mailman.testing.helpers import SMTPServer, TestableMaster from mailman.utilities.datetime import factory from mailman.utilities.string import expand +TEST_TIMEOUT = datetime.timedelta(seconds=5) NL = '\n' @@ -230,12 +233,25 @@ class RESTLayer(SMTPLayer): server = None + @staticmethod + def _wait_for_rest_server(): + until = datetime.datetime.now() + TEST_TIMEOUT + while datetime.datetime.now() < until: + try: + fp = urlopen('http://localhost:8001/3.0/system') + except URLError: + pass + else: + fp.close() + break + else: + raise RuntimeError('REST server did not start up') + @classmethod def setUp(cls): assert cls.server is None, 'Layer already set up' - from mailman.rest.testing.server import TestableServer - cls.server = TestableServer() - cls.server.start() + cls.server = TestableMaster(cls._wait_for_rest_server) + cls.server.start('rest') @classmethod def tearDown(cls): |
