Skip to content

Commit

Permalink
updated SCHEMA MAP property to reflect changes in Apprise v1.0 (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
caronc authored Aug 7, 2022
1 parent 8247191 commit def1ded
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 24 deletions.
27 changes: 17 additions & 10 deletions apprise_api/api/tests/test_notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def test_notify_with_tags(self, mock_post):
# Disable Throttling to speed testing
apprise.plugins.NotifyBase.request_rate_per_sec = 0
# Ensure we're enabled for the purpose of our testing
apprise.plugins.SCHEMA_MAP['json'].enabled = True
apprise.common.NOTIFY_SCHEMA_MAP['json'].enabled = True

# Prepare our response
response = requests.Request()
Expand Down Expand Up @@ -461,7 +461,7 @@ def test_notify_with_filters(self, mock_send):
}

# Verify by default email is enabled
assert apprise.plugins.SCHEMA_MAP['mailto'].enabled is True
assert apprise.common.NOTIFY_SCHEMA_MAP['mailto'].enabled is True

# Send our service with the `mailto://` denied
with override_settings(APPRISE_ALLOW_SERVICES=""):
Expand All @@ -478,10 +478,11 @@ def test_notify_with_filters(self, mock_send):
assert mock_send.call_count == 0

# What actually took place behind close doors:
assert apprise.plugins.SCHEMA_MAP['mailto'].enabled is False
assert \
apprise.common.NOTIFY_SCHEMA_MAP['mailto'].enabled is False

# Reset our flag (for next test)
apprise.plugins.SCHEMA_MAP['mailto'].enabled = True
apprise.common.NOTIFY_SCHEMA_MAP['mailto'].enabled = True

# Reset Mock
mock_send.reset_mock()
Expand All @@ -501,7 +502,8 @@ def test_notify_with_filters(self, mock_send):
assert mock_send.call_count == 1

# Verify that mailto was never turned off
assert apprise.plugins.SCHEMA_MAP['mailto'].enabled is True
assert \
apprise.common.NOTIFY_SCHEMA_MAP['mailto'].enabled is True

# Reset Mock
mock_send.reset_mock()
Expand All @@ -521,7 +523,8 @@ def test_notify_with_filters(self, mock_send):
assert mock_send.call_count == 1

# Verify email was never turned off
assert apprise.plugins.SCHEMA_MAP['mailto'].enabled is True
assert \
apprise.common.NOTIFY_SCHEMA_MAP['mailto'].enabled is True

# Reset Mock
mock_send.reset_mock()
Expand All @@ -541,7 +544,8 @@ def test_notify_with_filters(self, mock_send):
assert mock_send.call_count == 1

# Verify email was never turned off
assert apprise.plugins.SCHEMA_MAP['mailto'].enabled is True
assert \
apprise.common.NOTIFY_SCHEMA_MAP['mailto'].enabled is True

# Reset Mock
mock_send.reset_mock()
Expand All @@ -561,10 +565,12 @@ def test_notify_with_filters(self, mock_send):
assert mock_send.call_count == 0

# What actually took place behind close doors:
assert apprise.plugins.SCHEMA_MAP['mailto'].enabled is False
assert \
apprise.common.NOTIFY_SCHEMA_MAP['mailto']\
.enabled is False

# Reset our flag (for next test)
apprise.plugins.SCHEMA_MAP['mailto'].enabled = True
apprise.common.NOTIFY_SCHEMA_MAP['mailto'].enabled = True

# Reset Mock
mock_send.reset_mock()
Expand All @@ -584,7 +590,8 @@ def test_notify_with_filters(self, mock_send):
assert mock_send.call_count == 1

# nothing was changed
assert apprise.plugins.SCHEMA_MAP['mailto'].enabled is True
assert \
apprise.common.NOTIFY_SCHEMA_MAP['mailto'].enabled is True

@override_settings(APPRISE_RECURSION_MAX=1)
@patch('apprise.Apprise.notify')
Expand Down
22 changes: 12 additions & 10 deletions apprise_api/api/tests/test_stateless_notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def test_partial_notify(self, mock_notify):
"""

# Ensure we're enabled for the purpose of our testing
apprise.plugins.SCHEMA_MAP['mailto'].enabled = True
apprise.common.NOTIFY_SCHEMA_MAP['mailto'].enabled = True

# Set our return value; first we return a true, then we fail
# on the second call
Expand Down Expand Up @@ -364,7 +364,7 @@ def test_notify_with_filters(self, mock_send):
)

# Ensure we're enabled for the purpose of our testing
apprise.plugins.SCHEMA_MAP['json'].enabled = True
apprise.common.NOTIFY_SCHEMA_MAP['json'].enabled = True

# Reset Mock
mock_send.reset_mock()
Expand All @@ -384,10 +384,11 @@ def test_notify_with_filters(self, mock_send):
assert mock_send.call_count == 0

# What actually took place behind close doors:
assert apprise.plugins.SCHEMA_MAP['json'].enabled is False
assert \
apprise.common.NOTIFY_SCHEMA_MAP['json'].enabled is False

# Reset our flag (for next test)
apprise.plugins.SCHEMA_MAP['json'].enabled = True
apprise.common.NOTIFY_SCHEMA_MAP['json'].enabled = True

# Reset Mock
mock_send.reset_mock()
Expand All @@ -407,7 +408,7 @@ def test_notify_with_filters(self, mock_send):
assert mock_send.call_count == 1

# Verify that json was never turned off
assert apprise.plugins.SCHEMA_MAP['json'].enabled is True
assert apprise.common.NOTIFY_SCHEMA_MAP['json'].enabled is True

# Reset Mock
mock_send.reset_mock()
Expand All @@ -427,7 +428,7 @@ def test_notify_with_filters(self, mock_send):
assert mock_send.call_count == 1

# Verify email was never turned off
assert apprise.plugins.SCHEMA_MAP['json'].enabled is True
assert apprise.common.NOTIFY_SCHEMA_MAP['json'].enabled is True

# Reset Mock
mock_send.reset_mock()
Expand All @@ -447,7 +448,7 @@ def test_notify_with_filters(self, mock_send):
assert mock_send.call_count == 1

# Verify email was never turned off
assert apprise.plugins.SCHEMA_MAP['json'].enabled is True
assert apprise.common.NOTIFY_SCHEMA_MAP['json'].enabled is True

# Reset Mock
mock_send.reset_mock()
Expand All @@ -467,10 +468,11 @@ def test_notify_with_filters(self, mock_send):
assert mock_send.call_count == 0

# What actually took place behind close doors:
assert apprise.plugins.SCHEMA_MAP['json'].enabled is False
assert \
apprise.common.NOTIFY_SCHEMA_MAP['json'].enabled is False

# Reset our flag (for next test)
apprise.plugins.SCHEMA_MAP['json'].enabled = True
apprise.common.NOTIFY_SCHEMA_MAP['json'].enabled = True

# Reset Mock
mock_send.reset_mock()
Expand All @@ -490,4 +492,4 @@ def test_notify_with_filters(self, mock_send):
assert mock_send.call_count == 1

# nothing was changed
assert apprise.plugins.SCHEMA_MAP['json'].enabled is True
assert apprise.common.NOTIFY_SCHEMA_MAP['json'].enabled is True
8 changes: 4 additions & 4 deletions apprise_api/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ def post(self, request, key):
for x in re.split(r'[ ,]+', settings.APPRISE_ALLOW_SERVICES)
if alphanum_re.match(x)]

for plugin in set(apprise.plugins.SCHEMA_MAP.values()):
for plugin in set(apprise.common.NOTIFY_SCHEMA_MAP.values()):
if entries:
# Get a list of the current schema's associated with
# a given plugin
Expand Down Expand Up @@ -646,7 +646,7 @@ def post(self, request, key):
for name in entries:
try:
# Force plugin to be disabled
apprise.plugins.SCHEMA_MAP[name].enabled = False
apprise.common.NOTIFY_SCHEMA_MAP[name].enabled = False

except KeyError:
logger.warning(
Expand Down Expand Up @@ -900,7 +900,7 @@ def post(self, request):
for x in re.split(r'[ ,]+', settings.APPRISE_ALLOW_SERVICES)
if alphanum_re.match(x)]

for plugin in set(apprise.plugins.SCHEMA_MAP.values()):
for plugin in set(apprise.common.NOTIFY_SCHEMA_MAP.values()):
if entries:
# Get a list of the current schema's associated with
# a given plugin
Expand Down Expand Up @@ -939,7 +939,7 @@ def post(self, request):
for name in entries:
try:
# Force plugin to be disabled
apprise.plugins.SCHEMA_MAP[name].enabled = False
apprise.common.NOTIFY_SCHEMA_MAP[name].enabled = False

except KeyError:
logger.warning(
Expand Down

0 comments on commit def1ded

Please sign in to comment.