Refactor Test Code for Efficiency and Quality (#1100)

This commit is contained in:
Han Wang 2024-04-21 00:00:31 +01:00 committed by GitHub
parent 1f77254d71
commit 08cb018e11
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
29 changed files with 188 additions and 218 deletions

View File

@ -189,7 +189,7 @@ def test_apprise_config(tmpdir):
assert isinstance(ac[0].url(), str) assert isinstance(ac[0].url(), str)
# pop an entry from our list # pop an entry from our list
assert isinstance(ac.pop(0), ConfigBase) is True assert isinstance(ac.pop(0), ConfigBase)
# Determine we have no more configuration entries loaded # Determine we have no more configuration entries loaded
assert len(ac) == 0 assert len(ac) == 0
@ -271,19 +271,13 @@ def test_apprise_multi_config_entries(tmpdir):
assert ac.add(configs=object()) is False assert ac.add(configs=object()) is False
# Try to pop an element out of range # Try to pop an element out of range
try: with pytest.raises(IndexError):
ac.server_pop(len(ac.servers())) ac.server_pop(len(ac.servers()))
# We should have thrown an exception here
assert False
except IndexError:
# We expect to be here
assert True
# Pop our elements # Pop our elements
while len(ac.servers()) > 0: while len(ac.servers()) > 0:
assert isinstance( assert isinstance(
ac.server_pop(len(ac.servers()) - 1), NotifyBase) is True ac.server_pop(len(ac.servers()) - 1), NotifyBase)
def test_apprise_add_config(): def test_apprise_add_config():
@ -623,7 +617,7 @@ def test_apprise_config_with_apprise_obj(tmpdir):
# reference index 0 of our list # reference index 0 of our list
ref = a[0] ref = a[0]
assert isinstance(ref, NotifyBase) is True assert isinstance(ref, NotifyBase)
# Our length is unchanged # Our length is unchanged
assert len(a) == 5 assert len(a) == 5
@ -632,7 +626,7 @@ def test_apprise_config_with_apprise_obj(tmpdir):
ref_popped = a.pop(0) ref_popped = a.pop(0)
# Verify our response # Verify our response
assert isinstance(ref_popped, NotifyBase) is True assert isinstance(ref_popped, NotifyBase)
# Our length drops by 1 # Our length drops by 1
assert len(a) == 4 assert len(a) == 4
@ -642,34 +636,21 @@ def test_apprise_config_with_apprise_obj(tmpdir):
assert ref == ref_popped assert ref == ref_popped
# pop an index out of range # pop an index out of range
try: with pytest.raises(IndexError):
a.pop(len(a)) a.pop(len(a))
# We'll thrown an IndexError and not make it this far
assert False
except IndexError:
# As expected
assert True
# Our length remains unchanged # Our length remains unchanged
assert len(a) == 4 assert len(a) == 4
# Reference content out of range # Reference content out of range
try: with pytest.raises(IndexError):
a[len(a)] a[len(a)]
# We'll thrown an IndexError and not make it this far
assert False
except IndexError:
# As expected
assert True
# reference index at the end of our list # reference index at the end of our list
ref = a[len(a) - 1] ref = a[len(a) - 1]
# Verify our response # Verify our response
assert isinstance(ref, NotifyBase) is True assert isinstance(ref, NotifyBase)
# Our length stays the same # Our length stays the same
assert len(a) == 4 assert len(a) == 4
@ -678,7 +659,7 @@ def test_apprise_config_with_apprise_obj(tmpdir):
ref_popped = a.pop(len(a) - 1) ref_popped = a.pop(len(a) - 1)
# Verify our response # Verify our response
assert isinstance(ref_popped, NotifyBase) is True assert isinstance(ref_popped, NotifyBase)
# Content popped is the same as one referenced by index # Content popped is the same as one referenced by index
# earlier # earlier
@ -703,13 +684,13 @@ def test_apprise_config_with_apprise_obj(tmpdir):
ref = a[len(a) - 1] ref = a[len(a) - 1]
# Verify our response # Verify our response
assert isinstance(ref, NotifyBase) is True assert isinstance(ref, NotifyBase)
# We can pop from the back of the list without a problem too # We can pop from the back of the list without a problem too
ref_popped = a.pop(len(a) - 1) ref_popped = a.pop(len(a) - 1)
# Verify our response # Verify our response
assert isinstance(ref_popped, NotifyBase) is True assert isinstance(ref_popped, NotifyBase)
# Content popped is the same as one referenced by index # Content popped is the same as one referenced by index
# earlier # earlier
@ -720,7 +701,7 @@ def test_apprise_config_with_apprise_obj(tmpdir):
# pop our list # pop our list
while len(a) > 0: while len(a) > 0:
assert isinstance(a.pop(len(a) - 1), NotifyBase) is True assert isinstance(a.pop(len(a) - 1), NotifyBase)
def test_recursive_config_inclusion(tmpdir): def test_recursive_config_inclusion(tmpdir):

View File

@ -50,7 +50,7 @@ def test_parse_qsd():
"utils: parse_qsd() testing """ "utils: parse_qsd() testing """
result = utils.parse_qsd('a=1&b=&c&d=abcd') 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 len(result) == 4
assert 'qsd' in result assert 'qsd' in result
assert 'qsd+' in result assert 'qsd+' in result
@ -2607,39 +2607,39 @@ def test_apply_templating():
result = utils.apply_template( result = utils.apply_template(
template, **{'fname': 'Chris', 'whence': 'this morning'}) 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?" assert result == "Hello Chris, How are you this morning?"
# In this example 'whence' isn't provided, so it isn't swapped # In this example 'whence' isn't provided, so it isn't swapped
result = utils.apply_template( result = utils.apply_template(
template, **{'fname': 'Chris'}) template, **{'fname': 'Chris'})
assert isinstance(result, str) is True assert isinstance(result, str)
assert result == "Hello Chris, How are you {{whence}}?" assert result == "Hello Chris, How are you {{whence}}?"
# white space won't cause any ill affects: # white space won't cause any ill affects:
template = "Hello {{ fname }}, How are you {{ whence}}?" template = "Hello {{ fname }}, How are you {{ whence}}?"
result = utils.apply_template( result = utils.apply_template(
template, **{'fname': 'Chris', 'whence': 'this morning'}) 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?" assert result == "Hello Chris, How are you this morning?"
# No arguments won't cause any problems # No arguments won't cause any problems
template = "Hello {{fname}}, How are you {{whence}}?" template = "Hello {{fname}}, How are you {{whence}}?"
result = utils.apply_template(template) result = utils.apply_template(template)
assert isinstance(result, str) is True assert isinstance(result, str)
assert result == template assert result == template
# Wrong elements are simply ignored # Wrong elements are simply ignored
result = utils.apply_template( result = utils.apply_template(
template, template,
**{'fname': 'l2g', 'whence': 'this evening', 'ignore': 'me'}) **{'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?" assert result == "Hello l2g, How are you this evening?"
# Empty template makes things easy # Empty template makes things easy
result = utils.apply_template( result = utils.apply_template(
"", **{'fname': 'l2g', 'whence': 'this evening'}) "", **{'fname': 'l2g', 'whence': 'this evening'})
assert isinstance(result, str) is True assert isinstance(result, str)
assert result == "" assert result == ""
# Regular expressions are safely escapped and act as normal # Regular expressions are safely escapped and act as normal

View File

@ -980,9 +980,9 @@ urls:
assert asset.theme == AppriseAsset().theme assert asset.theme == AppriseAsset().theme
# Empty string assignment # Empty string assignment
assert isinstance(asset.image_url_mask, str) is True assert isinstance(asset.image_url_mask, str)
assert asset.image_url_mask == "" assert asset.image_url_mask == ""
assert isinstance(asset.image_url_logo, str) is True assert isinstance(asset.image_url_logo, str)
assert asset.image_url_logo == "" assert asset.image_url_logo == ""
# For on-lookers looking through this file; here is a perfectly formatted # For on-lookers looking through this file; here is a perfectly formatted

View File

@ -48,8 +48,8 @@ def test_config_memory():
assert len(cm) == 1 assert len(cm) == 1
# Test general functions # Test general functions
assert isinstance(cm.url(), str) is True assert isinstance(cm.url(), str)
assert isinstance(cm.read(), str) is True assert isinstance(cm.read(), str)
# Test situation where an auto-detect is required: # Test situation where an auto-detect is required:
cm = ConfigMemory(content="json://localhost") cm = ConfigMemory(content="json://localhost")
@ -58,8 +58,8 @@ def test_config_memory():
assert len(cm) == 1 assert len(cm) == 1
# Test general functions # Test general functions
assert isinstance(cm.url(), str) is True assert isinstance(cm.url(), str)
assert isinstance(cm.read(), str) is True assert isinstance(cm.read(), str)
# Test situation where we can not detect the data # Test situation where we can not detect the data
assert len(ConfigMemory(content="garbage")) == 0 assert len(ConfigMemory(content="garbage")) == 0

View File

@ -381,7 +381,7 @@ def test_apprise_secure_logging(mock_post):
assert a.add("json://user:pass1$-3!@localhost") is True assert a.add("json://user:pass1$-3!@localhost") is True
# Our servers should carry this flag # Our servers should carry this flag
a[0].asset.secure_logging is True assert a[0].asset.secure_logging is True
logs = re.split(r'\r*\n', stream.getvalue().rstrip()) logs = re.split(r'\r*\n', stream.getvalue().rstrip())
assert len(logs) == 1 assert len(logs) == 1

View File

@ -67,7 +67,7 @@ def test_notification_manager_general():
N_MGR.unload_modules() N_MGR.unload_modules()
assert bool(N_MGR) is False assert bool(N_MGR) is False
assert len([x for x in iter(N_MGR)]) > 0 assert len([x for x in iter(N_MGR)]) > 0
assert bool(N_MGR) is True assert bool(N_MGR)
N_MGR.unload_modules() N_MGR.unload_modules()
assert isinstance(N_MGR.plugins(), types.GeneratorType) assert isinstance(N_MGR.plugins(), types.GeneratorType)

View File

@ -64,15 +64,11 @@ def test_notify_base():
assert isinstance(nb.url(), str) assert isinstance(nb.url(), str)
assert str(nb) == nb.url() assert str(nb) == nb.url()
try: with pytest.raises(NotImplementedError):
nb.send('test message')
assert False
except NotImplementedError:
# Each sub-module is that inherits this as a parent is required to # Each sub-module is that inherits this as a parent is required to
# over-ride this function. So direct calls to this throws a not # over-ride this function. So direct calls to this throws a not
# implemented error intentionally # implemented error intentionally
assert True nb.send('test message')
# Throttle overrides.. # Throttle overrides..
nb = NotifyBase() nb = NotifyBase()
@ -208,13 +204,13 @@ def test_notify_base():
result = NotifyBase.parse_list( result = NotifyBase.parse_list(
',path,?name=Dr%20Disrespect', unquote=False) ',path,?name=Dr%20Disrespect', unquote=False)
assert isinstance(result, list) is True assert isinstance(result, list)
assert len(result) == 2 assert len(result) == 2
assert 'path' in result assert 'path' in result
assert '?name=Dr%20Disrespect' in result assert '?name=Dr%20Disrespect' in result
result = NotifyBase.parse_list(',path,?name=Dr%20Disrespect', unquote=True) result = NotifyBase.parse_list(',path,?name=Dr%20Disrespect', unquote=True)
assert isinstance(result, list) is True assert isinstance(result, list)
assert len(result) == 2 assert len(result) == 2
assert 'path' in result assert 'path' in result
assert '?name=Dr Disrespect' in result assert '?name=Dr Disrespect' in result
@ -225,7 +221,7 @@ def test_notify_base():
# eliminates duplicates in addition to unquoting content by default # eliminates duplicates in addition to unquoting content by default
result = NotifyBase.parse_list( result = NotifyBase.parse_list(
',%2F,%2F%2F, , , ,%2F%2F%2F, %2F', unquote=True) ',%2F,%2F%2F, , , ,%2F%2F%2F, %2F', unquote=True)
assert isinstance(result, list) is True assert isinstance(result, list)
assert len(result) == 3 assert len(result) == 3
assert '/' in result assert '/' in result
assert '//' in result assert '//' in result
@ -238,7 +234,7 @@ def test_notify_base():
result = NotifyBase.parse_phone_no( result = NotifyBase.parse_phone_no(
'+1-800-123-1234,(800) 123-4567', unquote=False) '+1-800-123-1234,(800) 123-4567', unquote=False)
assert isinstance(result, list) is True assert isinstance(result, list)
assert len(result) == 2 assert len(result) == 2
assert '+1-800-123-1234' in result assert '+1-800-123-1234' in result
assert '(800) 123-4567' in result assert '(800) 123-4567' in result
@ -246,7 +242,7 @@ def test_notify_base():
# %2B == + # %2B == +
result = NotifyBase.parse_phone_no( result = NotifyBase.parse_phone_no(
'%2B1-800-123-1234,%2B1%20800%20123%204567', unquote=True) '%2B1-800-123-1234,%2B1%20800%20123%204567', unquote=True)
assert isinstance(result, list) is True assert isinstance(result, list)
assert len(result) == 2 assert len(result) == 2
assert '+1-800-123-1234' in result assert '+1-800-123-1234' in result
assert '+1 800 123 4567' in result assert '+1 800 123 4567' in result

View File

@ -187,7 +187,7 @@ def test_plugin_custom_json_edge_cases(mock_get, mock_post):
assert results['query'] == 'command' assert results['query'] == 'command'
assert results['schema'] == 'json' assert results['schema'] == 'json'
assert results['url'] == 'json://localhost:8080/command' assert results['url'] == 'json://localhost:8080/command'
assert isinstance(results['qsd:'], dict) is True assert isinstance(results['qsd:'], dict)
assert results['qsd:']['message'] == 'msg' assert results['qsd:']['message'] == 'msg'
# empty special mapping # empty special mapping
assert results['qsd:']['type'] == '' assert results['qsd:']['type'] == ''
@ -321,7 +321,7 @@ def test_plugin_custom_form_for_synology(mock_post):
assert results['query'] == 'entry.cgi' assert results['query'] == 'entry.cgi'
assert results['schema'] == 'jsons' assert results['schema'] == 'jsons'
assert results['url'] == 'jsons://localhost:8081/webapi/entry.cgi' assert results['url'] == 'jsons://localhost:8081/webapi/entry.cgi'
assert isinstance(results['qsd:'], dict) is True assert isinstance(results['qsd:'], dict)
# Header Entries # Header Entries
assert results['qsd-']['api'] == 'SYNO.Chat.External' assert results['qsd-']['api'] == 'SYNO.Chat.External'
assert results['qsd-']['method'] == 'incoming' assert results['qsd-']['method'] == 'incoming'

View File

@ -260,7 +260,7 @@ def test_plugin_custom_xml_edge_cases(mock_get, mock_post):
assert results['query'] == 'command' assert results['query'] == 'command'
assert results['schema'] == 'xml' assert results['schema'] == 'xml'
assert results['url'] == 'xml://localhost:8080/command' assert results['url'] == 'xml://localhost:8080/command'
assert isinstance(results['qsd:'], dict) is True assert isinstance(results['qsd:'], dict)
assert results['qsd:']['Message'] == 'Body' assert results['qsd:']['Message'] == 'Body'
assert results['qsd:']['Key'] == 'value' assert results['qsd:']['Key'] == 'value'
assert results['qsd:'][','] == 'invalid' assert results['qsd:'][','] == 'invalid'
@ -316,7 +316,7 @@ def test_plugin_custom_xml_edge_cases(mock_get, mock_post):
assert results['query'] == 'command' assert results['query'] == 'command'
assert results['schema'] == 'xml' assert results['schema'] == 'xml'
assert results['url'] == 'xml://localhost:8081/command' assert results['url'] == 'xml://localhost:8081/command'
assert isinstance(results['qsd:'], dict) is True assert isinstance(results['qsd:'], dict)
assert results['qsd:']['New'] == 'Value' assert results['qsd:']['New'] == 'Value'
instance = NotifyXML(**results) instance = NotifyXML(**results)
@ -364,7 +364,7 @@ def test_plugin_custom_xml_edge_cases(mock_get, mock_post):
assert results['query'] is None assert results['query'] is None
assert results['schema'] == 'xmls' assert results['schema'] == 'xmls'
assert results['url'] == 'xmls://localhost' assert results['url'] == 'xmls://localhost'
assert isinstance(results['qsd:'], dict) is True assert isinstance(results['qsd:'], dict)
assert results['qsd:']['Version'] == '' assert results['qsd:']['Version'] == ''
assert results['qsd:']['Message'] == 'Body' assert results['qsd:']['Message'] == 'Body'
assert results['qsd:']['Subject'] == 'Title' assert results['qsd:']['Subject'] == 'Title'

View File

@ -346,14 +346,14 @@ def test_plugin_email(mock_smtp, mock_smtpssl):
if isinstance(obj, NotifyBase): if isinstance(obj, NotifyBase):
# We loaded okay; now lets make sure we can reverse this url # We loaded okay; now lets make sure we can reverse this url
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
# Verify we can acquire a target count as an integer # Verify we can acquire a target count as an integer
assert isinstance(len(obj), int) assert isinstance(len(obj), int)
# Test url() with privacy=True # Test url() with privacy=True
assert isinstance( assert isinstance(
obj.url(privacy=True), str) is True obj.url(privacy=True), str)
# Some Simple Invalid Instance Testing # Some Simple Invalid Instance Testing
assert instance.parse_url(None) is None assert instance.parse_url(None) is None
@ -379,12 +379,10 @@ def test_plugin_email(mock_smtp, mock_smtpssl):
assert False assert False
# Verify there is no change from the old and the new # Verify there is no change from the old and the new
if len(obj) != len(obj_cmp): assert len(obj) == len(obj_cmp), (
print('%d targets found in %s' % ( '%d targets found in %s, But %d targets found in %s'
len(obj), obj.url(privacy=True))) % (len(obj), obj.url(privacy=True), len(obj_cmp),
print('But %d targets found in %s' % ( obj_cmp.url(privacy=True)))
len(obj_cmp), obj_cmp.url(privacy=True)))
raise AssertionError("Target miscount %d != %d")
if self: if self:
# Iterate over our expected entries inside of our object # Iterate over our expected entries inside of our object
@ -711,7 +709,7 @@ def test_plugin_email_url_escaping():
obj = NotifyEmail.parse_url( obj = NotifyEmail.parse_url(
'mailto://user:{}@gmail.com?format=text'.format(passwd)) 'mailto://user:{}@gmail.com?format=text'.format(passwd))
assert isinstance(obj, dict) is True assert isinstance(obj, dict)
assert 'password' in obj assert 'password' in obj
# Escaping doesn't happen at this stage because we want to leave this to # Escaping doesn't happen at this stage because we want to leave this to
@ -721,7 +719,7 @@ def test_plugin_email_url_escaping():
obj = Apprise.instantiate( obj = Apprise.instantiate(
'mailto://user:{}@gmail.com?format=text'.format(passwd), 'mailto://user:{}@gmail.com?format=text'.format(passwd),
suppress_exceptions=False) suppress_exceptions=False)
assert isinstance(obj, NotifyEmail) is True assert isinstance(obj, NotifyEmail)
# The password is escaped only 'once' # The password is escaped only 'once'
assert obj.password == ' %20' assert obj.password == ' %20'
@ -739,7 +737,7 @@ def test_plugin_email_url_variations():
user='apprise%40example21.ca', user='apprise%40example21.ca',
passwd='abcd123'), passwd='abcd123'),
suppress_exceptions=False) suppress_exceptions=False)
assert isinstance(obj, NotifyEmail) is True assert isinstance(obj, NotifyEmail)
assert obj.password == 'abcd123' assert obj.password == 'abcd123'
assert obj.user == 'apprise@example21.ca' assert obj.user == 'apprise@example21.ca'
@ -762,7 +760,7 @@ def test_plugin_email_url_variations():
user='apprise%40example21.ca', user='apprise%40example21.ca',
passwd='abcd123'), passwd='abcd123'),
suppress_exceptions=False) suppress_exceptions=False)
assert isinstance(obj, NotifyEmail) is True assert isinstance(obj, NotifyEmail)
assert obj.password == 'abcd123' assert obj.password == 'abcd123'
assert obj.user == 'apprise@example21.ca' assert obj.user == 'apprise@example21.ca'
@ -784,7 +782,7 @@ def test_plugin_email_url_variations():
user='apprise%40example21.ca', user='apprise%40example21.ca',
passwd='abcd123'), passwd='abcd123'),
suppress_exceptions=False) suppress_exceptions=False)
assert isinstance(obj, NotifyEmail) is True assert isinstance(obj, NotifyEmail)
assert obj.password == 'abcd123' assert obj.password == 'abcd123'
assert obj.user == 'apprise@example21.ca' assert obj.user == 'apprise@example21.ca'
@ -814,7 +812,7 @@ def test_plugin_email_url_variations():
user='apprise%40example21.ca', user='apprise%40example21.ca',
passwd='abcd123'), passwd='abcd123'),
suppress_exceptions=False) suppress_exceptions=False)
assert isinstance(obj, NotifyEmail) is True assert isinstance(obj, NotifyEmail)
assert obj.password == 'abcd123' assert obj.password == 'abcd123'
assert obj.user == 'apprise@example21.ca' assert obj.user == 'apprise@example21.ca'
@ -848,7 +846,7 @@ def test_plugin_email_url_variations():
that='to@example.jp', that='to@example.jp',
smtp_host='smtp.example.edu'), smtp_host='smtp.example.edu'),
suppress_exceptions=False) suppress_exceptions=False)
assert isinstance(obj, NotifyEmail) is True assert isinstance(obj, NotifyEmail)
assert obj.password == 'abcd123' assert obj.password == 'abcd123'
assert obj.user == 'apprise@example21.ca' assert obj.user == 'apprise@example21.ca'
@ -870,7 +868,7 @@ def test_plugin_email_url_variations():
obj = Apprise.instantiate( obj = Apprise.instantiate(
'mailto://user:pass@domain.com{}'.format(toaddr)) 'mailto://user:pass@domain.com{}'.format(toaddr))
assert isinstance(obj, NotifyEmail) is True assert isinstance(obj, NotifyEmail)
assert obj.password == 'pass' assert obj.password == 'pass'
assert obj.user == 'user' assert obj.user == 'user'
assert obj.host == 'domain.com' assert obj.host == 'domain.com'
@ -893,7 +891,7 @@ def test_plugin_email_dict_variations():
'user': 'apprise@example.com', 'user': 'apprise@example.com',
'password': 'abd123', 'password': 'abd123',
'host': 'example.com'}, suppress_exceptions=False) 'host': 'example.com'}, suppress_exceptions=False)
assert isinstance(obj, NotifyEmail) is True assert isinstance(obj, NotifyEmail)
@mock.patch('smtplib.SMTP_SSL') @mock.patch('smtplib.SMTP_SSL')
@ -923,7 +921,7 @@ def test_plugin_email_url_parsing(mock_smtp, mock_smtp_ssl):
assert 'user2@yahoo.com' in results['targets'] assert 'user2@yahoo.com' in results['targets']
obj = Apprise.instantiate(results, suppress_exceptions=False) obj = Apprise.instantiate(results, suppress_exceptions=False)
assert isinstance(obj, NotifyEmail) is True assert isinstance(obj, NotifyEmail)
assert mock_smtp.call_count == 0 assert mock_smtp.call_count == 0
assert mock_smtp_ssl.call_count == 0 assert mock_smtp_ssl.call_count == 0
@ -971,7 +969,7 @@ def test_plugin_email_url_parsing(mock_smtp, mock_smtp_ssl):
assert 'user2@yahoo.com' in results['targets'] assert 'user2@yahoo.com' in results['targets']
assert 'ssl' == results['secure_mode'] assert 'ssl' == results['secure_mode']
obj = Apprise.instantiate(results, suppress_exceptions=False) obj = Apprise.instantiate(results, suppress_exceptions=False)
assert isinstance(obj, NotifyEmail) is True assert isinstance(obj, NotifyEmail)
assert mock_smtp.call_count == 0 assert mock_smtp.call_count == 0
assert mock_smtp_ssl.call_count == 0 assert mock_smtp_ssl.call_count == 0
@ -1017,7 +1015,7 @@ def test_plugin_email_url_parsing(mock_smtp, mock_smtp_ssl):
results = NotifyEmail.parse_url( results = NotifyEmail.parse_url(
'mailtos://user:pass123@hotmail.com') 'mailtos://user:pass123@hotmail.com')
obj = Apprise.instantiate(results, suppress_exceptions=False) obj = Apprise.instantiate(results, suppress_exceptions=False)
assert isinstance(obj, NotifyEmail) is True assert isinstance(obj, NotifyEmail)
assert obj.smtp_host == 'smtp-mail.outlook.com' assert obj.smtp_host == 'smtp-mail.outlook.com'
# No entries in the reply_to # No entries in the reply_to
assert not obj.reply_to assert not obj.reply_to
@ -1043,7 +1041,7 @@ def test_plugin_email_url_parsing(mock_smtp, mock_smtp_ssl):
results = NotifyEmail.parse_url( results = NotifyEmail.parse_url(
'mailtos://user:pass123@outlook.com') 'mailtos://user:pass123@outlook.com')
obj = Apprise.instantiate(results, suppress_exceptions=False) obj = Apprise.instantiate(results, suppress_exceptions=False)
assert isinstance(obj, NotifyEmail) is True assert isinstance(obj, NotifyEmail)
assert obj.smtp_host == 'smtp.outlook.com' assert obj.smtp_host == 'smtp.outlook.com'
# No entries in the reply_to # No entries in the reply_to
assert not obj.reply_to assert not obj.reply_to
@ -1069,7 +1067,7 @@ def test_plugin_email_url_parsing(mock_smtp, mock_smtp_ssl):
results = NotifyEmail.parse_url( results = NotifyEmail.parse_url(
'mailtos://user:pass123@outlook.com.au') 'mailtos://user:pass123@outlook.com.au')
obj = Apprise.instantiate(results, suppress_exceptions=False) obj = Apprise.instantiate(results, suppress_exceptions=False)
assert isinstance(obj, NotifyEmail) is True assert isinstance(obj, NotifyEmail)
assert obj.smtp_host == 'smtp.outlook.com' assert obj.smtp_host == 'smtp.outlook.com'
# No entries in the reply_to # No entries in the reply_to
assert not obj.reply_to assert not obj.reply_to
@ -1097,7 +1095,7 @@ def test_plugin_email_url_parsing(mock_smtp, mock_smtp_ssl):
'mailtos://outlook.com?smtp=smtp.outlook.com' 'mailtos://outlook.com?smtp=smtp.outlook.com'
'&user=user@outlook.com&pass=app.pw') '&user=user@outlook.com&pass=app.pw')
obj1 = Apprise.instantiate(results, suppress_exceptions=False) obj1 = Apprise.instantiate(results, suppress_exceptions=False)
assert isinstance(obj1, NotifyEmail) is True assert isinstance(obj1, NotifyEmail)
assert obj1.smtp_host == 'smtp.outlook.com' assert obj1.smtp_host == 'smtp.outlook.com'
assert obj1.user == 'user@outlook.com' assert obj1.user == 'user@outlook.com'
assert obj1.password == 'app.pw' assert obj1.password == 'app.pw'
@ -1125,7 +1123,7 @@ def test_plugin_email_url_parsing(mock_smtp, mock_smtp_ssl):
results = NotifyEmail.parse_url( results = NotifyEmail.parse_url(
'mailtos://user:app.pw@outlook.com') 'mailtos://user:app.pw@outlook.com')
obj2 = Apprise.instantiate(results, suppress_exceptions=False) obj2 = Apprise.instantiate(results, suppress_exceptions=False)
assert isinstance(obj2, NotifyEmail) is True assert isinstance(obj2, NotifyEmail)
assert obj2.smtp_host == obj1.smtp_host assert obj2.smtp_host == obj1.smtp_host
assert obj2.user == obj1.user assert obj2.user == obj1.user
assert obj2.password == obj1.password assert obj2.password == obj1.password
@ -1153,7 +1151,7 @@ def test_plugin_email_url_parsing(mock_smtp, mock_smtp_ssl):
results = NotifyEmail.parse_url( results = NotifyEmail.parse_url(
'mailto://user:pass@comcast.net') 'mailto://user:pass@comcast.net')
obj = Apprise.instantiate(results, suppress_exceptions=False) obj = Apprise.instantiate(results, suppress_exceptions=False)
assert isinstance(obj, NotifyEmail) is True assert isinstance(obj, NotifyEmail)
assert obj.smtp_host == 'smtp.comcast.net' assert obj.smtp_host == 'smtp.comcast.net'
assert obj.user == 'user@comcast.net' assert obj.user == 'user@comcast.net'
assert obj.password == 'pass' assert obj.password == 'pass'
@ -1181,7 +1179,7 @@ def test_plugin_email_url_parsing(mock_smtp, mock_smtp_ssl):
results = NotifyEmail.parse_url( results = NotifyEmail.parse_url(
'mailtos://user:pass123@live.com') 'mailtos://user:pass123@live.com')
obj = Apprise.instantiate(results, suppress_exceptions=False) obj = Apprise.instantiate(results, suppress_exceptions=False)
assert isinstance(obj, NotifyEmail) is True assert isinstance(obj, NotifyEmail)
# No entries in the reply_to # No entries in the reply_to
assert not obj.reply_to assert not obj.reply_to
@ -1206,7 +1204,7 @@ def test_plugin_email_url_parsing(mock_smtp, mock_smtp_ssl):
results = NotifyEmail.parse_url( results = NotifyEmail.parse_url(
'mailtos://user:pass123@hotmail.com') 'mailtos://user:pass123@hotmail.com')
obj = Apprise.instantiate(results, suppress_exceptions=False) obj = Apprise.instantiate(results, suppress_exceptions=False)
assert isinstance(obj, NotifyEmail) is True assert isinstance(obj, NotifyEmail)
# No entries in the reply_to # No entries in the reply_to
assert not obj.reply_to assert not obj.reply_to
@ -1235,7 +1233,7 @@ def test_plugin_email_url_parsing(mock_smtp, mock_smtp_ssl):
"mailtos://abc:password@xyz.cn:465?" "mailtos://abc:password@xyz.cn:465?"
"smtp=smtp.exmail.qq.com&mode=ssl") "smtp=smtp.exmail.qq.com&mode=ssl")
obj = Apprise.instantiate(results, suppress_exceptions=False) obj = Apprise.instantiate(results, suppress_exceptions=False)
assert isinstance(obj, NotifyEmail) is True assert isinstance(obj, NotifyEmail)
# Verify our over-rides are in place # Verify our over-rides are in place
assert obj.smtp_host == 'smtp.exmail.qq.com' assert obj.smtp_host == 'smtp.exmail.qq.com'
@ -1279,7 +1277,7 @@ def test_plugin_email_url_parsing(mock_smtp, mock_smtp_ssl):
"mailtos://abc:password@xyz.cn?" "mailtos://abc:password@xyz.cn?"
"smtp=smtp.exmail.qq.com&mode=ssl&port=465") "smtp=smtp.exmail.qq.com&mode=ssl&port=465")
obj = Apprise.instantiate(results, suppress_exceptions=False) obj = Apprise.instantiate(results, suppress_exceptions=False)
assert isinstance(obj, NotifyEmail) is True assert isinstance(obj, NotifyEmail)
# Verify our over-rides are in place # Verify our over-rides are in place
assert obj.smtp_host == 'smtp.exmail.qq.com' assert obj.smtp_host == 'smtp.exmail.qq.com'
@ -1314,7 +1312,7 @@ def test_plugin_email_url_parsing(mock_smtp, mock_smtp_ssl):
results = NotifyEmail.parse_url( results = NotifyEmail.parse_url(
"mailtos://user:pass@example.com?reply=noreply@example.com") "mailtos://user:pass@example.com?reply=noreply@example.com")
obj = Apprise.instantiate(results, suppress_exceptions=False) obj = Apprise.instantiate(results, suppress_exceptions=False)
assert isinstance(obj, NotifyEmail) is True assert isinstance(obj, NotifyEmail)
# Verify our over-rides are in place # Verify our over-rides are in place
assert obj.smtp_host == 'example.com' assert obj.smtp_host == 'example.com'
assert obj.from_addr[0] == obj.app_id assert obj.from_addr[0] == obj.app_id
@ -1349,7 +1347,7 @@ def test_plugin_email_url_parsing(mock_smtp, mock_smtp_ssl):
results = NotifyEmail.parse_url( results = NotifyEmail.parse_url(
"mailtos://user:pass@example.com?reply=Chris<noreply@example.ca>") "mailtos://user:pass@example.com?reply=Chris<noreply@example.ca>")
obj = Apprise.instantiate(results, suppress_exceptions=False) obj = Apprise.instantiate(results, suppress_exceptions=False)
assert isinstance(obj, NotifyEmail) is True assert isinstance(obj, NotifyEmail)
# Verify our over-rides are in place # Verify our over-rides are in place
assert obj.smtp_host == 'example.com' assert obj.smtp_host == 'example.com'
assert obj.from_addr[0] == obj.app_id assert obj.from_addr[0] == obj.app_id
@ -1397,7 +1395,7 @@ def test_plugin_email_url_parsing(mock_smtp, mock_smtp_ssl):
assert 'hello@concordium-explorer.nl' in results['targets'] assert 'hello@concordium-explorer.nl' in results['targets']
obj = Apprise.instantiate(results, suppress_exceptions=False) obj = Apprise.instantiate(results, suppress_exceptions=False)
assert isinstance(obj, NotifyEmail) is True assert isinstance(obj, NotifyEmail)
assert mock_smtp.call_count == 0 assert mock_smtp.call_count == 0
assert mock_smtp_ssl.call_count == 0 assert mock_smtp_ssl.call_count == 0
@ -1447,7 +1445,7 @@ def test_plugin_email_url_parsing(mock_smtp, mock_smtp_ssl):
assert results['smtp_host'] == '' assert results['smtp_host'] == ''
obj = Apprise.instantiate(results, suppress_exceptions=False) obj = Apprise.instantiate(results, suppress_exceptions=False)
assert isinstance(obj, NotifyEmail) is True assert isinstance(obj, NotifyEmail)
# During instantiation, our variables get detected # During instantiation, our variables get detected
assert obj.smtp_host == 'smtp.fastmail.com' assert obj.smtp_host == 'smtp.fastmail.com'
assert obj.from_addr == ['Apprise', 'username@customdomain.com'] assert obj.from_addr == ['Apprise', 'username@customdomain.com']
@ -1498,7 +1496,7 @@ def test_plugin_email_url_parsing(mock_smtp, mock_smtp_ssl):
assert results['smtp_host'] == '' assert results['smtp_host'] == ''
obj = Apprise.instantiate(results, suppress_exceptions=False) obj = Apprise.instantiate(results, suppress_exceptions=False)
assert isinstance(obj, NotifyEmail) is True assert isinstance(obj, NotifyEmail)
# During instantiation, our variables get detected # During instantiation, our variables get detected
assert obj.smtp_host == 'smtp.fastmail.com' assert obj.smtp_host == 'smtp.fastmail.com'
assert obj.from_addr == ['Custom', 'username@customdomain.com'] assert obj.from_addr == ['Custom', 'username@customdomain.com']
@ -1555,7 +1553,7 @@ def test_plugin_email_url_parsing(mock_smtp, mock_smtp_ssl):
assert 'mail@mail-domain.com' in results['targets'] assert 'mail@mail-domain.com' in results['targets']
obj = Apprise.instantiate(results, suppress_exceptions=False) obj = Apprise.instantiate(results, suppress_exceptions=False)
assert isinstance(obj, NotifyEmail) is True assert isinstance(obj, NotifyEmail)
# Not that our from_address takes on 'admin@domain.subdomain.com' # Not that our from_address takes on 'admin@domain.subdomain.com'
assert obj.from_addr == ['Apprise', 'admin@domain.subdomain.com'] assert obj.from_addr == ['Apprise', 'admin@domain.subdomain.com']
@ -1612,7 +1610,7 @@ def test_plugin_email_plus_in_toemail(mock_smtp, mock_smtp_ssl):
assert 'Plus Support<test+notification@gmail.com>' in results['targets'] assert 'Plus Support<test+notification@gmail.com>' in results['targets']
obj = Apprise.instantiate(results, suppress_exceptions=False) obj = Apprise.instantiate(results, suppress_exceptions=False)
assert isinstance(obj, NotifyEmail) is True assert isinstance(obj, NotifyEmail)
assert len(obj.targets) == 1 assert len(obj.targets) == 1
assert ('Plus Support', 'test+notification@gmail.com') in obj.targets assert ('Plus Support', 'test+notification@gmail.com') in obj.targets
@ -1660,7 +1658,7 @@ def test_plugin_email_plus_in_toemail(mock_smtp, mock_smtp_ssl):
assert 'test+notification@gmail.com' in results['targets'] assert 'test+notification@gmail.com' in results['targets']
obj = Apprise.instantiate(results, suppress_exceptions=False) obj = Apprise.instantiate(results, suppress_exceptions=False)
assert isinstance(obj, NotifyEmail) is True assert isinstance(obj, NotifyEmail)
assert len(obj.targets) == 1 assert len(obj.targets) == 1
assert (False, 'test+notification@gmail.com') in obj.targets assert (False, 'test+notification@gmail.com') in obj.targets
@ -1704,7 +1702,7 @@ def test_plugin_email_plus_in_toemail(mock_smtp, mock_smtp_ssl):
assert 'test+notification@gmail.com' in results['targets'] assert 'test+notification@gmail.com' in results['targets']
obj = Apprise.instantiate(results, suppress_exceptions=False) obj = Apprise.instantiate(results, suppress_exceptions=False)
assert isinstance(obj, NotifyEmail) is True assert isinstance(obj, NotifyEmail)
assert len(obj.targets) == 1 assert len(obj.targets) == 1
assert (False, 'test+notification@gmail.com') in obj.targets assert (False, 'test+notification@gmail.com') in obj.targets
@ -1760,7 +1758,7 @@ def test_plugin_email_formatting_990(mock_smtp, mock_smtp_ssl):
assert 'me@mydomain.com' in results['targets'] assert 'me@mydomain.com' in results['targets']
obj = Apprise.instantiate(results, suppress_exceptions=False) obj = Apprise.instantiate(results, suppress_exceptions=False)
assert isinstance(obj, NotifyEmail) is True assert isinstance(obj, NotifyEmail)
assert len(obj.targets) == 1 assert len(obj.targets) == 1
assert (False, 'me@mydomain.com') in obj.targets assert (False, 'me@mydomain.com') in obj.targets

View File

@ -873,13 +873,13 @@ def test_plugin_fcm_color_manager():
# We will be `true` because we can acquire a color based on what was # We will be `true` because we can acquire a color based on what was
# passed in # passed in
assert bool(instance) is True assert bool(instance)
# Custom color # Custom color
instance = FCMColorManager('#A2B3A4') instance = FCMColorManager('#A2B3A4')
assert isinstance(instance.get(), str) assert isinstance(instance.get(), str)
assert instance.get() == '#a2b3a4' assert instance.get() == '#a2b3a4'
assert bool(instance) is True assert bool(instance)
# str() response does not include hashtag # str() response does not include hashtag
assert str(instance) == 'a2b3a4' assert str(instance) == 'a2b3a4'
@ -888,7 +888,7 @@ def test_plugin_fcm_color_manager():
assert isinstance(instance.get(), str) assert isinstance(instance.get(), str)
# Hashtag is always part of output # Hashtag is always part of output
assert instance.get() == '#a2b3a4' assert instance.get() == '#a2b3a4'
assert bool(instance) is True assert bool(instance)
# str() response does not include hashtag # str() response does not include hashtag
assert str(instance) == 'a2b3a4' assert str(instance) == 'a2b3a4'
@ -897,7 +897,7 @@ def test_plugin_fcm_color_manager():
assert isinstance(instance.get(), str) assert isinstance(instance.get(), str)
# Hashtag is always part of output # Hashtag is always part of output
assert instance.get() == '#aacc44' assert instance.get() == '#aacc44'
assert bool(instance) is True assert bool(instance)
# str() response does not include hashtag # str() response does not include hashtag
assert str(instance) == 'aacc44' assert str(instance) == 'aacc44'

View File

@ -153,20 +153,20 @@ def test_plugin_dbus_general_success(mocker, dbus_glib_environment):
# Create our instance (identify all supported types) # Create our instance (identify all supported types)
obj = apprise.Apprise.instantiate('dbus://', suppress_exceptions=False) obj = apprise.Apprise.instantiate('dbus://', suppress_exceptions=False)
assert isinstance(obj, NotifyDBus) is True assert isinstance(obj, NotifyDBus)
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
assert obj.url().startswith('dbus://_/') assert obj.url().startswith('dbus://_/')
obj = apprise.Apprise.instantiate('kde://', suppress_exceptions=False) obj = apprise.Apprise.instantiate('kde://', suppress_exceptions=False)
assert isinstance(obj, NotifyDBus) is True assert isinstance(obj, NotifyDBus)
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
assert obj.url().startswith('kde://_/') assert obj.url().startswith('kde://_/')
obj = apprise.Apprise.instantiate('qt://', suppress_exceptions=False) obj = apprise.Apprise.instantiate('qt://', suppress_exceptions=False)
assert isinstance(obj, NotifyDBus) is True assert isinstance(obj, NotifyDBus)
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
assert obj.url().startswith('qt://_/') assert obj.url().startswith('qt://_/')
obj = apprise.Apprise.instantiate('glib://', suppress_exceptions=False) obj = apprise.Apprise.instantiate('glib://', suppress_exceptions=False)
assert isinstance(obj, NotifyDBus) is True assert isinstance(obj, NotifyDBus)
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
assert obj.url().startswith('glib://_/') assert obj.url().startswith('glib://_/')
obj.duration = 0 obj.duration = 0
@ -189,8 +189,8 @@ def test_plugin_dbus_general_success(mocker, dbus_glib_environment):
# Test our arguments through the instantiate call # Test our arguments through the instantiate call
obj = apprise.Apprise.instantiate( obj = apprise.Apprise.instantiate(
'dbus://_/?image=True', suppress_exceptions=False) 'dbus://_/?image=True', suppress_exceptions=False)
assert isinstance(obj, NotifyDBus) is True assert isinstance(obj, NotifyDBus)
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
assert obj.url().startswith('dbus://_/') assert obj.url().startswith('dbus://_/')
assert re.search('image=yes', obj.url()) assert re.search('image=yes', obj.url())
@ -200,8 +200,8 @@ def test_plugin_dbus_general_success(mocker, dbus_glib_environment):
obj = apprise.Apprise.instantiate( obj = apprise.Apprise.instantiate(
'dbus://_/?image=False', suppress_exceptions=False) 'dbus://_/?image=False', suppress_exceptions=False)
assert isinstance(obj, NotifyDBus) is True assert isinstance(obj, NotifyDBus)
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
assert obj.url().startswith('dbus://_/') assert obj.url().startswith('dbus://_/')
assert re.search('image=no', obj.url()) assert re.search('image=no', obj.url())
@ -212,24 +212,24 @@ def test_plugin_dbus_general_success(mocker, dbus_glib_environment):
# Test priority (alias to urgency) handling # Test priority (alias to urgency) handling
obj = apprise.Apprise.instantiate( obj = apprise.Apprise.instantiate(
'dbus://_/?priority=invalid', suppress_exceptions=False) 'dbus://_/?priority=invalid', suppress_exceptions=False)
assert isinstance(obj, NotifyDBus) is True assert isinstance(obj, NotifyDBus)
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
assert obj.notify( assert obj.notify(
title='title', body='body', title='title', body='body',
notify_type=apprise.NotifyType.INFO) is True notify_type=apprise.NotifyType.INFO) is True
obj = apprise.Apprise.instantiate( obj = apprise.Apprise.instantiate(
'dbus://_/?priority=high', suppress_exceptions=False) 'dbus://_/?priority=high', suppress_exceptions=False)
assert isinstance(obj, NotifyDBus) is True assert isinstance(obj, NotifyDBus)
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
assert obj.notify( assert obj.notify(
title='title', body='body', title='title', body='body',
notify_type=apprise.NotifyType.INFO) is True notify_type=apprise.NotifyType.INFO) is True
obj = apprise.Apprise.instantiate( obj = apprise.Apprise.instantiate(
'dbus://_/?priority=2', suppress_exceptions=False) 'dbus://_/?priority=2', suppress_exceptions=False)
assert isinstance(obj, NotifyDBus) is True assert isinstance(obj, NotifyDBus)
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
assert obj.notify( assert obj.notify(
title='title', body='body', title='title', body='body',
notify_type=apprise.NotifyType.INFO) is True notify_type=apprise.NotifyType.INFO) is True
@ -237,32 +237,32 @@ def test_plugin_dbus_general_success(mocker, dbus_glib_environment):
# Test urgency handling # Test urgency handling
obj = apprise.Apprise.instantiate( obj = apprise.Apprise.instantiate(
'dbus://_/?urgency=invalid', suppress_exceptions=False) 'dbus://_/?urgency=invalid', suppress_exceptions=False)
assert isinstance(obj, NotifyDBus) is True assert isinstance(obj, NotifyDBus)
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
assert obj.notify( assert obj.notify(
title='title', body='body', title='title', body='body',
notify_type=apprise.NotifyType.INFO) is True notify_type=apprise.NotifyType.INFO) is True
obj = apprise.Apprise.instantiate( obj = apprise.Apprise.instantiate(
'dbus://_/?urgency=high', suppress_exceptions=False) 'dbus://_/?urgency=high', suppress_exceptions=False)
assert isinstance(obj, NotifyDBus) is True assert isinstance(obj, NotifyDBus)
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
assert obj.notify( assert obj.notify(
title='title', body='body', title='title', body='body',
notify_type=apprise.NotifyType.INFO) is True notify_type=apprise.NotifyType.INFO) is True
obj = apprise.Apprise.instantiate( obj = apprise.Apprise.instantiate(
'dbus://_/?urgency=2', suppress_exceptions=False) 'dbus://_/?urgency=2', suppress_exceptions=False)
assert isinstance(obj, NotifyDBus) is True assert isinstance(obj, NotifyDBus)
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
assert obj.notify( assert obj.notify(
title='title', body='body', title='title', body='body',
notify_type=apprise.NotifyType.INFO) is True notify_type=apprise.NotifyType.INFO) is True
obj = apprise.Apprise.instantiate( obj = apprise.Apprise.instantiate(
'dbus://_/?urgency=', suppress_exceptions=False) 'dbus://_/?urgency=', suppress_exceptions=False)
assert isinstance(obj, NotifyDBus) is True assert isinstance(obj, NotifyDBus)
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
assert obj.notify( assert obj.notify(
title='title', body='body', title='title', body='body',
notify_type=apprise.NotifyType.INFO) is True notify_type=apprise.NotifyType.INFO) is True
@ -270,8 +270,8 @@ def test_plugin_dbus_general_success(mocker, dbus_glib_environment):
# Test x/y # Test x/y
obj = apprise.Apprise.instantiate( obj = apprise.Apprise.instantiate(
'dbus://_/?x=5&y=5', suppress_exceptions=False) 'dbus://_/?x=5&y=5', suppress_exceptions=False)
assert isinstance(obj, NotifyDBus) is True assert isinstance(obj, NotifyDBus)
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
assert obj.notify( assert obj.notify(
title='title', body='body', title='title', body='body',
notify_type=apprise.NotifyType.INFO) is True notify_type=apprise.NotifyType.INFO) is True

View File

@ -183,4 +183,4 @@ def test_plugin_guilded_general(mock_post):
footer=True, thumbnail=False) footer=True, thumbnail=False)
# Test that we get a string response # Test that we get a string response
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)

View File

@ -150,7 +150,7 @@ def test_plugin_ifttt_edge_cases(mock_post, mock_get):
NotifyIFTTT(webhook_id=webhook_id, events=None) NotifyIFTTT(webhook_id=webhook_id, events=None)
obj = NotifyIFTTT(webhook_id=webhook_id, events=events) obj = NotifyIFTTT(webhook_id=webhook_id, events=events)
assert isinstance(obj, NotifyIFTTT) is True assert isinstance(obj, NotifyIFTTT)
assert obj.notify( assert obj.notify(
body='body', title='title', notify_type=NotifyType.INFO) is True body='body', title='title', notify_type=NotifyType.INFO) is True
@ -160,7 +160,7 @@ def test_plugin_ifttt_edge_cases(mock_post, mock_get):
webhook_id=webhook_id, events=events, webhook_id=webhook_id, events=events,
add_tokens={'Test': 'ValueA', 'Test2': 'ValueB'}) add_tokens={'Test': 'ValueA', 'Test2': 'ValueB'})
assert isinstance(obj, NotifyIFTTT) is True assert isinstance(obj, NotifyIFTTT)
assert obj.notify( assert obj.notify(
body='body', title='title', notify_type=NotifyType.INFO) is True body='body', title='title', notify_type=NotifyType.INFO) is True
@ -171,7 +171,7 @@ def test_plugin_ifttt_edge_cases(mock_post, mock_get):
webhook_id=webhook_id, events=events, webhook_id=webhook_id, events=events,
del_tokens=NotifyIFTTT.ifttt_default_title_key) del_tokens=NotifyIFTTT.ifttt_default_title_key)
assert isinstance(obj, NotifyIFTTT) is True assert isinstance(obj, NotifyIFTTT)
assert obj.notify( assert obj.notify(
body='body', title='title', notify_type=NotifyType.INFO) is True body='body', title='title', notify_type=NotifyType.INFO) is True
@ -187,7 +187,7 @@ def test_plugin_ifttt_edge_cases(mock_post, mock_get):
NotifyIFTTT.ifttt_default_body_key, NotifyIFTTT.ifttt_default_body_key,
NotifyIFTTT.ifttt_default_type_key)) NotifyIFTTT.ifttt_default_type_key))
assert isinstance(obj, NotifyIFTTT) is True assert isinstance(obj, NotifyIFTTT)
assert obj.notify( assert obj.notify(
body='body', title='title', notify_type=NotifyType.INFO) is True body='body', title='title', notify_type=NotifyType.INFO) is True
@ -203,4 +203,4 @@ def test_plugin_ifttt_edge_cases(mock_post, mock_get):
NotifyIFTTT.ifttt_default_body_key: None, NotifyIFTTT.ifttt_default_body_key: None,
NotifyIFTTT.ifttt_default_type_key: None}) NotifyIFTTT.ifttt_default_type_key: None})
assert isinstance(obj, NotifyIFTTT) is True assert isinstance(obj, NotifyIFTTT)

View File

@ -181,7 +181,7 @@ def test_plugin_custom_lunasea_edge_cases(mock_post):
assert results['query'] is None assert results['query'] is None
assert results['schema'] == 'lsea' assert results['schema'] == 'lsea'
assert results['url'] == 'lsea://user:pass@userA,+device1,~~,,' assert results['url'] == 'lsea://user:pass@userA,+device1,~~,,'
assert isinstance(results['qsd:'], dict) is True assert isinstance(results['qsd:'], dict)
instance = NotifyLunaSea(**results) instance = NotifyLunaSea(**results)
assert isinstance(instance, NotifyLunaSea) assert isinstance(instance, NotifyLunaSea)
@ -245,7 +245,7 @@ def test_plugin_custom_lunasea_edge_cases(mock_post):
results['url'] == results['url'] ==
'lseas://user:pass@myhost:3222/%40userA%2C%2Bdevice1%2C%7E%7E%2C%2C' 'lseas://user:pass@myhost:3222/%40userA%2C%2Bdevice1%2C%7E%7E%2C%2C'
) )
assert isinstance(results['qsd:'], dict) is True assert isinstance(results['qsd:'], dict)
instance = NotifyLunaSea(**results) instance = NotifyLunaSea(**results)
assert isinstance(instance, NotifyLunaSea) assert isinstance(instance, NotifyLunaSea)

View File

@ -331,7 +331,7 @@ def test_plugin_mailgun_header_check(mock_post):
obj = Apprise.instantiate( obj = Apprise.instantiate(
'mailgun://user@localhost.localdomain/{}'.format(apikey)) 'mailgun://user@localhost.localdomain/{}'.format(apikey))
assert isinstance(obj, NotifyMailgun) assert isinstance(obj, NotifyMailgun)
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
# No calls made yet # No calls made yet
assert mock_post.call_count == 0 assert mock_post.call_count == 0
@ -358,7 +358,7 @@ def test_plugin_mailgun_header_check(mock_post):
'mailgun://user@localhost.localdomain/' 'mailgun://user@localhost.localdomain/'
'{}?from=Luke%20Skywalker'.format(apikey)) '{}?from=Luke%20Skywalker'.format(apikey))
assert isinstance(obj, NotifyMailgun) assert isinstance(obj, NotifyMailgun)
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
# No calls made yet # No calls made yet
assert mock_post.call_count == 0 assert mock_post.call_count == 0
@ -381,7 +381,7 @@ def test_plugin_mailgun_header_check(mock_post):
'mailgun://user@localhost.localdomain/{}' 'mailgun://user@localhost.localdomain/{}'
'?from=Luke%20Skywalker<luke@rebels.com>'.format(apikey)) '?from=Luke%20Skywalker<luke@rebels.com>'.format(apikey))
assert isinstance(obj, NotifyMailgun) assert isinstance(obj, NotifyMailgun)
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
# No calls made yet # No calls made yet
assert mock_post.call_count == 0 assert mock_post.call_count == 0
@ -404,7 +404,7 @@ def test_plugin_mailgun_header_check(mock_post):
'mailgun://user@localhost.localdomain/{}' 'mailgun://user@localhost.localdomain/{}'
'?from=luke@rebels.com'.format(apikey)) '?from=luke@rebels.com'.format(apikey))
assert isinstance(obj, NotifyMailgun) assert isinstance(obj, NotifyMailgun)
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
# No calls made yet # No calls made yet
assert mock_post.call_count == 0 assert mock_post.call_count == 0

View File

@ -190,8 +190,8 @@ def test_plugin_mastodon_general(mock_post, mock_get):
# Instantiate our object # Instantiate our object
obj = NotifyMastodon(token=token, host=host) obj = NotifyMastodon(token=token, host=host)
assert isinstance(obj, NotifyMastodon) is True assert isinstance(obj, NotifyMastodon)
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
# apprise room was found # apprise room was found
assert obj.send(body="test") is True assert obj.send(body="test") is True
@ -268,7 +268,7 @@ def test_plugin_mastodon_general(mock_post, mock_get):
results = NotifyMastodon.parse_url( results = NotifyMastodon.parse_url(
'mastodon://{}@{}/@user?visbility=direct'.format(token, host)) 'mastodon://{}@{}/@user?visbility=direct'.format(token, host))
assert isinstance(results, dict) is True assert isinstance(results, dict)
assert '@user' in results['targets'] assert '@user' in results['targets']
# cause a json parsing issue now # cause a json parsing issue now

View File

@ -254,27 +254,27 @@ def test_plugin_matrix_general(mock_post, mock_get, mock_put):
# Variation Initializations # Variation Initializations
obj = NotifyMatrix(host='host', targets='#abcd') obj = NotifyMatrix(host='host', targets='#abcd')
assert isinstance(obj, NotifyMatrix) is True assert isinstance(obj, NotifyMatrix)
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
# Registration successful # Registration successful
assert obj.send(body="test") is True assert obj.send(body="test") is True
obj = NotifyMatrix(host='host', user='user', targets='#abcd') obj = NotifyMatrix(host='host', user='user', targets='#abcd')
assert isinstance(obj, NotifyMatrix) is True assert isinstance(obj, NotifyMatrix)
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
# Registration successful # Registration successful
assert obj.send(body="test") is True assert obj.send(body="test") is True
obj = NotifyMatrix(host='host', password='passwd', targets='#abcd') obj = NotifyMatrix(host='host', password='passwd', targets='#abcd')
assert isinstance(obj, NotifyMatrix) is True assert isinstance(obj, NotifyMatrix)
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
# A username gets automatically generated in these cases # A username gets automatically generated in these cases
assert obj.send(body="test") is True assert obj.send(body="test") is True
obj = NotifyMatrix( obj = NotifyMatrix(
host='host', user='user', password='passwd', targets='#abcd') host='host', user='user', password='passwd', targets='#abcd')
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
assert isinstance(obj, NotifyMatrix) is True assert isinstance(obj, NotifyMatrix)
# Registration Successful # Registration Successful
assert obj.send(body="test") is True assert obj.send(body="test") is True
@ -282,23 +282,23 @@ def test_plugin_matrix_general(mock_post, mock_get, mock_put):
kwargs = NotifyMatrix.parse_url( kwargs = NotifyMatrix.parse_url(
'matrix://user:passwd@hostname/#abcd?format=html') 'matrix://user:passwd@hostname/#abcd?format=html')
obj = NotifyMatrix(**kwargs) obj = NotifyMatrix(**kwargs)
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
assert isinstance(obj, NotifyMatrix) is True assert isinstance(obj, NotifyMatrix)
obj.send(body="test") is True assert obj.send(body="test") is True
obj.send(title="title", body="test") is True assert obj.send(title="title", body="test") is True
kwargs = NotifyMatrix.parse_url( kwargs = NotifyMatrix.parse_url(
'matrix://user:passwd@hostname/#abcd/#abcd:localhost?format=markdown') 'matrix://user:passwd@hostname/#abcd/#abcd:localhost?format=markdown')
obj = NotifyMatrix(**kwargs) obj = NotifyMatrix(**kwargs)
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
assert isinstance(obj, NotifyMatrix) is True assert isinstance(obj, NotifyMatrix)
obj.send(body="test") is True assert obj.send(body="test") is True
obj.send(title="title", body="test") is True assert obj.send(title="title", body="test") is True
kwargs = NotifyMatrix.parse_url( kwargs = NotifyMatrix.parse_url(
'matrix://user:passwd@hostname/#abcd/!abcd:localhost?format=text') 'matrix://user:passwd@hostname/#abcd/!abcd:localhost?format=text')
obj = NotifyMatrix(**kwargs) obj = NotifyMatrix(**kwargs)
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
assert isinstance(obj, NotifyMatrix) is True assert isinstance(obj, NotifyMatrix) is True
obj.send(body="test") is True obj.send(body="test") is True
obj.send(title="title", body="test") is True obj.send(title="title", body="test") is True
@ -309,8 +309,8 @@ def test_plugin_matrix_general(mock_post, mock_get, mock_put):
obj = NotifyMatrix(**kwargs) obj = NotifyMatrix(**kwargs)
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str) is True
assert isinstance(obj, NotifyMatrix) is True assert isinstance(obj, NotifyMatrix) is True
obj.send(body="test") is True assert obj.send(body="test") is True
obj.send(title="title", body="test") is True assert obj.send(title="title", body="test") is True
with pytest.raises(TypeError): with pytest.raises(TypeError):
# invalid message type specified # invalid message type specified

View File

@ -163,8 +163,8 @@ def test_plugin_msg91_keywords(mock_post):
obj = Apprise.instantiate( obj = Apprise.instantiate(
'msg91://{}@{}/{}?:key=value&:mobiles=ignored' 'msg91://{}@{}/{}?:key=value&:mobiles=ignored'
.format(template, authkey, target)) .format(template, authkey, target))
assert isinstance(obj, NotifyMSG91) is True assert isinstance(obj, NotifyMSG91)
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
# Send Notification # Send Notification
assert obj.send(body=message_contents) is True assert obj.send(body=message_contents) is True
@ -192,8 +192,8 @@ def test_plugin_msg91_keywords(mock_post):
# Play with mapping # Play with mapping
obj = Apprise.instantiate( obj = Apprise.instantiate(
'msg91://{}@{}/{}?:body&:type=cat'.format(template, authkey, target)) 'msg91://{}@{}/{}?:body&:type=cat'.format(template, authkey, target))
assert isinstance(obj, NotifyMSG91) is True assert isinstance(obj, NotifyMSG91)
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
# Send Notification # Send Notification
assert obj.send(body=message_contents) is True assert obj.send(body=message_contents) is True

View File

@ -110,8 +110,8 @@ def test_plugin_pushdeer_general(mock_post):
# Variation Initializations # Variation Initializations
obj = Apprise.instantiate('pushdeer://localhost/pushKey') obj = Apprise.instantiate('pushdeer://localhost/pushKey')
assert isinstance(obj, NotifyPushDeer) is True assert isinstance(obj, NotifyPushDeer)
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
# Send Notification # Send Notification
assert obj.send(body="test") is True assert obj.send(body="test") is True

View File

@ -340,7 +340,7 @@ def test_plugin_pushover_edge_cases(mock_post):
obj = NotifyPushover( obj = NotifyPushover(
user_key=user_key, token=token, targets=devices) user_key=user_key, token=token, targets=devices)
assert isinstance(obj, NotifyPushover) is True assert isinstance(obj, NotifyPushover)
# Our invalid device is ignored # Our invalid device is ignored
assert len(obj.targets) == 2 assert len(obj.targets) == 2
@ -350,7 +350,7 @@ def test_plugin_pushover_edge_cases(mock_post):
notify_type=apprise.NotifyType.INFO) is True notify_type=apprise.NotifyType.INFO) is True
obj = NotifyPushover(user_key=user_key, token=token) obj = NotifyPushover(user_key=user_key, token=token)
assert isinstance(obj, NotifyPushover) is True assert isinstance(obj, NotifyPushover)
# Default is to send to all devices, so there will be a # Default is to send to all devices, so there will be a
# device defined here # device defined here
assert len(obj.targets) == 1 assert len(obj.targets) == 1
@ -362,7 +362,7 @@ def test_plugin_pushover_edge_cases(mock_post):
obj = NotifyPushover( obj = NotifyPushover(
user_key=user_key, token=token, targets=set()) user_key=user_key, token=token, targets=set())
assert isinstance(obj, NotifyPushover) is True assert isinstance(obj, NotifyPushover)
# Default is to send to all devices, so there will be a # Default is to send to all devices, so there will be a
# device defined here # device defined here
assert len(obj.targets) == 1 assert len(obj.targets) == 1

View File

@ -274,8 +274,8 @@ def test_plugin_reddit_general(mock_post):
# Variation Initializations # Variation Initializations
obj = NotifyReddit(**kwargs) obj = NotifyReddit(**kwargs)
assert isinstance(obj, NotifyReddit) is True assert isinstance(obj, NotifyReddit)
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
# Dynamically pick up on a link # Dynamically pick up on a link
assert obj.send(body="http://hostname") is True assert obj.send(body="http://hostname") is True

View File

@ -319,7 +319,7 @@ def test_plugin_revolt_general(mock_sleep, mock_post):
assert obj.ratelimit_remaining == 1 assert obj.ratelimit_remaining == 1
# Test that we get a string response # Test that we get a string response
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
# This call includes an image with it's payload: # This call includes an image with it's payload:
assert obj.notify( assert obj.notify(

View File

@ -113,7 +113,7 @@ def test_plugin_sns_edge_cases(mock_post):
NotifySNS() Edge Cases NotifySNS() Edge Cases
""" """
target = '+1800555999'
# Initializes the plugin with a valid access, but invalid access key # Initializes the plugin with a valid access, but invalid access key
with pytest.raises(TypeError): with pytest.raises(TypeError):
# No access_key_id specified # No access_key_id specified
@ -121,7 +121,7 @@ def test_plugin_sns_edge_cases(mock_post):
access_key_id=None, access_key_id=None,
secret_access_key=TEST_ACCESS_KEY_SECRET, secret_access_key=TEST_ACCESS_KEY_SECRET,
region_name=TEST_REGION, region_name=TEST_REGION,
targets='+1800555999', targets=target,
) )
with pytest.raises(TypeError): with pytest.raises(TypeError):
@ -130,7 +130,7 @@ def test_plugin_sns_edge_cases(mock_post):
access_key_id=TEST_ACCESS_KEY_ID, access_key_id=TEST_ACCESS_KEY_ID,
secret_access_key=None, secret_access_key=None,
region_name=TEST_REGION, region_name=TEST_REGION,
targets='+1800555999', targets=target,
) )
with pytest.raises(TypeError): with pytest.raises(TypeError):
@ -139,7 +139,7 @@ def test_plugin_sns_edge_cases(mock_post):
access_key_id=TEST_ACCESS_KEY_ID, access_key_id=TEST_ACCESS_KEY_ID,
secret_access_key=TEST_ACCESS_KEY_SECRET, secret_access_key=TEST_ACCESS_KEY_SECRET,
region_name=None, region_name=None,
targets='+1800555999', targets=target,
) )
# No recipients # No recipients
@ -200,20 +200,22 @@ def test_plugin_sns_url_parsing():
assert 'secret_access_key' in results assert 'secret_access_key' in results
assert TEST_ACCESS_KEY_SECRET == results['secret_access_key'] assert TEST_ACCESS_KEY_SECRET == results['secret_access_key']
target = '+18001234567'
topic = 'MyTopic'
# Detect recipients # Detect recipients
results = NotifySNS.parse_url('sns://%s/%s/%s/%s/%s/' % ( results = NotifySNS.parse_url('sns://%s/%s/%s/%s/%s/' % (
TEST_ACCESS_KEY_ID, TEST_ACCESS_KEY_ID,
TEST_ACCESS_KEY_SECRET, TEST_ACCESS_KEY_SECRET,
# Uppercase Region won't break anything # Uppercase Region won't break anything
TEST_REGION.upper(), TEST_REGION.upper(),
'+18001234567', target,
'MyTopic') topic)
) )
# Confirm that our recipients were found # Confirm that our recipients were found
assert len(results['targets']) == 2 assert len(results['targets']) == 2
assert '+18001234567' in results['targets'] assert target in results['targets']
assert 'MyTopic' in results['targets'] assert topic in results['targets']
assert 'region_name' in results assert 'region_name' in results
assert TEST_REGION == results['region_name'] assert TEST_REGION == results['region_name']
assert 'access_key_id' in results assert 'access_key_id' in results

View File

@ -57,7 +57,7 @@ def test_plugin_syslog_by_url(openlog, syslog):
assert NotifySyslog.parse_url(None) is None assert NotifySyslog.parse_url(None) is None
obj = apprise.Apprise.instantiate('syslog://') obj = apprise.Apprise.instantiate('syslog://')
assert obj.url().startswith('syslog://user') is True assert obj.url().startswith('syslog://user')
assert re.search(r'logpid=yes', obj.url()) is not None assert re.search(r'logpid=yes', obj.url()) is not None
assert re.search(r'logperror=no', obj.url()) is not None assert re.search(r'logperror=no', obj.url()) is not None
@ -67,7 +67,7 @@ def test_plugin_syslog_by_url(openlog, syslog):
obj = apprise.Apprise.instantiate('syslog://?logpid=no&logperror=yes') obj = apprise.Apprise.instantiate('syslog://?logpid=no&logperror=yes')
assert isinstance(obj, NotifySyslog) assert isinstance(obj, NotifySyslog)
assert obj.url().startswith('syslog://user') is True assert obj.url().startswith('syslog://user')
assert re.search(r'logpid=no', obj.url()) is not None assert re.search(r'logpid=no', obj.url()) is not None
assert re.search(r'logperror=yes', obj.url()) is not None assert re.search(r'logperror=yes', obj.url()) is not None
@ -80,7 +80,7 @@ def test_plugin_syslog_by_url(openlog, syslog):
obj = apprise.Apprise.instantiate('syslog://_/?facility=local5') obj = apprise.Apprise.instantiate('syslog://_/?facility=local5')
assert isinstance(obj, NotifySyslog) assert isinstance(obj, NotifySyslog)
assert obj.url().startswith('syslog://local5') is True assert obj.url().startswith('syslog://local5')
assert re.search(r'logpid=yes', obj.url()) is not None assert re.search(r'logpid=yes', obj.url()) is not None
assert re.search(r'logperror=no', obj.url()) is not None assert re.search(r'logperror=no', obj.url()) is not None
@ -90,21 +90,21 @@ def test_plugin_syslog_by_url(openlog, syslog):
# j will cause a search to take place and match to daemon # j will cause a search to take place and match to daemon
obj = apprise.Apprise.instantiate('syslog://_/?facility=d') obj = apprise.Apprise.instantiate('syslog://_/?facility=d')
assert isinstance(obj, NotifySyslog) assert isinstance(obj, NotifySyslog)
assert obj.url().startswith('syslog://daemon') is True assert obj.url().startswith('syslog://daemon')
assert re.search(r'logpid=yes', obj.url()) is not None assert re.search(r'logpid=yes', obj.url()) is not None
assert re.search(r'logperror=no', obj.url()) is not None assert re.search(r'logperror=no', obj.url()) is not None
# Facility can also be specified on the url as a hostname # Facility can also be specified on the url as a hostname
obj = apprise.Apprise.instantiate('syslog://kern?logpid=no&logperror=y') obj = apprise.Apprise.instantiate('syslog://kern?logpid=no&logperror=y')
assert isinstance(obj, NotifySyslog) assert isinstance(obj, NotifySyslog)
assert obj.url().startswith('syslog://kern') is True assert obj.url().startswith('syslog://kern')
assert re.search(r'logpid=no', obj.url()) is not None assert re.search(r'logpid=no', obj.url()) is not None
assert re.search(r'logperror=yes', obj.url()) is not None assert re.search(r'logperror=yes', obj.url()) is not None
# Facilities specified as an argument always over-ride host # Facilities specified as an argument always over-ride host
obj = apprise.Apprise.instantiate('syslog://kern?facility=d') obj = apprise.Apprise.instantiate('syslog://kern?facility=d')
assert isinstance(obj, NotifySyslog) assert isinstance(obj, NotifySyslog)
assert obj.url().startswith('syslog://daemon') is True assert obj.url().startswith('syslog://daemon')
@mock.patch('syslog.syslog') @mock.patch('syslog.syslog')
@ -118,7 +118,7 @@ def test_plugin_syslog_edge_cases(openlog, syslog):
# Default # Default
obj = NotifySyslog(facility=None) obj = NotifySyslog(facility=None)
assert isinstance(obj, NotifySyslog) assert isinstance(obj, NotifySyslog)
assert obj.url().startswith('syslog://user') is True assert obj.url().startswith('syslog://user')
assert re.search(r'logpid=yes', obj.url()) is not None assert re.search(r'logpid=yes', obj.url()) is not None
assert re.search(r'logperror=no', obj.url()) is not None assert re.search(r'logperror=no', obj.url()) is not None

View File

@ -153,9 +153,9 @@ def test_plugin_threema_edge_cases(mock_post):
assert results['query'] is None assert results['query'] is None
assert results['schema'] == 'threema' assert results['schema'] == 'threema'
assert results['url'] == 'threema:///' assert results['url'] == 'threema:///'
assert isinstance(results['targets'], list) is True assert isinstance(results['targets'], list)
assert len(results['targets']) == 1 assert len(results['targets']) == 1
assert results['targets'][0] == '+1 (555) 123-9876' assert results['targets'][0] == targets
instance = NotifyThreema(**results) instance = NotifyThreema(**results)
assert len(instance.targets) == 1 assert len(instance.targets) == 1

View File

@ -158,8 +158,8 @@ def test_plugin_twilio_auth(mock_post):
obj = Apprise.instantiate( obj = Apprise.instantiate(
'twilio://{}:{}@{}/{}' 'twilio://{}:{}@{}/{}'
.format(account_sid, auth_token, source, dest)) .format(account_sid, auth_token, source, dest))
assert isinstance(obj, NotifyTwilio) is True assert isinstance(obj, NotifyTwilio)
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
# Send Notification # Send Notification
assert obj.send(body=message_contents) is True assert obj.send(body=message_contents) is True
@ -168,8 +168,8 @@ def test_plugin_twilio_auth(mock_post):
obj = Apprise.instantiate( obj = Apprise.instantiate(
'twilio://{}:{}@{}/{}?apikey={}' 'twilio://{}:{}@{}/{}?apikey={}'
.format(account_sid, auth_token, source, dest, apikey)) .format(account_sid, auth_token, source, dest, apikey))
assert isinstance(obj, NotifyTwilio) is True assert isinstance(obj, NotifyTwilio)
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
# Send Notification # Send Notification
assert obj.send(body=message_contents) is True assert obj.send(body=message_contents) is True

View File

@ -28,6 +28,7 @@
from unittest import mock from unittest import mock
import pytest
import requests import requests
from json import dumps from json import dumps
from apprise import Apprise from apprise import Apprise
@ -111,19 +112,11 @@ def test_plugin_twist_init():
NotifyTwist() init() NotifyTwist() init()
""" """
try: with pytest.raises(TypeError):
NotifyTwist(email='invalid', targets=None) NotifyTwist(email='invalid', targets=None)
assert False
except TypeError:
# Invalid email address
assert True
try: with pytest.raises(TypeError):
NotifyTwist(email='user@domain', targets=None) NotifyTwist(email='user@domain', targets=None)
assert False
except TypeError:
# No password was specified
assert True
# Simple object initialization # Simple object initialization
result = NotifyTwist( result = NotifyTwist(

View File

@ -109,7 +109,7 @@ def test_plugin_windows_mocked():
obj.duration = 0 obj.duration = 0
# Test URL functionality # Test URL functionality
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
# Check that it found our mocked environments # Check that it found our mocked environments
assert obj.enabled is True assert obj.enabled is True
@ -125,7 +125,7 @@ def test_plugin_windows_mocked():
obj = apprise.Apprise.instantiate( obj = apprise.Apprise.instantiate(
'windows://_/?image=True', suppress_exceptions=False) 'windows://_/?image=True', suppress_exceptions=False)
obj.duration = 0 obj.duration = 0
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
assert obj.notify( assert obj.notify(
title='title', body='body', title='title', body='body',
notify_type=apprise.NotifyType.INFO) is True notify_type=apprise.NotifyType.INFO) is True
@ -133,14 +133,14 @@ def test_plugin_windows_mocked():
obj = apprise.Apprise.instantiate( obj = apprise.Apprise.instantiate(
'windows://_/?image=False', suppress_exceptions=False) 'windows://_/?image=False', suppress_exceptions=False)
obj.duration = 0 obj.duration = 0
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
assert obj.notify( assert obj.notify(
title='title', body='body', title='title', body='body',
notify_type=apprise.NotifyType.INFO) is True notify_type=apprise.NotifyType.INFO) is True
obj = apprise.Apprise.instantiate( obj = apprise.Apprise.instantiate(
'windows://_/?duration=1', suppress_exceptions=False) 'windows://_/?duration=1', suppress_exceptions=False)
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
# loads okay # loads okay
assert obj.duration == 1 assert obj.duration == 1
assert obj.notify( assert obj.notify(
@ -211,7 +211,7 @@ def test_plugin_windows_native(mock_loadimage,
obj.duration = 0 obj.duration = 0
# Test URL functionality # Test URL functionality
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
# Check that it found our mocked environments # Check that it found our mocked environments
assert obj.enabled is True assert obj.enabled is True
@ -227,7 +227,7 @@ def test_plugin_windows_native(mock_loadimage,
obj = apprise.Apprise.instantiate( obj = apprise.Apprise.instantiate(
'windows://_/?image=True', suppress_exceptions=False) 'windows://_/?image=True', suppress_exceptions=False)
obj.duration = 0 obj.duration = 0
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
assert obj.notify( assert obj.notify(
title='title', body='body', title='title', body='body',
notify_type=apprise.NotifyType.INFO) is True notify_type=apprise.NotifyType.INFO) is True
@ -235,14 +235,14 @@ def test_plugin_windows_native(mock_loadimage,
obj = apprise.Apprise.instantiate( obj = apprise.Apprise.instantiate(
'windows://_/?image=False', suppress_exceptions=False) 'windows://_/?image=False', suppress_exceptions=False)
obj.duration = 0 obj.duration = 0
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
assert obj.notify( assert obj.notify(
title='title', body='body', title='title', body='body',
notify_type=apprise.NotifyType.INFO) is True notify_type=apprise.NotifyType.INFO) is True
obj = apprise.Apprise.instantiate( obj = apprise.Apprise.instantiate(
'windows://_/?duration=1', suppress_exceptions=False) 'windows://_/?duration=1', suppress_exceptions=False)
assert isinstance(obj.url(), str) is True assert isinstance(obj.url(), str)
assert obj.notify( assert obj.notify(
title='title', body='body', title='title', body='body',
notify_type=apprise.NotifyType.INFO) is True notify_type=apprise.NotifyType.INFO) is True