summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBarry Warsaw2015-03-13 21:16:51 -0400
committerBarry Warsaw2015-03-13 21:16:51 -0400
commit6280c5ffcd2fdebf80f170f7c9a4e47adf0c6c4a (patch)
treeabff21eb9eebe7049aad72ee79a31c22482cfc96
parenta77f6650bc69ce968d3ac60d1b545d9bbdb9c62f (diff)
parent4f9987aa91ddde4aff66ed9cb85b3c34d7c71dae (diff)
downloadmailman-6280c5ffcd2fdebf80f170f7c9a4e47adf0c6c4a.tar.gz
mailman-6280c5ffcd2fdebf80f170f7c9a4e47adf0c6c4a.tar.zst
mailman-6280c5ffcd2fdebf80f170f7c9a4e47adf0c6c4a.zip
-rw-r--r--src/mailman/commands/cli_lists.py2
-rw-r--r--src/mailman/commands/docs/lists.rst8
-rw-r--r--src/mailman/commands/tests/test_lists.py67
-rw-r--r--src/mailman/docs/NEWS.rst2
4 files changed, 74 insertions, 5 deletions
diff --git a/src/mailman/commands/cli_lists.py b/src/mailman/commands/cli_lists.py
index 05aa7b7ca..3d5fcd634 100644
--- a/src/mailman/commands/cli_lists.py
+++ b/src/mailman/commands/cli_lists.py
@@ -86,7 +86,7 @@ class Lists:
mlist = list_manager.get(fqdn_name)
if args.advertised and not mlist.advertised:
continue
- domains = getattr(args, 'domains', None)
+ domains = getattr(args, 'domain', None)
if domains and mlist.mail_host not in domains:
continue
mailing_lists.append(mlist)
diff --git a/src/mailman/commands/docs/lists.rst b/src/mailman/commands/docs/lists.rst
index 036147a23..04e0d744d 100644
--- a/src/mailman/commands/docs/lists.rst
+++ b/src/mailman/commands/docs/lists.rst
@@ -100,14 +100,14 @@ You can narrow the search down to a specific domain with the --domain option.
A helpful message is displayed if no matching domains are given.
>>> FakeArgs.quiet = False
- >>> FakeArgs.domains = ['example.org']
+ >>> FakeArgs.domain = ['example.org']
>>> command.process(FakeArgs)
No matching mailing lists found
But if a matching domain is given, only mailing lists in that domain are
shown.
- >>> FakeArgs.domains = ['example.net']
+ >>> FakeArgs.domain = ['example.net']
>>> command.process(FakeArgs)
1 matching mailing lists found:
list-one@example.net
@@ -115,7 +115,7 @@ shown.
More than one --domain argument can be given; then all mailing lists in
matching domains are shown.
- >>> FakeArgs.domains = ['example.com', 'example.net']
+ >>> FakeArgs.domain = ['example.com', 'example.net']
>>> command.process(FakeArgs)
3 matching mailing lists found:
list-one@example.com
@@ -131,7 +131,7 @@ knowledge. Non-advertised lists are considered private. Display through the
command line can select on this attribute.
::
- >>> FakeArgs.domains = []
+ >>> FakeArgs.domain = []
>>> FakeArgs.advertised = True
>>> mlist_1.advertised = False
diff --git a/src/mailman/commands/tests/test_lists.py b/src/mailman/commands/tests/test_lists.py
new file mode 100644
index 000000000..dad15eec8
--- /dev/null
+++ b/src/mailman/commands/tests/test_lists.py
@@ -0,0 +1,67 @@
+# Copyright (C) 2015 by the Free Software Foundation, Inc.
+#
+# This file is part of GNU Mailman.
+#
+# GNU Mailman is free software: you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option)
+# any later version.
+#
+# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+# more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# GNU Mailman. If not, see <http://www.gnu.org/licenses/>.
+
+"""Additional tests for the `lists` command line subcommand."""
+
+__all__ = [
+ 'TestLists',
+ ]
+
+
+import unittest
+
+from io import StringIO
+from mailman.app.lifecycle import create_list
+from mailman.commands.cli_lists import Lists
+from mailman.interfaces.domain import IDomainManager
+from mailman.testing.layers import ConfigLayer
+from unittest.mock import patch
+from zope.component import getUtility
+
+
+class FakeArgs:
+ advertised = False
+ names = False
+ descriptions = False
+ quiet = False
+ domain = []
+
+
+class TestLists(unittest.TestCase):
+ layer = ConfigLayer
+
+ def test_lists_with_domain_option(self):
+ # LP: #1166911 - non-matching lists were returned.
+ getUtility(IDomainManager).add(
+ 'example.net', 'An example domain.',
+ 'http://lists.example.net', 'postmaster@example.net')
+ create_list('test1@example.com')
+ create_list('test2@example.com')
+ # Only this one should show up.
+ create_list('test3@example.net')
+ create_list('test4@example.com')
+ command = Lists()
+ args = FakeArgs()
+ args.domain.append('example.net')
+ output = StringIO()
+ with patch('sys.stdout', output):
+ command.process(args)
+ lines = output.getvalue().splitlines()
+ # The first line is the heading, so skip that.
+ lines.pop(0)
+ self.assertEqual(len(lines), 1, lines)
+ self.assertEqual(lines[0], 'test3@example.net')
diff --git a/src/mailman/docs/NEWS.rst b/src/mailman/docs/NEWS.rst
index 381cd5e03..0c1f6bc63 100644
--- a/src/mailman/docs/NEWS.rst
+++ b/src/mailman/docs/NEWS.rst
@@ -24,6 +24,8 @@ Bugs
* When trying to subscribe an address to a mailing list through the REST API
where a case-differing version of the address is already subscribed, return
a 409 error instead of a 500 error. Found by Ankush Sharma. (LP: #1425359)
+ * ``mailman lists --domain`` was not properly handling its arguments. Given
+ by Manish Gill. (LP: #1166911)
Configuration
-------------