mirror of https://github.com/caronc/apprise
CLI --interpret-escapes works without --title specified (#471)
parent
245e57cca9
commit
9b5815ef6e
|
@ -558,6 +558,7 @@ class Apprise(object):
|
|||
logger.error('Failed to escape message body')
|
||||
raise TypeError
|
||||
|
||||
if title:
|
||||
try:
|
||||
# Added overhead required due to Python 3 Encoding Bug
|
||||
# identified here: https://bugs.python.org/issue21331
|
||||
|
@ -566,8 +567,9 @@ class Apprise(object):
|
|||
.decode('unicode-escape')
|
||||
|
||||
except UnicodeDecodeError: # pragma: no cover
|
||||
# This occurs using a very old verion of Python 2.7 such
|
||||
# as the one that ships with CentOS/RedHat 7.x (v2.7.5).
|
||||
# This occurs using a very old verion of Python 2.7
|
||||
# such as the one that ships with CentOS/RedHat 7.x
|
||||
# (v2.7.5).
|
||||
title = title.decode('string_escape')
|
||||
|
||||
except AttributeError:
|
||||
|
|
|
@ -576,6 +576,23 @@ def test_apprise_cli_nux_env(tmpdir):
|
|||
])
|
||||
assert result.exit_code == 1
|
||||
|
||||
# Test Escaping:
|
||||
result = runner.invoke(cli.main, [
|
||||
'-e',
|
||||
'-t', 'test\ntitle',
|
||||
'-b', 'test\nbody',
|
||||
'good://localhost',
|
||||
])
|
||||
assert result.exit_code == 0
|
||||
|
||||
# Test Escaping (without title)
|
||||
result = runner.invoke(cli.main, [
|
||||
'--interpret-escapes',
|
||||
'-b', 'test\nbody',
|
||||
'good://localhost',
|
||||
])
|
||||
assert result.exit_code == 0
|
||||
|
||||
|
||||
@mock.patch('platform.system')
|
||||
def test_apprise_cli_windows_env(mock_system):
|
||||
|
|
|
@ -191,13 +191,13 @@ def test_apprise_escaping_py3(mock_post):
|
|||
# the body only. Now we run similar tests but only make the title
|
||||
# bad and always mark the body good
|
||||
assert a.notify(
|
||||
title=None, body="valid", interpret_escapes=True) is False
|
||||
title=None, body="valid", interpret_escapes=True) is True
|
||||
assert a.notify(
|
||||
title=4, body="valid", interpret_escapes=True) is False
|
||||
assert a.notify(
|
||||
title=object(), body="valid", interpret_escapes=True) is False
|
||||
assert a.notify(
|
||||
title=False, body="valid", interpret_escapes=True) is False
|
||||
title=False, body="valid", interpret_escapes=True) is True
|
||||
assert a.notify(
|
||||
title=b'byte title', body="valid", interpret_escapes=True) is False
|
||||
|
||||
|
@ -320,10 +320,10 @@ def test_apprise_escaping_py2(mock_post):
|
|||
# the body only. Now we run similar tests but only make the title
|
||||
# bad and always mark the body good
|
||||
assert a.notify(
|
||||
title=None, body="valid", interpret_escapes=True) is False
|
||||
title=None, body="valid", interpret_escapes=True) is True
|
||||
assert a.notify(
|
||||
title=4, body="valid", interpret_escapes=True) is False
|
||||
assert a.notify(
|
||||
title=object(), body="valid", interpret_escapes=True) is False
|
||||
assert a.notify(
|
||||
title=False, body="valid", interpret_escapes=True) is False
|
||||
title=False, body="valid", interpret_escapes=True) is True
|
||||
|
|
Loading…
Reference in New Issue