Mark Sapiro pushed to branch master at GNU Mailman / Mailman Core
Commits:
b82c5ceb by Mark Sapiro at 2018-03-14T22:41:40Z
Accept no -f/--filename option in mailman inject command.
- - - - -
032f9326 by Mark Sapiro at 2018-03-15T16:34:54Z
Merge branch 'inject' into 'master'
Accept no -f/--filename option in mailman inject command.
Closes #459
See merge request mailman/mailman!365
- - - - -
3 changed files:
- src/mailman/commands/cli_inject.py
- src/mailman/commands/tests/test_cli_inject.py
- src/mailman/docs/NEWS.rst
Changes:
=====================================
src/mailman/commands/cli_inject.py
=====================================
--- a/src/mailman/commands/cli_inject.py
+++ b/src/mailman/commands/cli_inject.py
@@ -56,7 +56,7 @@ def show_queues(ctx, param, value):
help=_('Show a list of all available queue names and exit.'))
@click.option(
'--filename', '-f', 'message_file',
- type=click.File(encoding='utf-8'),
+ default='-', type=click.File(encoding='utf-8'),
help=_("""\
Name of file containing the message to inject. If not given, or
'-' (without the quotes) standard input is used."""))
=====================================
src/mailman/commands/tests/test_cli_inject.py
=====================================
--- a/src/mailman/commands/tests/test_cli_inject.py
+++ b/src/mailman/commands/tests/test_cli_inject.py
@@ -20,11 +20,20 @@
import unittest
from click.testing import CliRunner
-from io import StringIO
+from io import BytesIO, StringIO
from mailman.app.lifecycle import create_list
from mailman.commands.cli_inject import inject
+from mailman.testing.helpers import get_queue_messages
from mailman.testing.layers import ConfigLayer
+test_msg = b"""\
+To: [email protected]
+From: [email protected]
+Message-ID: <[email protected]>
+
+body
+"""
+
class InterruptRaisingReader(StringIO):
def read(self, count=None):
@@ -64,3 +73,13 @@ class TestInject(unittest.TestCase):
result.output,
'Usage: inject [OPTIONS] LISTSPEC\n\n'
'Error: No such queue: bogus\n')
+
+ def test_inject_no_filename_option(self):
+ result = self._command.invoke(
+ inject, (('ant.example.com',)),
+ input=BytesIO(test_msg))
+ self.assertEqual(result.exit_code, 0)
+ self.assertEqual(result.output, '')
+ msg = get_queue_messages('in', expected_count=1)[0].msg
+ # We can't compare the entire message because of inserted headers.
+ self.assertEqual(msg.as_bytes()[:75], test_msg[:75])
=====================================
src/mailman/docs/NEWS.rst
=====================================
--- a/src/mailman/docs/NEWS.rst
+++ b/src/mailman/docs/NEWS.rst
@@ -61,6 +61,8 @@ Bugs
* Message decoration has been removed from the posting pipeline and added to
bulk delivery to avoid duplicate decoration of personalized and VERPed
messages. (Closes #450)
+* The ``mailman inject`` command now reads standard input as documented if
+ there is no ``-f`` or ``--filename`` option. (Closes #459)
Command line
------------
View it on GitLab:
https://gitlab.com/mailman/mailman/compare/811b8caf7fc5db8d46d5892f5f33df4fc3e5aba7...032f9326aad0f80c78cb1ca3235840233886ae50
---
View it on GitLab:
https://gitlab.com/mailman/mailman/compare/811b8caf7fc5db8d46d5892f5f33df4fc3e5aba7...032f9326aad0f80c78cb1ca3235840233886ae50
You're receiving this email because of your account on gitlab.com.
_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe:
https://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org