summaryrefslogtreecommitdiff
path: root/mailman/testing
diff options
context:
space:
mode:
authorBarry Warsaw2008-12-23 17:33:37 -0500
committerBarry Warsaw2008-12-23 17:33:37 -0500
commitd4de7996e6d4fb5db04dfed3b3fd12747622b164 (patch)
treeda5485447a128a0dd857a2a492168deec838362b /mailman/testing
parentfd600d3952393dc9808fefb9be871f78cdbdff39 (diff)
downloadmailman-d4de7996e6d4fb5db04dfed3b3fd12747622b164.tar.gz
mailman-d4de7996e6d4fb5db04dfed3b3fd12747622b164.tar.zst
mailman-d4de7996e6d4fb5db04dfed3b3fd12747622b164.zip
Use my lazr.config megamerge branch for now, even though it's still under
development. Completely rework the way switchboards and queue runners are initialized, i.e. driven from the configuration file instead of hard coded. The various queue runner directories are no longer available thorugh the config object directly. Get them from config.switchboards. Provide minimal mailman.cfg and testing.cfg configuration files. Neuter styles for now until they can be consolidated with lazr.config.
Diffstat (limited to 'mailman/testing')
-rw-r--r--mailman/testing/helpers.py9
-rw-r--r--mailman/testing/layers.py42
-rw-r--r--mailman/testing/testing.cfg66
-rw-r--r--mailman/testing/testing.cfg.in17
4 files changed, 82 insertions, 52 deletions
diff --git a/mailman/testing/helpers.py b/mailman/testing/helpers.py
index 0f9c3edae..2f5b4af01 100644
--- a/mailman/testing/helpers.py
+++ b/mailman/testing/helpers.py
@@ -58,14 +58,19 @@ def make_testable_runner(runner_class):
:return: A runner instance.
"""
+ assert runner_class.__name__.endswith('Runner'), (
+ 'Unparseable runner class name: %s' % runner_class.__name__)
+
+ name = runner_class.__name__[:-6].lower()
+
class EmptyingRunner(runner_class):
"""Stop processing when the queue is empty."""
def _do_periodic(self):
"""Stop when the queue is empty."""
- self._stop = (len(self._switchboard.files) == 0)
+ self._stop = (len(self.switchboard.files) == 0)
- return EmptyingRunner()
+ return EmptyingRunner(name)
diff --git a/mailman/testing/layers.py b/mailman/testing/layers.py
index 97d6ade23..bda18289c 100644
--- a/mailman/testing/layers.py
+++ b/mailman/testing/layers.py
@@ -27,7 +27,9 @@ __all__ = [
import os
import shutil
import tempfile
-import textwrap
+
+from pkg_resources import resource_string
+from textwrap import dedent
from mailman.config import config
from mailman.core.initialize import initialize
@@ -47,45 +49,19 @@ class ConfigLayer:
def setUp(cls):
initialize()
assert cls.var_dir is None, 'Layer already set up'
- test_config = []
# Calculate a temporary VAR_DIR directory so that run-time artifacts
# of the tests won't tread on the installation's data. This also
# makes it easier to clean up after the tests are done, and insures
# isolation of test suite runs.
cls.var_dir = tempfile.mkdtemp()
- # lazr.config says it doesn't care about indentation, but we've
- # actually got mixed indentation above because of the for-loop. It's
- # just safer to dedent the whole string now.
- test_config.append(textwrap.dedent("""
+ # Create a section with the var directory.
+ test_config = dedent("""
[mailman]
var_dir: %s
- """ % cls.var_dir))
- # Push a high port for our test SMTP server.
- test_config.append(textwrap.dedent("""
- [mta]
- smtp_port: 9025
- """))
- # Set the qrunners to exit after one error.
- for qrunner in config.qrunner_shortcuts:
- test_config.append(textwrap.dedent("""
- [qrunner.%s]
- max_restarts: 1
- """ % qrunner))
- # Add stuff for the archiver and a sample domain.
- test_config.append(textwrap.dedent("""
- [archiver.mail_archive]
- base_url: http://go.mail-archive.dev/
- recipient: archive@mail-archive.dev
-
- [domain.example_dot_com]
- email_host: example.com
- base_url: http://www.example.com
- contact_address: postmaster@example.com
- """))
- config_string = NL.join(test_config)
- import pdb; pdb.set_trace()
- config.push('test config', config_string)
- config._config.getByCategory('domain')
+ """ % cls.var_dir)
+ # Read the testing config, but don't push it yet.
+ test_config += resource_string('mailman.testing', 'testing.cfg')
+ config.push('test config', test_config)
@classmethod
def tearDown(cls):
diff --git a/mailman/testing/testing.cfg b/mailman/testing/testing.cfg
new file mode 100644
index 000000000..baac7d803
--- /dev/null
+++ b/mailman/testing/testing.cfg
@@ -0,0 +1,66 @@
+# Copyright (C) 2008 by the Free Software Foundation, Inc.
+#
+# This file is part of GNU Mailman.
+#
+# GNU Mailman is free software: you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option)
+# any later version.
+#
+# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+# more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# GNU Mailman. If not, see <http://www.gnu.org/licenses/>.
+
+# A testing configuration.
+
+[mta]
+smtp_port: 9025
+
+[qrunner.archive]
+max_restarts: 1
+
+[qrunner.bounces]
+max_restarts: 1
+
+[qrunner.commands]
+max_restarts: 1
+
+[qrunner.in]
+max_restarts: 1
+
+[qrunner.lmtp]
+max_restarts: 1
+
+[qrunner.maildir]
+max_restarts: 1
+
+[qrunner.news]
+max_restarts: 1
+
+[qrunner.out]
+max_restarts: 1
+
+[qrunner.pipeline]
+max_restarts: 1
+
+[qrunner.retry]
+max_restarts: 1
+
+[qrunner.shunt]
+max_restarts: 1
+
+[qrunner.virgin]
+max_restarts: 1
+
+[archiver.mail_archive]
+base_url: http://go.mail-archive.dev/
+recipient: archive@mail-archive.dev
+
+[domain.example_dot_com]
+email_host: example.com
+base_url: http://www.example.com
+contact_address: postmaster@example.com
diff --git a/mailman/testing/testing.cfg.in b/mailman/testing/testing.cfg.in
deleted file mode 100644
index e544242d0..000000000
--- a/mailman/testing/testing.cfg.in
+++ /dev/null
@@ -1,17 +0,0 @@
-# -*- python -*-
-
-# Configuration file template for the unit test suite. We need this because
-# both the process running the tests and all sub-processes (e.g. qrunners)
-# must share the same configuration file.
-
-MAX_RESTARTS = 1
-MTA = None
-USE_LMTP = Yes
-
-# Make sure these goes to fake domains.
-MAIL_ARCHIVE_BASEURL = 'http://go.mail-archive.dev/'
-MAIL_ARCHIVE_RECIPIENT = 'archive@mail-archive.dev'
-
-add_domain('example.com', 'http://www.example.com')
-
-# bin/testall will add additional runtime configuration variables here.