From 9c8397319e995fe8733685fed53a788c42e0efdc Mon Sep 17 00:00:00 2001 From: Chris Caron Date: Sat, 1 Jul 2023 13:00:41 -0400 Subject: [PATCH] updated to fit with recent global changes --- apprise/plugins/NotifyOctopush.py | 7 +++++++ test/test_plugin_octopush.py | 20 ++++++++++---------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/apprise/plugins/NotifyOctopush.py b/apprise/plugins/NotifyOctopush.py index f23fcb9693..85f6383485 100644 --- a/apprise/plugins/NotifyOctopush.py +++ b/apprise/plugins/NotifyOctopush.py @@ -141,6 +141,7 @@ class NotifyOctopush(NotifyBase): 'targets': { 'name': _('Targets'), 'type': 'list:string', + 'required': True, }, }) @@ -409,6 +410,12 @@ def url(self, privacy=False, *args, **kwargs): params=NotifyOctopush.urlencode(params), ) + def __len__(self): + """ + Returns the number of targets associated with this notification + """ + return len(self.targets) + @staticmethod def parse_url(url): """ diff --git a/test/test_plugin_octopush.py b/test/test_plugin_octopush.py index c58ca2179b..0cfdee2967 100644 --- a/test/test_plugin_octopush.py +++ b/test/test_plugin_octopush.py @@ -57,25 +57,25 @@ }), ('octopush://user@myaccount.com/apikey', { # All valid entries, but no target phone numbers defined - 'instance': plugins.NotifyOctopush, + 'instance': plugins.NotifyOctopush.NotifyOctopush, 'response': False, }), ('octopush://user@myaccount.com/apikey/+0987654321', { # A valid url - 'instance': plugins.NotifyOctopush, + 'instance': plugins.NotifyOctopush.NotifyOctopush, # Our expected url(privacy=True) startswith() response: 'privacy_url': 'octopush://u...m/****/+0987654321', }), ('octopush://sender:user@myaccount.com/apikey/+1111111111', { # A valid url with sender - 'instance': plugins.NotifyOctopush, + 'instance': plugins.NotifyOctopush.NotifyOctopush, # Our expected url(privacy=True) startswith() response: 'privacy_url': 'octopush://sender:u...m/****/+1111111111', }), ('octopush://?login=user@myaccount.com&key=key&to=9999999999' '&purpose=wholesale', { # Testing valid purpose change - 'instance': plugins.NotifyOctopush}), + 'instance': plugins.NotifyOctopush.NotifyOctopush}), ('octopush://?login=user@myaccount.com&key=key&to=9999999999' '&purpose=invalid', { # Testing invalid purpose change @@ -83,33 +83,33 @@ ('octopush://?login=user@myaccount.com&key=key&to=9999999999' '&type=premium', { # Testing valid type change - 'instance': plugins.NotifyOctopush}), + 'instance': plugins.NotifyOctopush.NotifyOctopush}), ('octopush://?login=user@myaccount.com&key=key&to=9999999999' '&type=invalid', { # Testing invalid type change 'instance': TypeError}), ('octopush://user@myaccount.com/apikey/+3333333333?replies=yes', { # Test replies - 'instance': plugins.NotifyOctopush, + 'instance': plugins.NotifyOctopush.NotifyOctopush, }), ('octopush://sender:user@myaccount.com/apikey/{}/{}/{}/?batch=yes'.format( '1' * 10, '2' * 3, '3' * 11), { # batch mode, 2 valid targets (1 is invalid and skipped) - 'instance': plugins.NotifyOctopush}), + 'instance': plugins.NotifyOctopush.NotifyOctopush}), ('octopush://_?key=abc123&login=user@myaccount&sender=abc&to=2222222222', { # use get args to acomplish the same thing - 'instance': plugins.NotifyOctopush, + 'instance': plugins.NotifyOctopush.NotifyOctopush, # Our expected url(privacy=True) startswith() response: 'privacy_url': 'octopush://abc:u...t/****/+2222222222', }), ('octopush://user@myaccount.com/apikey/1234567890', { - 'instance': plugins.NotifyOctopush, + 'instance': plugins.NotifyOctopush.NotifyOctopush, # throw a bizzare code forcing us to fail to look it up 'response': False, 'requests_response_code': 999, }), ('octopush://user@myaccount.com/apikey/1234567890', { - 'instance': plugins.NotifyOctopush, + 'instance': plugins.NotifyOctopush.NotifyOctopush, # Throws a series of connection and transfer exceptions when this flag # is set and tests that we gracfully handle them 'test_requests_exceptions': True,