mirror of
https://github.com/caronc/apprise.git
synced 2025-01-01 03:29:53 +01:00
code coverage updates
This commit is contained in:
parent
fe83c62669
commit
54cd566ab8
@ -220,16 +220,8 @@ class NotifyXMPP(NotifyBase):
|
|||||||
jid = self.jid
|
jid = self.jid
|
||||||
password = self.password
|
password = self.password
|
||||||
if not jid:
|
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)
|
jid = '{}@{}'.format(self.user, self.host)
|
||||||
|
|
||||||
if not self.password:
|
|
||||||
self.logger.error('You must specify a XMPP password')
|
|
||||||
return False
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Communicate with XMPP.
|
# Communicate with XMPP.
|
||||||
xmpp_adapter = self._adapter(
|
xmpp_adapter = self._adapter(
|
||||||
@ -270,16 +262,10 @@ class NotifyXMPP(NotifyBase):
|
|||||||
|
|
||||||
default_schema = self.secure_protocol if self.secure else self.protocol
|
default_schema = self.secure_protocol if self.secure else self.protocol
|
||||||
|
|
||||||
if self.user and self.password:
|
auth = '{user}:{password}'.format(
|
||||||
auth = '{user}:{password}'.format(
|
user=NotifyXMPP.quote(self.user, safe=''),
|
||||||
user=NotifyXMPP.quote(self.user, safe=''),
|
password=self.pprint(
|
||||||
password=self.pprint(
|
self.password, privacy, mode=PrivacyMode.Secret, safe=''))
|
||||||
self.password, privacy, mode=PrivacyMode.Secret, safe=''))
|
|
||||||
|
|
||||||
else:
|
|
||||||
auth = self.pprint(
|
|
||||||
self.password if self.password else self.user, privacy,
|
|
||||||
mode=PrivacyMode.Secret, safe='')
|
|
||||||
|
|
||||||
return '{schema}://{auth}@{hostname}{port}/{jids}?{params}'.format(
|
return '{schema}://{auth}@{hostname}{port}/{jids}?{params}'.format(
|
||||||
auth=auth,
|
auth=auth,
|
||||||
|
@ -508,7 +508,7 @@ def requirements(plugin):
|
|||||||
# Get our package details
|
# Get our package details
|
||||||
_req_details = plugin.requirements.get('details')
|
_req_details = plugin.requirements.get('details')
|
||||||
if not _req_details:
|
if not _req_details:
|
||||||
if not (_req_packages and _opt_packages):
|
if not (_req_packages or _opt_packages):
|
||||||
_req_details = _('No dependencies.')
|
_req_details = _('No dependencies.')
|
||||||
|
|
||||||
elif _req_packages:
|
elif _req_packages:
|
||||||
|
@ -1316,6 +1316,28 @@ def test_apprise_details():
|
|||||||
|
|
||||||
SCHEMA_MAP['req04'] = TestReq04Notification
|
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
|
# Create our Apprise instance
|
||||||
a = Apprise()
|
a = Apprise()
|
||||||
|
|
||||||
@ -1699,20 +1721,20 @@ def test_apprise_details_plugin_verification():
|
|||||||
if arg not in function_args:
|
if arg not in function_args:
|
||||||
# This print statement just makes the error easier to
|
# This print statement just makes the error easier to
|
||||||
# troubleshoot
|
# troubleshoot
|
||||||
print('{}:// template/arg/func reference missing error.'
|
raise AssertionError(
|
||||||
.format(protocols[0]))
|
'{}.__init__() expects a {}=None entry according to '
|
||||||
assert arg in function_args
|
'template configuration'
|
||||||
|
.format(SCHEMA_MAP[protocols[0]].__name__, arg))
|
||||||
|
|
||||||
# Iterate over all of the function arguments and make sure that
|
# Iterate over all of the function arguments and make sure that
|
||||||
# it maps back to a key
|
# it maps back to a key
|
||||||
function_args -= valid_kwargs
|
function_args -= valid_kwargs
|
||||||
for arg in function_args:
|
for arg in function_args:
|
||||||
if arg not in map_to_entries:
|
if arg not in map_to_entries:
|
||||||
# This print statement just makes the error easier to
|
raise AssertionError(
|
||||||
# troubleshoot
|
'{}.__init__({}) found but not defined in the '
|
||||||
print('{}:// template/func/arg reference missing error.'
|
'template configuration'
|
||||||
.format(protocols[0]))
|
.format(SCHEMA_MAP[protocols[0]].__name__, arg))
|
||||||
assert arg in map_to_entries
|
|
||||||
|
|
||||||
# Iterate over our map_to_aliases and make sure they were defined in
|
# Iterate over our map_to_aliases and make sure they were defined in
|
||||||
# either the as a token or arg
|
# either the as a token or arg
|
||||||
|
@ -682,7 +682,7 @@ def test_apprise_cli_details(tmpdir):
|
|||||||
This class is used to test various requirement configurations
|
This class is used to test various requirement configurations
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Set some requirements
|
# Set some requirements (but additionally include a details over-ride)
|
||||||
requirements = {
|
requirements = {
|
||||||
# We can over-ride the default details assigned to our plugin if
|
# We can over-ride the default details assigned to our plugin if
|
||||||
# specified
|
# specified
|
||||||
@ -702,6 +702,47 @@ def test_apprise_cli_details(tmpdir):
|
|||||||
|
|
||||||
SCHEMA_MAP['req03'] = TestReq03Notification
|
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):
|
class TestDisabled01Notification(NotifyBase):
|
||||||
"""
|
"""
|
||||||
This class is used to test a pre-disabled state
|
This class is used to test a pre-disabled state
|
||||||
|
Loading…
Reference in New Issue
Block a user