mirror of
https://github.com/caronc/apprise.git
synced 2025-08-17 12:01:33 +02:00
Apprise API Integration (#459)
This commit is contained in:
@ -68,6 +68,131 @@ REQUEST_EXCEPTIONS = (
|
||||
TEST_VAR_DIR = os.path.join(os.path.dirname(__file__), 'var')
|
||||
|
||||
TEST_URLS = (
|
||||
##################################
|
||||
# NotifyAppriseAPI
|
||||
##################################
|
||||
('apprise://', {
|
||||
# invalid url (not complete)
|
||||
'instance': None,
|
||||
}),
|
||||
# A a bad url
|
||||
('apprise://:@/', {
|
||||
'instance': None,
|
||||
}),
|
||||
# No token specified
|
||||
('apprise://localhost', {
|
||||
'instance': TypeError,
|
||||
}),
|
||||
# invalid token
|
||||
('apprise://localhost/!', {
|
||||
'instance': TypeError,
|
||||
}),
|
||||
# No token specified (whitespace is trimmed)
|
||||
('apprise://localhost/%%20', {
|
||||
'instance': TypeError,
|
||||
}),
|
||||
# A valid URL with Token
|
||||
('apprise://localhost/%s' % ('a' * 32), {
|
||||
'instance': plugins.NotifyAppriseAPI,
|
||||
# Our expected url(privacy=True) startswith() response:
|
||||
'privacy_url': 'apprise://localhost/a...a/',
|
||||
}),
|
||||
# A valid URL with Token (using port)
|
||||
('apprise://localhost:8080/%s' % ('b' * 32), {
|
||||
'instance': plugins.NotifyAppriseAPI,
|
||||
# Our expected url(privacy=True) startswith() response:
|
||||
'privacy_url': 'apprise://localhost:8080/b...b/',
|
||||
}),
|
||||
# A secure (https://) reference
|
||||
('apprises://localhost/%s' % ('c' * 32), {
|
||||
'instance': plugins.NotifyAppriseAPI,
|
||||
# Our expected url(privacy=True) startswith() response:
|
||||
'privacy_url': 'apprises://localhost/c...c/',
|
||||
}),
|
||||
# Native URL suport (https)
|
||||
('https://example.com/path/notify/%s' % ('d' * 32), {
|
||||
'instance': plugins.NotifyAppriseAPI,
|
||||
# Our expected url(privacy=True) startswith() response:
|
||||
'privacy_url': 'apprises://example.com/path/d...d/',
|
||||
}),
|
||||
# Native URL suport (http)
|
||||
('http://example.com/notify/%s' % ('d' * 32), {
|
||||
'instance': plugins.NotifyAppriseAPI,
|
||||
# Our expected url(privacy=True) startswith() response:
|
||||
'privacy_url': 'apprise://example.com/d...d/',
|
||||
}),
|
||||
# support to= keyword
|
||||
('apprises://localhost/?to=%s' % ('e' * 32), {
|
||||
'instance': plugins.NotifyAppriseAPI,
|
||||
'privacy_url': 'apprises://localhost/e...e/',
|
||||
}),
|
||||
# support token= keyword (even when passed with to=, token over-rides)
|
||||
('apprise://localhost/?token=%s&to=%s' % ('f' * 32, 'abcd'), {
|
||||
'instance': plugins.NotifyAppriseAPI,
|
||||
'privacy_url': 'apprise://localhost/f...f/',
|
||||
}),
|
||||
# Test tags
|
||||
('apprise://localhost/?token=%s&tags=admin,team' % ('abcd'), {
|
||||
'instance': plugins.NotifyAppriseAPI,
|
||||
'privacy_url': 'apprise://localhost/a...d/',
|
||||
}),
|
||||
# Test Format string
|
||||
('apprise://user@localhost/mytoken0/?format=markdown', {
|
||||
'instance': plugins.NotifyAppriseAPI,
|
||||
'privacy_url': 'apprise://user@localhost/m...0/',
|
||||
}),
|
||||
('apprise://user@localhost/mytoken1/', {
|
||||
'instance': plugins.NotifyAppriseAPI,
|
||||
'privacy_url': 'apprise://user@localhost/m...1/',
|
||||
}),
|
||||
('apprise://localhost:8080/mytoken/', {
|
||||
'instance': plugins.NotifyAppriseAPI,
|
||||
}),
|
||||
('apprise://user:pass@localhost:8080/mytoken2/', {
|
||||
'instance': plugins.NotifyAppriseAPI,
|
||||
'privacy_url': 'apprise://user:****@localhost:8080/m...2/',
|
||||
}),
|
||||
('apprises://localhost/mytoken/', {
|
||||
'instance': plugins.NotifyAppriseAPI,
|
||||
}),
|
||||
('apprises://user:pass@localhost/mytoken3/', {
|
||||
'instance': plugins.NotifyAppriseAPI,
|
||||
# Our expected url(privacy=True) startswith() response:
|
||||
'privacy_url': 'apprises://user:****@localhost/m...3/',
|
||||
}),
|
||||
('apprises://localhost:8080/mytoken4/', {
|
||||
'instance': plugins.NotifyAppriseAPI,
|
||||
# Our expected url(privacy=True) startswith() response:
|
||||
'privacy_url': 'apprises://localhost:8080/m...4/',
|
||||
}),
|
||||
('apprises://user:password@localhost:8080/mytoken5/', {
|
||||
'instance': plugins.NotifyAppriseAPI,
|
||||
|
||||
# Our expected url(privacy=True) startswith() response:
|
||||
'privacy_url': 'apprises://user:****@localhost:8080/m...5/',
|
||||
}),
|
||||
('apprises://localhost:8080/path?-HeaderKey=HeaderValue', {
|
||||
'instance': plugins.NotifyAppriseAPI,
|
||||
}),
|
||||
('apprise://localhost/%s' % ('a' * 32), {
|
||||
'instance': plugins.NotifyAppriseAPI,
|
||||
# force a failure
|
||||
'response': False,
|
||||
'requests_response_code': requests.codes.internal_server_error,
|
||||
}),
|
||||
('apprise://localhost/%s' % ('a' * 32), {
|
||||
'instance': plugins.NotifyAppriseAPI,
|
||||
# throw a bizzare code forcing us to fail to look it up
|
||||
'response': False,
|
||||
'requests_response_code': 999,
|
||||
}),
|
||||
('apprise://localhost/%s' % ('a' * 32), {
|
||||
'instance': plugins.NotifyAppriseAPI,
|
||||
# Throws a series of connection and transfer exceptions when this flag
|
||||
# is set and tests that we gracfully handle them
|
||||
'test_requests_exceptions': True,
|
||||
}),
|
||||
|
||||
##################################
|
||||
# NotifyBoxcar
|
||||
##################################
|
||||
|
Reference in New Issue
Block a user