mirror of
https://github.com/caronc/apprise.git
synced 2025-08-14 10:28:38 +02:00
Resolve ambiguity with apprise.plugins
module namespace
While the namespace is physically made of modules, it has been amended to be the namespace home for the corresponding notifier classes as well. This turned out to confuse both humans and machines on various ends. While it has apparently worked for a while, it croaks on Python 3.11 now, and is not considered to have been a good idea in general.
This commit is contained in:
@ -26,7 +26,8 @@ from unittest import mock
|
||||
|
||||
import pytest
|
||||
import requests
|
||||
from apprise import plugins
|
||||
|
||||
from apprise.plugins.NotifySendGrid import NotifySendGrid
|
||||
from helpers import AppriseURLTester
|
||||
|
||||
# Disable logging for a cleaner testing output
|
||||
@ -59,54 +60,54 @@ apprise_url_tests = (
|
||||
('sendgrid://abcd:user@example.com', {
|
||||
# No To/Target Address(es) specified; so we sub in the same From
|
||||
# address
|
||||
'instance': plugins.NotifySendGrid,
|
||||
'instance': NotifySendGrid,
|
||||
}),
|
||||
('sendgrid://abcd:user@example.com/newuser@example.com', {
|
||||
# A good email
|
||||
'instance': plugins.NotifySendGrid,
|
||||
'instance': NotifySendGrid,
|
||||
}),
|
||||
('sendgrid://abcd:user@example.com/newuser@example.com'
|
||||
'?bcc=l2g@nuxref.com', {
|
||||
# A good email with Blind Carbon Copy
|
||||
'instance': plugins.NotifySendGrid,
|
||||
'instance': NotifySendGrid,
|
||||
}),
|
||||
('sendgrid://abcd:user@example.com/newuser@example.com'
|
||||
'?cc=l2g@nuxref.com', {
|
||||
# A good email with Carbon Copy
|
||||
'instance': plugins.NotifySendGrid,
|
||||
'instance': NotifySendGrid,
|
||||
}),
|
||||
('sendgrid://abcd:user@example.com/newuser@example.com'
|
||||
'?to=l2g@nuxref.com', {
|
||||
# A good email with Carbon Copy
|
||||
'instance': plugins.NotifySendGrid,
|
||||
'instance': NotifySendGrid,
|
||||
}),
|
||||
('sendgrid://abcd:user@example.com/newuser@example.com'
|
||||
'?template={}'.format(UUID4), {
|
||||
# A good email with a template + no substitutions
|
||||
'instance': plugins.NotifySendGrid,
|
||||
'instance': NotifySendGrid,
|
||||
}),
|
||||
('sendgrid://abcd:user@example.com/newuser@example.com'
|
||||
'?template={}&+sub=value&+sub2=value2'.format(UUID4), {
|
||||
# A good email with a template + substitutions
|
||||
'instance': plugins.NotifySendGrid,
|
||||
'instance': NotifySendGrid,
|
||||
|
||||
# Our expected url(privacy=True) startswith() response:
|
||||
'privacy_url': 'sendgrid://a...d:user@example.com/',
|
||||
}),
|
||||
('sendgrid://abcd:user@example.ca/newuser@example.ca', {
|
||||
'instance': plugins.NotifySendGrid,
|
||||
'instance': NotifySendGrid,
|
||||
# force a failure
|
||||
'response': False,
|
||||
'requests_response_code': requests.codes.internal_server_error,
|
||||
}),
|
||||
('sendgrid://abcd:user@example.uk/newuser@example.uk', {
|
||||
'instance': plugins.NotifySendGrid,
|
||||
'instance': NotifySendGrid,
|
||||
# throw a bizzare code forcing us to fail to look it up
|
||||
'response': False,
|
||||
'requests_response_code': 999,
|
||||
}),
|
||||
('sendgrid://abcd:user@example.au/newuser@example.au', {
|
||||
'instance': plugins.NotifySendGrid,
|
||||
'instance': NotifySendGrid,
|
||||
# Throws a series of connection and transfer exceptions when this flag
|
||||
# is set and tests that we gracfully handle them
|
||||
'test_requests_exceptions': True,
|
||||
@ -134,25 +135,25 @@ def test_plugin_sendgrid_edge_cases(mock_post, mock_get, no_throttling):
|
||||
|
||||
# no apikey
|
||||
with pytest.raises(TypeError):
|
||||
plugins.NotifySendGrid(
|
||||
NotifySendGrid(
|
||||
apikey=None, from_email='user@example.com')
|
||||
|
||||
# invalid from email
|
||||
with pytest.raises(TypeError):
|
||||
plugins.NotifySendGrid(
|
||||
NotifySendGrid(
|
||||
apikey='abcd', from_email='!invalid')
|
||||
|
||||
# no email
|
||||
with pytest.raises(TypeError):
|
||||
plugins.NotifySendGrid(apikey='abcd', from_email=None)
|
||||
NotifySendGrid(apikey='abcd', from_email=None)
|
||||
|
||||
# Invalid To email address
|
||||
plugins.NotifySendGrid(
|
||||
NotifySendGrid(
|
||||
apikey='abcd', from_email='user@example.com', targets="!invalid")
|
||||
|
||||
# Test invalid bcc/cc entries mixed with good ones
|
||||
assert isinstance(plugins.NotifySendGrid(
|
||||
assert isinstance(NotifySendGrid(
|
||||
apikey='abcd',
|
||||
from_email='l2g@example.com',
|
||||
bcc=('abc@def.com', '!invalid'),
|
||||
cc=('abc@test.org', '!invalid')), plugins.NotifySendGrid)
|
||||
cc=('abc@test.org', '!invalid')), NotifySendGrid)
|
||||
|
Reference in New Issue
Block a user