From 2f96710c413d85ec2c6ecaf8548eb49a99321234 Mon Sep 17 00:00:00 2001 From: Chris Caron Date: Fri, 4 Oct 2024 16:29:09 -0400 Subject: [PATCH 1/2] type-o in matrix test case --- test/test_plugin_matrix.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_plugin_matrix.py b/test/test_plugin_matrix.py index c8f344ef..7e6299ba 100644 --- a/test/test_plugin_matrix.py +++ b/test/test_plugin_matrix.py @@ -1402,7 +1402,7 @@ def test_plugin_matrix_transaction_ids_api_v3_no_cache( # Instantiate our object obj = Apprise.instantiate('matrix://user:pass@localhost/#general?v=3') - # Ensure mode is flush + # Ensure mode is memory assert obj.store.mode == PersistentStoreMode.MEMORY # Performs a login From 981f1ece8bc238cd06df4486ac9fa294700727e2 Mon Sep 17 00:00:00 2001 From: Chris Caron Date: Sun, 9 Mar 2025 20:33:29 -0400 Subject: [PATCH 2/2] More code cleanup --- apprise/plugins/nextcloudtalk.py | 2 +- apprise/plugins/twitter.py | 12 +++++++----- test/test_plugin_twitter.py | 10 ++++++---- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/apprise/plugins/nextcloudtalk.py b/apprise/plugins/nextcloudtalk.py index 3d5fc4d5..d7b8d2ba 100644 --- a/apprise/plugins/nextcloudtalk.py +++ b/apprise/plugins/nextcloudtalk.py @@ -127,7 +127,7 @@ class NotifyNextcloudTalk(NotifyBase): super().__init__(**kwargs) if self.user is None or self.password is None: - msg = 'User and password have to be specified.' + msg = 'A NextCloudTalk User and Password must be specified.' self.logger.warning(msg) raise TypeError(msg) diff --git a/apprise/plugins/twitter.py b/apprise/plugins/twitter.py index f6b5511a..c71a5cbd 100644 --- a/apprise/plugins/twitter.py +++ b/apprise/plugins/twitter.py @@ -268,9 +268,7 @@ class NotifyTwitter(NotifyBase): # and we failed to load any of them. Since it's also valid to # notify no one at all (which means we notify ourselves), it's # important we don't switch from the users original intentions - msg = 'No Twitter targets to notify.' - self.logger.warning(msg) - raise TypeError(msg) + self.targets = None # Initialize our cache values self._whoami_cache = None @@ -284,6 +282,10 @@ class NotifyTwitter(NotifyBase): Perform Twitter Notification """ + if self.targets is None: + self.logger.warning('No valid Twitter targets to notify.') + return False + # Build a list of our attachments attachments = [] @@ -815,7 +817,7 @@ class NotifyTwitter(NotifyBase): params.update(self.url_parameters(privacy=privacy, *args, **kwargs)) return '{schema}://{ckey}/{csecret}/{akey}/{asecret}' \ - '/{targets}/?{params}'.format( + '/{targets}?{params}'.format( schema=self.secure_protocol[0], ckey=self.pprint(self.ckey, privacy, safe=''), csecret=self.pprint( @@ -825,7 +827,7 @@ class NotifyTwitter(NotifyBase): self.asecret, privacy, mode=PrivacyMode.Secret, safe=''), targets='/'.join( [NotifyTwitter.quote('@{}'.format(target), safe='@') - for target in self.targets]), + for target in self.targets]) if self.targets else '', params=NotifyTwitter.urlencode(params)) def __len__(self): diff --git a/test/test_plugin_twitter.py b/test/test_plugin_twitter.py index 792c904f..e84ca56e 100644 --- a/test/test_plugin_twitter.py +++ b/test/test_plugin_twitter.py @@ -521,10 +521,12 @@ def test_plugin_twitter_edge_cases(): ) # Invalid Target User - with pytest.raises(TypeError): - NotifyTwitter( - ckey='value', csecret='value', akey='value', asecret='value', - targets='%G@rB@g3') + obj = NotifyTwitter( + ckey='value', csecret='value', akey='value', asecret='value', + targets='%G@rB@g3') + + assert obj.notify( + body='body', title='title', notify_type=NotifyType.INFO) is False def test_plugin_twitter_dm_caching(