Skip to content

Commit

Permalink
fixed test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
caronc committed Aug 12, 2023
1 parent 5b6ea2d commit 6fc4225
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 12 deletions.
24 changes: 12 additions & 12 deletions apprise/plugins/NotifyBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,18 @@ def _build_send_calls(self, body=None, title=None,
self.logger.warning(msg)
raise TypeError(msg)

if not body and not self.attachment_support:
# If no body was specified, then we know that an attachment
# was. This is logic checked earlier in the code.
#
# Knowing this, if the plugin itself doesn't support sending
# attachments, there is nothing further to do here, just move
# along.
msg = f"{self.service_name} does not support attachments; " \
" service skipped"
self.logger.warning(msg)
raise TypeError(msg)

# Handle situations where the title is None
title = '' if not title else title

Expand All @@ -369,18 +381,6 @@ def _build_send_calls(self, body=None, title=None,
body=body, title=title, overflow=overflow,
body_format=body_format):

if not body and not self.attachment_support:
# If no body was specified, then we know that an attachment
# was. This is logic checked earlier in the code.
#
# Knowing this, if the plugin itself doesn't support sending
# attachments, there is nothing further to do here, just move
# along.
self.logger.warning(
f"{self.service_name} does not support attachments; "
" service skipped")
continue

# Send notification
yield dict(
body=chunk['body'], title=chunk['title'],
Expand Down
23 changes: 23 additions & 0 deletions test/helpers/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,13 +493,36 @@ def __notify(self, url, obj, meta, asset, mock_patch, mock_del, mock_put,
# have ot test against this flag is ran
obj.attachment_support = False

#
# Notifications should still transmit as normal if
# Attachment support is flipped off
#
assert obj.notify(
body=self.body, title=self.title,
notify_type=notify_type,
attach=attach) == notify_response

#
# We should not be able to send a message without a
# body or title in this circumstance
#
assert obj.notify(
body=None, title=None,
notify_type=notify_type,
attach=attach) is False

# Toggle Back
obj.attachment_support = True

else: # No Attachment support
#
# We should not be able to send a message without a
# body or title in this circumstance
#
assert obj.notify(
body=None, title=None,
notify_type=notify_type,
attach=attach) is False
else:

for _exception in self.req_exceptions:
Expand Down

0 comments on commit 6fc4225

Please sign in to comment.