mirror of
https://github.com/caronc/apprise.git
synced 2025-08-10 00:38:02 +02:00
Refactor Test Code for Efficiency and Quality (#1100)
This commit is contained in:
@ -50,7 +50,7 @@ def test_parse_qsd():
|
||||
"utils: parse_qsd() testing """
|
||||
|
||||
result = utils.parse_qsd('a=1&b=&c&d=abcd')
|
||||
assert isinstance(result, dict) is True
|
||||
assert isinstance(result, dict)
|
||||
assert len(result) == 4
|
||||
assert 'qsd' in result
|
||||
assert 'qsd+' in result
|
||||
@ -2607,39 +2607,39 @@ def test_apply_templating():
|
||||
|
||||
result = utils.apply_template(
|
||||
template, **{'fname': 'Chris', 'whence': 'this morning'})
|
||||
assert isinstance(result, str) is True
|
||||
assert isinstance(result, str)
|
||||
assert result == "Hello Chris, How are you this morning?"
|
||||
|
||||
# In this example 'whence' isn't provided, so it isn't swapped
|
||||
result = utils.apply_template(
|
||||
template, **{'fname': 'Chris'})
|
||||
assert isinstance(result, str) is True
|
||||
assert isinstance(result, str)
|
||||
assert result == "Hello Chris, How are you {{whence}}?"
|
||||
|
||||
# white space won't cause any ill affects:
|
||||
template = "Hello {{ fname }}, How are you {{ whence}}?"
|
||||
result = utils.apply_template(
|
||||
template, **{'fname': 'Chris', 'whence': 'this morning'})
|
||||
assert isinstance(result, str) is True
|
||||
assert isinstance(result, str)
|
||||
assert result == "Hello Chris, How are you this morning?"
|
||||
|
||||
# No arguments won't cause any problems
|
||||
template = "Hello {{fname}}, How are you {{whence}}?"
|
||||
result = utils.apply_template(template)
|
||||
assert isinstance(result, str) is True
|
||||
assert isinstance(result, str)
|
||||
assert result == template
|
||||
|
||||
# Wrong elements are simply ignored
|
||||
result = utils.apply_template(
|
||||
template,
|
||||
**{'fname': 'l2g', 'whence': 'this evening', 'ignore': 'me'})
|
||||
assert isinstance(result, str) is True
|
||||
assert isinstance(result, str)
|
||||
assert result == "Hello l2g, How are you this evening?"
|
||||
|
||||
# Empty template makes things easy
|
||||
result = utils.apply_template(
|
||||
"", **{'fname': 'l2g', 'whence': 'this evening'})
|
||||
assert isinstance(result, str) is True
|
||||
assert isinstance(result, str)
|
||||
assert result == ""
|
||||
|
||||
# Regular expressions are safely escapped and act as normal
|
||||
|
Reference in New Issue
Block a user