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:
Andreas Motl
2022-10-09 11:28:18 +02:00
parent c797d1e2eb
commit c9f0751b61
88 changed files with 1721 additions and 1688 deletions

View File

@ -26,7 +26,8 @@ from unittest import mock
import pytest
import requests
from apprise import plugins
from apprise.plugins.NotifyPushed import NotifyPushed
from helpers import AppriseURLTester
# Disable logging for a cleaner testing output
@ -48,15 +49,15 @@ apprise_url_tests = (
}),
# Application Key+Secret
('pushed://%s/%s' % ('a' * 32, 'a' * 64), {
'instance': plugins.NotifyPushed,
'instance': NotifyPushed,
}),
# Application Key+Secret + channel
('pushed://%s/%s/#channel/' % ('a' * 32, 'a' * 64), {
'instance': plugins.NotifyPushed,
'instance': NotifyPushed,
}),
# Application Key+Secret + channel (via to=)
('pushed://%s/%s?to=channel' % ('a' * 32, 'a' * 64), {
'instance': plugins.NotifyPushed,
'instance': NotifyPushed,
# Our expected url(privacy=True) startswith() response:
'privacy_url': 'pushed://a...a/****/',
}),
@ -67,65 +68,65 @@ apprise_url_tests = (
}),
# Application Key+Secret + 2 channels
('pushed://%s/%s/#channel1/#channel2' % ('a' * 32, 'a' * 64), {
'instance': plugins.NotifyPushed,
'instance': NotifyPushed,
}),
# Application Key+Secret + User Pushed ID
('pushed://%s/%s/@ABCD/' % ('a' * 32, 'a' * 64), {
'instance': plugins.NotifyPushed,
'instance': NotifyPushed,
}),
# Application Key+Secret + 2 devices
('pushed://%s/%s/@ABCD/@DEFG/' % ('a' * 32, 'a' * 64), {
'instance': plugins.NotifyPushed,
'instance': NotifyPushed,
}),
# Application Key+Secret + Combo
('pushed://%s/%s/@ABCD/#channel' % ('a' * 32, 'a' * 64), {
'instance': plugins.NotifyPushed,
'instance': NotifyPushed,
}),
# ,
('pushed://%s/%s' % ('a' * 32, 'a' * 64), {
'instance': plugins.NotifyPushed,
'instance': NotifyPushed,
# force a failure
'response': False,
'requests_response_code': requests.codes.internal_server_error,
}),
('pushed://%s/%s' % ('a' * 32, 'a' * 64), {
'instance': plugins.NotifyPushed,
'instance': NotifyPushed,
# throw a bizzare code forcing us to fail to look it up
'response': False,
'requests_response_code': 999,
}),
('pushed://%s/%s' % ('a' * 32, 'a' * 64), {
'instance': plugins.NotifyPushed,
'instance': NotifyPushed,
# Throws a series of connection and transfer exceptions when this flag
# is set and tests that we gracfully handle them
'test_requests_exceptions': True,
}),
('pushed://%s/%s' % ('a' * 32, 'a' * 64), {
'instance': plugins.NotifyPushed,
'instance': NotifyPushed,
# force a failure
'response': False,
'requests_response_code': requests.codes.internal_server_error,
}),
('pushed://%s/%s' % ('a' * 32, 'a' * 64), {
'instance': plugins.NotifyPushed,
'instance': NotifyPushed,
# throw a bizzare code forcing us to fail to look it up
'response': False,
'requests_response_code': 999,
}),
('pushed://%s/%s/#channel' % ('a' * 32, 'a' * 64), {
'instance': plugins.NotifyPushed,
'instance': NotifyPushed,
# throw a bizzare code forcing us to fail to look it up
'response': False,
'requests_response_code': 999,
}),
('pushed://%s/%s/@user' % ('a' * 32, 'a' * 64), {
'instance': plugins.NotifyPushed,
'instance': NotifyPushed,
# throw a bizzare code forcing us to fail to look it up
'response': False,
'requests_response_code': 999,
}),
('pushed://%s/%s' % ('a' * 32, 'a' * 64), {
'instance': plugins.NotifyPushed,
'instance': NotifyPushed,
# Throws a series of connection and transfer exceptions when this flag
# is set and tests that we gracfully handle them
'test_requests_exceptions': True,
@ -166,49 +167,49 @@ def test_plugin_pushed_edge_cases(mock_post, mock_get, no_throttling):
# No application Key specified
with pytest.raises(TypeError):
plugins.NotifyPushed(
NotifyPushed(
app_key=None,
app_secret=app_secret,
recipients=None,
)
with pytest.raises(TypeError):
plugins.NotifyPushed(
NotifyPushed(
app_key=" ",
app_secret=app_secret,
recipients=None,
)
# No application Secret specified
with pytest.raises(TypeError):
plugins.NotifyPushed(
NotifyPushed(
app_key=app_key,
app_secret=None,
recipients=None,
)
with pytest.raises(TypeError):
plugins.NotifyPushed(
NotifyPushed(
app_key=app_key,
app_secret=" ",
)
# recipients list set to (None) is perfectly fine; in this case it will
# notify the App
obj = plugins.NotifyPushed(
obj = NotifyPushed(
app_key=app_key,
app_secret=app_secret,
recipients=None,
)
assert isinstance(obj, plugins.NotifyPushed) is True
assert isinstance(obj, NotifyPushed) is True
assert len(obj.channels) == 0
assert len(obj.users) == 0
obj = plugins.NotifyPushed(
obj = NotifyPushed(
app_key=app_key,
app_secret=app_secret,
targets=recipients,
)
assert isinstance(obj, plugins.NotifyPushed) is True
assert isinstance(obj, NotifyPushed) is True
assert len(obj.channels) == 2
assert len(obj.users) == 2