Added Stride Support + Testing; refs #6

This commit is contained in:
Chris Caron
2018-03-06 20:27:15 -05:00
parent 16f1c2b78c
commit c4b3d1768b
4 changed files with 377 additions and 7 deletions

View File

@ -22,6 +22,7 @@ from apprise import Apprise
from apprise import AppriseAsset
from apprise.utils import compat_is_basestring
from json import dumps
import uuid
import requests
import mock
@ -233,6 +234,63 @@ TEST_URLS = (
'test_requests_exceptions': True,
}),
##################################
# NotifyStride
##################################
# no auth_key specified
('stride://', {
'instance': None,
}),
# No token_a specified
('stride://auth_key', {
# Missing a token
'instance': TypeError,
}),
# No token_b specified
('stride://auth_key/{0}'.format(
str(uuid.uuid4())), {
'instance': TypeError,
}),
# invalid uuid entries
('stride://auth_key/{0}/{1}'.format(
'invalid-uuid', str(uuid.uuid4())), {
'instance': TypeError,
}),
('stride://auth_key/{0}/{1}'.format(
str(uuid.uuid4()), 'invalid-uuid'), {
'instance': TypeError,
}),
# A valid url
('stride://auth_key/{0}/{1}'.format(
str(uuid.uuid4()), str(uuid.uuid4())), {
'instance': plugins.NotifyStride,
}),
# A very invalid URL
('stride://:@/', {
'instance': None,
}),
('stride://auth_key/{0}/{1}'.format(
str(uuid.uuid4()), str(uuid.uuid4())), {
'instance': plugins.NotifyStride,
# force a failure
'response': False,
'requests_response_code': requests.codes.internal_server_error,
}),
('stride://auth_key/{0}/{1}'.format(
str(uuid.uuid4()), str(uuid.uuid4())), {
'instance': plugins.NotifyStride,
# throw a bizzare code forcing us to fail to look it up
'response': False,
'requests_response_code': 999,
}),
('stride://auth_key/{0}/{1}'.format(
str(uuid.uuid4()), str(uuid.uuid4())), {
'instance': plugins.NotifyStride,
# Throws a series of connection and transfer exceptions when this flag
# is set and tests that we gracfully handle them
'test_requests_exceptions': True,
}),
##################################
# NotifyJoin
##################################
@ -1902,6 +1960,40 @@ def test_notify_emby_plugin_notify(mock_post, mock_get, mock_logout,
assert obj.notify('title', 'body', 'info') is True
def test_notify_stride_plugin():
"""
API: NotifyStride() Extra Checks
"""
try:
# Initializes the plugin with devices set to a string
plugins.NotifyStride(
auth_token=None,
cloud_id=str(uuid.uuid4()),
convo_id=str(uuid.uuid4()),
)
# The code shouldn't make it here, we should throw an exception
# on the previous line
assert False
except TypeError:
assert True
try:
# Initializes the plugin with devices set to a string
plugins.NotifyStride(
auth_token='key',
cloud_id=str(uuid.uuid4()),
convo_id=None,
)
# The code shouldn't make it here, we should throw an exception
# on the previous line
assert False
except TypeError:
assert True
@mock.patch('requests.get')
@mock.patch('requests.post')
def test_notify_join_plugin(mock_post, mock_get):