summaryrefslogtreecommitdiff
path: root/src/mailman/testing/layers.py
diff options
context:
space:
mode:
authorBarry Warsaw2009-07-10 21:55:26 -0400
committerBarry Warsaw2009-07-10 21:55:26 -0400
commitac3af23142c9b2417759f90837d68e15866b6793 (patch)
tree8c40fb498d2835750eef6277312b20568340b8c1 /src/mailman/testing/layers.py
parentc01da236a31f104b3752351ae93956f87b79d821 (diff)
downloadmailman-ac3af23142c9b2417759f90837d68e15866b6793.tar.gz
mailman-ac3af23142c9b2417759f90837d68e15866b6793.tar.zst
mailman-ac3af23142c9b2417759f90837d68e15866b6793.zip
Clean a few more lints.
Add get_mailing_lists() which is used just for the web interface. Because of a bug in lazr.restful, this cannot be a generator. Similar change in IDomainSet. Instrument IListManager to be vended through the api. The REST server must be run in a separate process since SQLite does not like objects created in one thread to be used in another thread. Note that this breaks the domain.txt test, but domains really need to be in the database anyway.
Diffstat (limited to '')
-rw-r--r--src/mailman/testing/layers.py24
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):