~rashi007/mailman/docsfix

« back to all changes in this revision

Viewing changes to src/mailman/rest/tests/test_configuration.py

  • Committer: Barry Warsaw
  • Date: 2014-11-15 17:01:30 UTC
  • mfrom: (7251.4.19 falcon)
  • Revision ID: barry@list.org-20141115170130-0log69qu4j6ctkfj
s/restish/falcon/

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2014 by the Free Software Foundation, Inc.
 
2
#
 
3
# This file is part of GNU Mailman.
 
4
#
 
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)
 
8
# any later version.
 
9
#
 
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
 
13
# more details.
 
14
#
 
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/>.
 
17
 
 
18
"""Test list configuration via the REST API."""
 
19
 
 
20
from __future__ import absolute_import, print_function, unicode_literals
 
21
 
 
22
__metaclass__ = type
 
23
__all__ = [
 
24
    'TestConfiguration',
 
25
    ]
 
26
 
 
27
 
 
28
import unittest
 
29
 
 
30
from mailman.app.lifecycle import create_list
 
31
from mailman.database.transaction import transaction
 
32
from mailman.interfaces.mailinglist import IAcceptableAliasSet
 
33
from mailman.testing.helpers import call_api
 
34
from mailman.testing.layers import RESTLayer
 
35
 
 
36
 
 
37
 
 
38
class TestConfiguration(unittest.TestCase):
 
39
    """Test list configuration via the REST API."""
 
40
 
 
41
    layer = RESTLayer
 
42
 
 
43
    def setUp(self):
 
44
        with transaction():
 
45
            self._mlist = create_list('test@example.com')
 
46
 
 
47
    def test_put_configuration(self):
 
48
        aliases = [
 
49
            'ant@example.com',
 
50
            'bee@example.com',
 
51
            'cat@example.com',
 
52
            ]
 
53
        # When using PUT, all writable attributes must be included.
 
54
        resource, response = call_api(
 
55
            'http://localhost:9001/3.0/lists/test@example.com/config',
 
56
            dict(
 
57
                acceptable_aliases=aliases,
 
58
                admin_immed_notify=False,
 
59
                admin_notify_mchanges=True,
 
60
                administrivia=False,
 
61
                advertised=False,
 
62
                anonymous_list=True,
 
63
                archive_policy='never',
 
64
                autorespond_owner='respond_and_discard',
 
65
                autorespond_postings='respond_and_continue',
 
66
                autorespond_requests='respond_and_discard',
 
67
                autoresponse_grace_period='45d',
 
68
                autoresponse_owner_text='the owner',
 
69
                autoresponse_postings_text='the mailing list',
 
70
                autoresponse_request_text='the robot',
 
71
                display_name='Fnords',
 
72
                description='This is my mailing list',
 
73
                include_rfc2369_headers=False,
 
74
                allow_list_posts=False,
 
75
                digest_size_threshold=10.5,
 
76
                posting_pipeline='virgin',
 
77
                filter_content=True,
 
78
                first_strip_reply_to=True,
 
79
                convert_html_to_plaintext=True,
 
80
                collapse_alternatives=False,
 
81
                reply_goes_to_list='point_to_list',
 
82
                reply_to_address='bee@example.com',
 
83
                send_welcome_message=False,
 
84
                subject_prefix='[ant]',
 
85
                welcome_message_uri='mailman:///welcome.txt',
 
86
                default_member_action='hold',
 
87
                default_nonmember_action='discard',
 
88
                ),
 
89
            'PUT')
 
90
        self.assertEqual(response.status, 204)
 
91
        self.assertEqual(self._mlist.display_name, 'Fnords')
 
92
        # All three acceptable aliases were set.
 
93
        self.assertEqual(set(IAcceptableAliasSet(self._mlist).aliases),
 
94
                         set(aliases))