From 8f87364023b6df3b58596e4346a2a34f51fd02c8 Mon Sep 17 00:00:00 2001 From: Chris Caron Date: Sat, 17 Feb 2024 19:30:14 -0500 Subject: [PATCH] Discord test case enhancement and code fix (dupe entry) --- apprise/plugins/NotifyTelegram.py | 3 +-- test/test_plugin_discord.py | 7 ++++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/apprise/plugins/NotifyTelegram.py b/apprise/plugins/NotifyTelegram.py index 03bc36c6..dbea79b1 100644 --- a/apprise/plugins/NotifyTelegram.py +++ b/apprise/plugins/NotifyTelegram.py @@ -297,7 +297,6 @@ class NotifyTelegram(NotifyBase): 'name': _('Target Chat ID'), 'type': 'string', 'map_to': 'targets', - 'map_to': 'targets', 'regex': (r'^((-?[0-9]{1,32})|([a-z_-][a-z0-9_-]+))$', 'i'), }, 'targets': { @@ -916,7 +915,7 @@ class NotifyTelegram(NotifyBase): """ Returns the number of targets associated with this notification """ - return len(self.targets) + return 1 if not self.targets else len(self.targets) @staticmethod def parse_url(url): diff --git a/test/test_plugin_discord.py b/test/test_plugin_discord.py index 848c7c31..ea634c3b 100644 --- a/test/test_plugin_discord.py +++ b/test/test_plugin_discord.py @@ -298,14 +298,19 @@ def test_plugin_discord_notifications(mock_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 """ + # Prevent throttling + mock_sleep.return_value = True + # Turn off clock skew for local testing NotifyDiscord.clock_skew = timedelta(seconds=0) + # Epoch time: epoch = datetime.fromtimestamp(0, timezone.utc)