1
# Copyright (C) 2014-2015 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 filter handler."""
27
from mailman.app.lifecycle import create_list
28
from mailman.config import config
29
from mailman.core.errors import DiscardMessage
30
from mailman.interfaces.mime import FilterAction
31
from mailman.testing.helpers import specialized_message_from_string as mfs
32
from mailman.testing.layers import ConfigLayer
36
class TestFilters(unittest.TestCase):
40
self._mlist = create_list('test@example.com')
42
def test_discard_when_outer_type_matches(self):
43
# When the outer MIME type of the message matches a filter type, the
44
# entire message is discarded.
45
self._mlist.filter_content = True
46
self._mlist.filter_types = ['image/jpeg']
47
self._mlist.filter_action = FilterAction.discard
49
From: aperson@example.com
50
Content-Type: image/jpeg
55
self.assertRaises(DiscardMessage,
56
config.handlers['mime-delete'].process,