~stephen-xemacs/mailman/sprint-2012-overview

« back to all changes in this revision

Viewing changes to src/mailman/app/tests/test_moderation.py

  • Committer: Barry Warsaw
  • Date: 2012-01-30 15:37:16 UTC
  • Revision ID: barry@list.org-20120130153716-s9qx07i6i0rltyax
 * Held messages can now be moderated through the REST API.  Mailing list
   resources now accept a `held` path component.  GETing this returns all held
   messages for the mailing list.  POSTing to a specific request id under this
   url can dispose of the message using `Action` enums.
 * `IRequests` interface is removed.  Now just use adaptation from
   `IListRequests` directly (which takes an `IMailingList` object).
 * `handle_message()` now allows for `Action.hold` which is synonymous with
   `Action.defer` (since the message is already being held).
 * `IListRequests.get_request()` now takes an optional `request_type`
   argument to narrow the search for the given request.

- also, print_function is now a standard __future__ import.  The template has
  been updated, but add this to modules as you edit them.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
from mailman.app.lifecycle import create_list
30
30
from mailman.app.moderator import handle_message, hold_message
31
31
from mailman.interfaces.action import Action
 
32
from mailman.interfaces.requests import IListRequests
32
33
from mailman.runners.incoming import IncomingRunner
33
34
from mailman.runners.outgoing import OutgoingRunner
34
35
from mailman.runners.pipeline import PipelineRunner
95
96
        # envelope.
96
97
        self.assertEqual(message['x-mailfrom'], 'test-bounces@example.com')
97
98
        self.assertEqual(message['x-rcptto'], 'bart@example.com')
 
99
 
 
100
    def test_hold_action_alias_for_defer(self):
 
101
        # In handle_message(), the 'hold' action is the same as 'defer' for
 
102
        # purposes of this API.
 
103
        request_id = hold_message(self._mlist, self._msg)
 
104
        handle_message(self._mlist, request_id, Action.defer)
 
105
        # The message is still in the pending requests.
 
106
        requests_db = IListRequests(self._mlist)
 
107
        key, data = requests_db.get_request(request_id)
 
108
        self.assertEqual(key, '<alpha>')
 
109
        handle_message(self._mlist, request_id, Action.hold)
 
110
        key, data = requests_db.get_request(request_id)
 
111
        self.assertEqual(key, '<alpha>')