Discord test case enhancement and code fix (dupe entry)

pull/1064/head
Chris Caron 10 months ago committed by GitHub
parent 119b4f06e5
commit 8f87364023
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -297,7 +297,6 @@ class NotifyTelegram(NotifyBase):
'name': _('Target Chat ID'), 'name': _('Target Chat ID'),
'type': 'string', 'type': 'string',
'map_to': 'targets', 'map_to': 'targets',
'map_to': 'targets',
'regex': (r'^((-?[0-9]{1,32})|([a-z_-][a-z0-9_-]+))$', 'i'), 'regex': (r'^((-?[0-9]{1,32})|([a-z_-][a-z0-9_-]+))$', 'i'),
}, },
'targets': { 'targets': {
@ -916,7 +915,7 @@ class NotifyTelegram(NotifyBase):
""" """
Returns the number of targets associated with this notification Returns the number of targets associated with this notification
""" """
return len(self.targets) return 1 if not self.targets else len(self.targets)
@staticmethod @staticmethod
def parse_url(url): def parse_url(url):

@ -298,14 +298,19 @@ def test_plugin_discord_notifications(mock_post):
@mock.patch('requests.post') @mock.patch('requests.post')
def test_plugin_discord_general(mock_post): @mock.patch('time.sleep')
def test_plugin_discord_general(mock_sleep, mock_post):
""" """
NotifyDiscord() General Checks NotifyDiscord() General Checks
""" """
# Prevent throttling
mock_sleep.return_value = True
# Turn off clock skew for local testing # Turn off clock skew for local testing
NotifyDiscord.clock_skew = timedelta(seconds=0) NotifyDiscord.clock_skew = timedelta(seconds=0)
# Epoch time: # Epoch time:
epoch = datetime.fromtimestamp(0, timezone.utc) epoch = datetime.fromtimestamp(0, timezone.utc)

Loading…
Cancel
Save