diff options
| author | Barry Warsaw | 2014-11-09 07:52:58 -0500 |
|---|---|---|
| committer | Barry Warsaw | 2014-11-09 07:52:58 -0500 |
| commit | 75f8476bee354a9d1a4fc2492f39a06b51d07481 (patch) | |
| tree | 254672b17a6a040a5cd6e88255c2365d235b4dcd | |
| parent | 4c8435727449e6cfe64e489a75fa5ec1e63f7f21 (diff) | |
| download | mailman-75f8476bee354a9d1a4fc2492f39a06b51d07481.tar.gz mailman-75f8476bee354a9d1a4fc2492f39a06b51d07481.tar.zst mailman-75f8476bee354a9d1a4fc2492f39a06b51d07481.zip | |
| -rw-r--r-- | src/mailman/app/docs/hooks.rst | 9 | ||||
| -rw-r--r-- | src/mailman/config/tests/test_configuration.py | 11 | ||||
| -rw-r--r-- | src/mailman/core/initialize.py | 8 | ||||
| -rw-r--r-- | src/mailman/docs/DATABASE.rst | 21 | ||||
| -rw-r--r-- | src/mailman/docs/NEWS.rst | 3 | ||||
| -rw-r--r-- | src/mailman/docs/START.rst | 33 | ||||
| -rw-r--r-- | src/mailman/testing/testing.cfg | 5 | ||||
| -rw-r--r-- | src/mailman/utilities/importer.py | 3 | ||||
| -rw-r--r-- | tox.ini | 8 |
9 files changed, 68 insertions, 33 deletions
diff --git a/src/mailman/app/docs/hooks.rst b/src/mailman/app/docs/hooks.rst index ca33f55fe..eb6cbac05 100644 --- a/src/mailman/app/docs/hooks.rst +++ b/src/mailman/app/docs/hooks.rst @@ -53,11 +53,14 @@ script that will produce no output to force the hooks to run. >>> from mailman.testing.layers import ConfigLayer >>> def call(): ... exe = os.path.join(os.path.dirname(sys.executable), 'mailman') + ... env = dict(MAILMAN_CONFIG_FILE=config_path, + ... PYTHONPATH=config_directory) + ... test_cfg = os.environ.get('MAILMAN_EXTRA_TESTING_CFG') + ... if test_cfg is not None: + ... env['MAILMAN_EXTRA_TESTING_CFG'] = test_cfg ... proc = subprocess.Popen( ... [exe, 'lists', '--domain', 'ignore', '-q'], - ... cwd=ConfigLayer.root_directory, - ... env=dict(MAILMAN_CONFIG_FILE=config_path, - ... PYTHONPATH=config_directory), + ... cwd=ConfigLayer.root_directory, env=env, ... stdout=subprocess.PIPE, stderr=subprocess.PIPE) ... stdout, stderr = proc.communicate() ... assert proc.returncode == 0, stderr diff --git a/src/mailman/config/tests/test_configuration.py b/src/mailman/config/tests/test_configuration.py index ee4827041..f3a49d64f 100644 --- a/src/mailman/config/tests/test_configuration.py +++ b/src/mailman/config/tests/test_configuration.py @@ -53,13 +53,12 @@ class TestConfiguration(unittest.TestCase): if isinstance(event, ConfigurationUpdatedEvent): # Record both the event and the top overlay. events.append(event.config.overlays[0].name) + # Do two pushes, and then pop one of them. with event_subscribers(on_event): - with configuration('test', _configname='my test'): - pass - # There should be two pushed configuration names on the list now, one - # for the push leaving 'my test' on the top of the stack, and one for - # the pop, leaving the ConfigLayer's 'test config' on top. - self.assertEqual(events, ['my test', 'test config']) + with configuration('test', _configname='first'): + with configuration('test', _configname='second'): + pass + self.assertEqual(events, ['first', 'second', 'first']) diff --git a/src/mailman/core/initialize.py b/src/mailman/core/initialize.py index 6f1e10068..c2395db10 100644 --- a/src/mailman/core/initialize.py +++ b/src/mailman/core/initialize.py @@ -129,6 +129,14 @@ def initialize_1(config_path=None): # For the test suite, force this back to not using a config file. config_path = None mailman.config.config.load(config_path) + # Use this environment variable to define an extra configuration file for + # testing. This is used by the tox.ini to run the full test suite under + # PostgreSQL. + extra_cfg_path = os.environ.get('MAILMAN_EXTRA_TESTING_CFG') + if extra_cfg_path is not None: + with open(extra_cfg_path) as fp: + extra_cfg = fp.read().decode('utf-8') + mailman.config.config.push('extra testing config', extra_cfg) def initialize_2(debug=False, propagate_logs=None, testing=False): diff --git a/src/mailman/docs/DATABASE.rst b/src/mailman/docs/DATABASE.rst index 7e198cd81..688a989e6 100644 --- a/src/mailman/docs/DATABASE.rst +++ b/src/mailman/docs/DATABASE.rst @@ -2,10 +2,10 @@ Setting up your database ======================== -Mailman uses the Storm_ ORM to provide persistence of data in a relational -database. By default, Mailman uses Python's built-in SQLite3_ database, -however, Storm is compatible with PostgreSQL_ and MySQL, among possibly -others. +Mailman uses the SQLAlchemy_ ORM to provide persistence of data in a +relational database. By default, Mailman uses Python's built-in SQLite3_ +database, however, SQLAlchemy is compatible with PostgreSQL_ and MySQL, among +possibly others. Currently, Mailman is known to work with either the default SQLite3 database, or PostgreSQL. (Volunteers to port it to other databases are welcome!). If @@ -14,9 +14,9 @@ you want Mailman to use PostgreSQL, you'll need to set that up first, and then change a configuration variable in your ``/etc/mailman.cfg`` file. Two configuration variables control which database Mailman uses. The first -names the class implementing the database interface. The second names the -Storm URL for connecting to the database. Both variables live in the -``[database]`` section of the configuration file. +names the class implementing the database interface. The second names the URL +for connecting to the database. Both variables live in the ``[database]`` +section of the configuration file. SQLite3 @@ -50,11 +50,6 @@ You would then need to set both the `class` and `url` variables in That should be it. -Note that if you want to run the full test suite against PostgreSQL, you -should make these changes to the ``mailman/testing/testing.cfg`` file (yes, -eventually we'll make this easier), start up PostgreSQL, enter the virtual -environment, and run ``nose2 -vv`` as normal. - If you have any problems, you may need to delete the database and re-create it:: @@ -64,7 +59,7 @@ it:: My thanks to Stephen A. Goss for his contribution of PostgreSQL support. -.. _Storm: http://storm.canonical.com +.. _SQLAlchemy: http://www.sqlalchemy.org/ .. _SQLite3: http://docs.python.org/library/sqlite3.html .. _PostgreSQL: http://www.postgresql.org/ .. _MySQL: http://dev.mysql.com/ diff --git a/src/mailman/docs/NEWS.rst b/src/mailman/docs/NEWS.rst index 2881eaacd..057dcb4ff 100644 --- a/src/mailman/docs/NEWS.rst +++ b/src/mailman/docs/NEWS.rst @@ -32,6 +32,9 @@ Development ----------- * You no longer have to create a virtual environment separately when running the test suite. Just use `tox`. + * You no longer have to edit `src/mailman/testing/testing.cfg` to run the + test suite against PostgreSQL. See `src/mailman/docs/START.rst` for + details. Interfaces ---------- diff --git a/src/mailman/docs/START.rst b/src/mailman/docs/START.rst index 8123a726c..794740c64 100644 --- a/src/mailman/docs/START.rst +++ b/src/mailman/docs/START.rst @@ -68,19 +68,40 @@ and basic client API, Postorius, and HyperKitty. Testing Mailman 3 ================= -To run the Mailman test suite, just use the `tox`_ command. `tox` creates a -virtual environment (virtualenv) for you, installs all the dependencies into -that virtualenv, and runs the test suite from that virtualenv. By default it -does not use the `--system-site-packages` so it downloads everything from the -Cheeseshop. +To run the Mailman test suite, just use the `tox`_ command:: + + $ tox + +`tox` creates a virtual environment (virtualenv) for you, installs all the +dependencies into that virtualenv, and runs the test suite from that +virtualenv. By default it does not use the `--system-site-packages` so it +downloads everything from the Cheeseshop. You do have access to the virtualenv, and you can use this to run individual tests, e.g.:: - % .tox/py27/bin/python -m nose2 -vv -P user + $ .tox/py27/bin/python -m nose2 -vv -P user Use `.tox/py27/bin/python -m nose2 --help` for more options. +If you want to run the full test suite against the PostgreSQL database, set +the database up as described in :doc:`DATABASE`, then create a `postgres.cfg` +file any where you want. This `postgres.cfg` file will contain the +``[database]`` section for PostgreSQL, e.g.:: + + [database] + class: mailman.database.postgresql.PostgreSQLDatabase + url: postgres://myuser:mypassword@mypghost/mailman + +Then run the test suite like so:: + + $ MAILMAN_EXTRA_TESTING_CFG=/path/to/postgres.cfg tox -e pg + +If you want to run an individual test against PostgreSQL, you would do it like +so:: + + $ MAILMAN_EXTRA_TESTING_CFG=/path/to/postgres.cfg .tox/pg/bin/python -m nose2 -vv -P user + Building for development ------------------------ diff --git a/src/mailman/testing/testing.cfg b/src/mailman/testing/testing.cfg index b61b36604..4bb9e93bc 100644 --- a/src/mailman/testing/testing.cfg +++ b/src/mailman/testing/testing.cfg @@ -17,11 +17,6 @@ # A testing configuration. -# For testing against PostgreSQL. -#[database] -#class: mailman.database.postgresql.PostgreSQLDatabase -#url: postgresql://barry:barry@localhost:5432/mailman - [mailman] site_owner: noreply@example.com diff --git a/src/mailman/utilities/importer.py b/src/mailman/utilities/importer.py index 0523bb06f..cc8a0cf44 100644 --- a/src/mailman/utilities/importer.py +++ b/src/mailman/utilities/importer.py @@ -162,11 +162,13 @@ TYPES = dict( default_member_action=member_action_mapping, default_nonmember_action=nonmember_action_mapping, digest_volume_frequency=DigestFrequency, + emergency=bool, encode_ascii_prefixes=bool, filter_action=filter_action_mapping, filter_extensions=list_members_to_unicode, filter_types=list_members_to_unicode, forward_unrecognized_bounces_to=UnrecognizedBounceDisposition, + gateway_to_mail=bool, include_rfc2369_headers=bool, moderator_password=unicode_to_string, newsgroup_moderation=NewsgroupModeration, @@ -176,6 +178,7 @@ TYPES = dict( personalize=Personalization, preferred_language=check_language_code, reply_goes_to_list=ReplyToMunging, + topics_enabled=bool, ) @@ -6,3 +6,11 @@ recreate = True commands = python -m nose2 -v #sitepackages = True usedevelop = True + +# This environment requires you to set up PostgreSQL and create a .cfg file +# somewhere outside of the source tree. +[testenv:pg] +basepython = python2.7 +commands = python -m nose2 -v +usedevelop = True +deps = psycopg2 |
