Browse Source

code coverage updates

pull/492/head
Chris Caron 3 years ago
parent
commit
54cd566ab8
  1. 22
      apprise/plugins/NotifyXMPP/__init__.py
  2. 2
      apprise/plugins/__init__.py
  3. 38
      test/test_api.py
  4. 43
      test/test_cli.py

22
apprise/plugins/NotifyXMPP/__init__.py

@ -220,16 +220,8 @@ class NotifyXMPP(NotifyBase):
jid = self.jid
password = self.password
if not jid:
if not self.user:
self.logger.error(
'Invalid JID, must be of the form username@server.')
return False
jid = '{}@{}'.format(self.user, self.host)
if not self.password:
self.logger.error('You must specify a XMPP password')
return False
try:
# Communicate with XMPP.
xmpp_adapter = self._adapter(
@ -270,16 +262,10 @@ class NotifyXMPP(NotifyBase):
default_schema = self.secure_protocol if self.secure else self.protocol
if self.user and self.password:
auth = '{user}:{password}'.format(
user=NotifyXMPP.quote(self.user, safe=''),
password=self.pprint(
self.password, privacy, mode=PrivacyMode.Secret, safe=''))
else:
auth = self.pprint(
self.password if self.password else self.user, privacy,
mode=PrivacyMode.Secret, safe='')
auth = '{user}:{password}'.format(
user=NotifyXMPP.quote(self.user, safe=''),
password=self.pprint(
self.password, privacy, mode=PrivacyMode.Secret, safe=''))
return '{schema}://{auth}@{hostname}{port}/{jids}?{params}'.format(
auth=auth,

2
apprise/plugins/__init__.py

@ -508,7 +508,7 @@ def requirements(plugin):
# Get our package details
_req_details = plugin.requirements.get('details')
if not _req_details:
if not (_req_packages and _opt_packages):
if not (_req_packages or _opt_packages):
_req_details = _('No dependencies.')
elif _req_packages:

38
test/test_api.py

@ -1316,6 +1316,28 @@ def test_apprise_details():
SCHEMA_MAP['req04'] = TestReq04Notification
# This is a made up class that is just used to verify
class TestReq05Notification(NotifyBase):
"""
This class is used to test a case where only packages_recommended
is identified
"""
requirements = {
# We can set a string value as well (it does not have to be a list)
'packages_recommended': 'cryptography <= 3.4'
}
def url(self, **kwargs):
# Support URL
return ''
def send(self, **kwargs):
# Pretend everything is okay (so we don't break other tests)
return True
SCHEMA_MAP['req05'] = TestReq05Notification
# Create our Apprise instance
a = Apprise()
@ -1699,20 +1721,20 @@ def test_apprise_details_plugin_verification():
if arg not in function_args:
# This print statement just makes the error easier to
# troubleshoot
print('{}:// template/arg/func reference missing error.'
.format(protocols[0]))
assert arg in function_args
raise AssertionError(
'{}.__init__() expects a {}=None entry according to '
'template configuration'
.format(SCHEMA_MAP[protocols[0]].__name__, arg))
# Iterate over all of the function arguments and make sure that
# it maps back to a key
function_args -= valid_kwargs
for arg in function_args:
if arg not in map_to_entries:
# This print statement just makes the error easier to
# troubleshoot
print('{}:// template/func/arg reference missing error.'
.format(protocols[0]))
assert arg in map_to_entries
raise AssertionError(
'{}.__init__({}) found but not defined in the '
'template configuration'
.format(SCHEMA_MAP[protocols[0]].__name__, arg))
# Iterate over our map_to_aliases and make sure they were defined in
# either the as a token or arg

43
test/test_cli.py

@ -682,7 +682,7 @@ def test_apprise_cli_details(tmpdir):
This class is used to test various requirement configurations
"""
# Set some requirements
# Set some requirements (but additionally include a details over-ride)
requirements = {
# We can over-ride the default details assigned to our plugin if
# specified
@ -702,6 +702,47 @@ def test_apprise_cli_details(tmpdir):
SCHEMA_MAP['req03'] = TestReq03Notification
# This is a made up class that is just used to verify
class TestReq04Notification(NotifyBase):
"""
This class is used to test a case where our requirements is fixed
to a None
"""
# This is the same as saying there are no requirements
requirements = None
def url(self, **kwargs):
# Support URL
return ''
def send(self, **kwargs):
# Pretend everything is okay (so we don't break other tests)
return True
SCHEMA_MAP['req04'] = TestReq04Notification
# This is a made up class that is just used to verify
class TestReq05Notification(NotifyBase):
"""
This class is used to test a case where only packages_recommended
is identified
"""
requirements = {
'packages_recommended': 'cryptography <= 3.4'
}
def url(self, **kwargs):
# Support URL
return ''
def send(self, **kwargs):
# Pretend everything is okay (so we don't break other tests)
return True
SCHEMA_MAP['req05'] = TestReq04Notification
class TestDisabled01Notification(NotifyBase):
"""
This class is used to test a pre-disabled state

Loading…
Cancel
Save