~barry/mailman/events-and-web

« back to all changes in this revision

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

  • Committer: klm
  • Date: 1998-01-07 21:21:35 UTC
  • Revision ID: vcs-imports@canonical.com-19980107212135-sv0y521ps0xye37r
Initial revision

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2011-2012 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
 
"""REST address tests."""
19
 
 
20
 
from __future__ import absolute_import, print_function, unicode_literals
21
 
 
22
 
__metaclass__ = type
23
 
__all__ = [
24
 
    'TestAddresses',
25
 
    ]
26
 
 
27
 
 
28
 
import unittest
29
 
 
30
 
from urllib2 import HTTPError
31
 
 
32
 
from mailman.app.lifecycle import create_list
33
 
from mailman.database.transaction import transaction
34
 
from mailman.testing.helpers import call_api
35
 
from mailman.testing.layers import RESTLayer
36
 
 
37
 
 
38
 
 
39
 
class TestAddresses(unittest.TestCase):
40
 
    layer = RESTLayer
41
 
 
42
 
    def setUp(self):
43
 
        with transaction():
44
 
            self._mlist = create_list('test@example.com')
45
 
 
46
 
    def test_membership_of_missing_address(self):
47
 
        # Try to get the memberships of a missing address.
48
 
        try:
49
 
            # For Python 2.6.
50
 
            call_api('http://localhost:9001/3.0/addresses/'
51
 
                     'nobody@example.com/memberships')
52
 
        except HTTPError as exc:
53
 
            self.assertEqual(exc.code, 404)
54
 
        else:
55
 
            raise AssertionError('Expected HTTPError')