~barry/mailman/events-and-web

« back to all changes in this revision

Viewing changes to src/mailman/runners/tests/test_confirm.py

  • Committer: Barry Warsaw
  • Date: 2012-04-22 21:33:33 UTC
  • mfrom: (7150.1.11 transactions)
  • Revision ID: barry@list.org-20120422213333-3skjqsjktooesgsl
Several non-functional improvements to the code base.

Reduce the explicit use of the config.db global by introducing two new
helpers:
 - A new transaction() context manager which will commit the transaction on
   successful exit, otherwise it will abort the transaction
 - A new dbconnection decorator which calls the decorated method with the
   Storm store object as the first argument (after self).  This can be used
   instead of config.db.store.

By reducing the explicit use of this global, we have a better chance of
refactoring it away in the future.  Still TODO: runner.py and lmtp.py.

Be explicit about the `store` attribute on the IDatabase interface.

More consistent use of __future__ imports.

Remove an obsolete command line script.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
 
33
33
from mailman.app.lifecycle import create_list
34
34
from mailman.config import config
 
35
from mailman.database.transaction import transaction
35
36
from mailman.interfaces.registrar import IRegistrar
36
37
from mailman.interfaces.usermanager import IUserManager
37
38
from mailman.runners.command import CommandRunner
50
51
    layer = ConfigLayer
51
52
 
52
53
    def setUp(self):
53
 
        # Register a subscription requiring confirmation.
54
54
        registrar = getUtility(IRegistrar)
55
 
        self._mlist = create_list('test@example.com')
56
 
        self._mlist.send_welcome_message = False
57
 
        self._token = registrar.register(self._mlist, 'anne@example.org')
58
55
        self._commandq = config.switchboards['command']
59
56
        self._runner = make_testable_runner(CommandRunner, 'command')
60
 
        config.db.commit()
 
57
        with transaction():
 
58
            # Register a subscription requiring confirmation.
 
59
            self._mlist = create_list('test@example.com')
 
60
            self._mlist.send_welcome_message = False
 
61
            self._token = registrar.register(self._mlist, 'anne@example.org')
61
62
 
62
63
    def test_confirm_with_re_prefix(self):
63
64
        subject = 'Re: confirm {0}'.format(self._token)