1
# Copyright (C) 2012 by the Free Software Foundation, Inc.
3
# This file is part of GNU Mailman.
5
# GNU Mailman is free software: you can redistribute it and/or modify it under
6
# the terms of the GNU General Public License as published by the Free
7
# Software Foundation, either version 3 of the License, or (at your option)
10
# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
11
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15
# You should have received a copy of the GNU General Public License along with
16
# GNU Mailman. If not, see <http://www.gnu.org/licenses/>.
18
"""Test the various pending requests interfaces."""
20
from __future__ import absolute_import, print_function, unicode_literals
29
from mailman.app.lifecycle import create_list
30
from mailman.app.moderator import hold_message
31
from mailman.interfaces.requests import IListRequests, RequestType
32
from mailman.testing.helpers import specialized_message_from_string as mfs
33
from mailman.testing.layers import ConfigLayer
37
class TestRequests(unittest.TestCase):
41
self._mlist = create_list('ant@example.com')
43
From: anne@example.com
51
def test_get_request_with_type(self):
52
# get_request() takes an optional request type.
53
request_id = hold_message(self._mlist, self._msg)
54
requests_db = IListRequests(self._mlist)
55
# Submit a request with a non-matching type. This should return None
56
# as if there were no matches.
57
response = requests_db.get_request(
58
request_id, RequestType.subscription)
59
self.assertEqual(response, None)
60
# Submit the same request with a matching type.
61
key, data = requests_db.get_request(
62
request_id, RequestType.held_message)
63
self.assertEqual(key, '<alpha>')
64
# It should also succeed with no optional request type given.
65
key, data = requests_db.get_request(request_id)
66
self.assertEqual(key, '<alpha>')