1
# Copyright (C) 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
"""Additional tests for the `lists` command line subcommand."""
27
from io import StringIO
28
from mailman.app.lifecycle import create_list
29
from mailman.commands.cli_lists import Lists
30
from mailman.interfaces.domain import IDomainManager
31
from mailman.testing.layers import ConfigLayer
32
from unittest.mock import patch
33
from zope.component import getUtility
44
class TestLists(unittest.TestCase):
47
def test_lists_with_domain_option(self):
48
# LP: #1166911 - non-matching lists were returned.
49
getUtility(IDomainManager).add(
50
'example.net', 'An example domain.',
51
'http://lists.example.net', 'postmaster@example.net')
52
create_list('test1@example.com')
53
create_list('test2@example.com')
54
# Only this one should show up.
55
create_list('test3@example.net')
56
create_list('test4@example.com')
59
args.domain.append('example.net')
61
with patch('sys.stdout', output):
63
lines = output.getvalue().splitlines()
64
# The first line is the heading, so skip that.
66
self.assertEqual(len(lines), 1, lines)
67
self.assertEqual(lines[0], 'test3@example.net')