diff --git a/apprise/plugins/NotifyMatterMost.py b/apprise/plugins/NotifyMatterMost.py index 24c8b1e2..b9821438 100644 --- a/apprise/plugins/NotifyMatterMost.py +++ b/apprise/plugins/NotifyMatterMost.py @@ -116,10 +116,7 @@ class NotifyMatterMost(NotifyBase): if self.channel: payload['channel'] = self.channel - url = '%s://%s' % (self.schema, self.host) - if isinstance(self.port, int): - url += ':%d' % self.port - + url = '%s://%s:%d' % (self.schema, self.host, self.port) url += '/hooks/%s' % self.authtoken self.logger.debug('MatterMost POST URL: %s (cert_verify=%r)' % ( @@ -153,7 +150,7 @@ class NotifyMatterMost(NotifyBase): else: self.logger.info('Sent MatterMost notification.') - except requests.ConnectionError as e: + except requests.RequestException as e: self.logger.warning( 'A Connection error occured sending MatterMost ' 'notification.' @@ -190,15 +187,7 @@ class NotifyMatterMost(NotifyBase): channel = None if 'channel' in results['qsd'] and len(results['qsd']['channel']): # Allow the user to specify the channel to post to - try: - channel = NotifyBase.unquote(results['qsd']['channel']).strip() - - except (AttributeError, TypeError, ValueError): - NotifyBase.logger.warning( - 'An invalid MatterMost channel of "%s" was specified and ' - 'will be ignored.' % results['qsd']['channel'] - ) - pass + channel = NotifyBase.unquote(results['qsd']['channel']).strip() results['authtoken'] = authtoken results['channel'] = channel diff --git a/test/test_plugins.py b/test/test_plugins.py index 04a86f2d..c98e2a2d 100644 --- a/test/test_plugins.py +++ b/test/test_plugins.py @@ -30,6 +30,9 @@ VALID_URLS = ( ('json://', { 'instance': None, }), + ('jsons://', { + 'instance': None, + }), ('json://localhost', { 'instance': plugins.NotifyJSON, }), @@ -71,7 +74,63 @@ VALID_URLS = ( # Throws a series of connection and transfer exceptions when this flag # is set and tests that we gracfully handle them 'test_requests_exceptions': True, - }) + }), + + ################################## + # NotifyMatterMost + ################################## + ('mmost://', { + 'instance': None, + }), + ('mmosts://', { + 'instance': None, + }), + ('mmost://localhost/3ccdd113474722377935511fc85d3dd4', { + 'instance': plugins.NotifyMatterMost, + }), + ('mmost://user@localhost/3ccdd113474722377935511fc85d3dd4?channel=test', { + 'instance': plugins.NotifyMatterMost, + }), + ('mmost://localhost:8080/3ccdd113474722377935511fc85d3dd4', { + 'instance': plugins.NotifyMatterMost, + }), + ('mmost://localhost:0/3ccdd113474722377935511fc85d3dd4', { + 'instance': plugins.NotifyMatterMost, + }), + ('mmost://localhost:invalid-port/3ccdd113474722377935511fc85d3dd4', { + 'instance': None, + }), + ('mmosts://localhost/3ccdd113474722377935511fc85d3dd4', { + 'instance': plugins.NotifyMatterMost, + }), + ('mmosts://localhost', { + 'instance': plugins.NotifyMatterMost, + # Thrown because there was no webhook id specified + 'exception': TypeError, + }), + ('mmost://localhost/bad-web-hook', { + 'instance': plugins.NotifyMatterMost, + # Thrown because the webhook is not in a valid format + 'exception': TypeError, + }), + ('mmost://localhost/3ccdd113474722377935511fc85d3dd4', { + 'instance': plugins.NotifyMatterMost, + # force a failure + 'response': False, + 'requests_response_code': 500, + }), + ('mmost://localhost/3ccdd113474722377935511fc85d3dd4', { + 'instance': plugins.NotifyMatterMost, + # throw a bizzare code forcing us to fail to look it up + 'response': False, + 'requests_response_code': 999, + }), + ('mmost://localhost/3ccdd113474722377935511fc85d3dd4', { + 'instance': plugins.NotifyMatterMost, + # Throws a series of connection and transfer exceptions when this flag + # is set and tests that we gracfully handle them + 'test_requests_exceptions': True, + }), )