mirror of https://github.com/caronc/apprise
test coverage
parent
70b747cb91
commit
3f099930b7
|
@ -28,15 +28,15 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from .NotifyBase import NotifyBase
|
from .base import NotifyBase
|
||||||
from ..URLBase import PrivacyMode
|
from ..url import PrivacyMode
|
||||||
from ..common import NotifyType
|
from ..common import NotifyType
|
||||||
from ..utils import is_phone_no
|
from ..utils import is_phone_no
|
||||||
from ..utils import is_email
|
from ..utils import is_email
|
||||||
from ..utils import parse_phone_no
|
from ..utils import parse_phone_no
|
||||||
from ..utils import parse_bool
|
from ..utils import parse_bool
|
||||||
from ..utils import validate_regex
|
from ..utils import validate_regex
|
||||||
from ..AppriseLocale import gettext_lazy as _
|
from ..locale import gettext_lazy as _
|
||||||
|
|
||||||
|
|
||||||
# Octopush Message Types
|
# Octopush Message Types
|
||||||
|
@ -293,7 +293,7 @@ class NotifyOctopush(NotifyBase):
|
||||||
# Prepare our headers
|
# Prepare our headers
|
||||||
headers = {
|
headers = {
|
||||||
'User-Agent': self.app_id,
|
'User-Agent': self.app_id,
|
||||||
'Accept': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'api-key': self.api_key,
|
'api-key': self.api_key,
|
||||||
'api-login': self.api_login,
|
'api-login': self.api_login,
|
||||||
'cache-control': 'no-cache',
|
'cache-control': 'no-cache',
|
||||||
|
@ -341,7 +341,9 @@ class NotifyOctopush(NotifyBase):
|
||||||
timeout=self.request_timeout,
|
timeout=self.request_timeout,
|
||||||
)
|
)
|
||||||
|
|
||||||
if r.status_code != requests.codes.ok:
|
if r.status_code not in (
|
||||||
|
requests.codes.ok, requests.codes.created):
|
||||||
|
|
||||||
# We had a problem
|
# We had a problem
|
||||||
status_str = \
|
status_str = \
|
||||||
NotifyBase.http_response_code_lookup(
|
NotifyBase.http_response_code_lookup(
|
||||||
|
@ -380,6 +382,17 @@ class NotifyOctopush(NotifyBase):
|
||||||
|
|
||||||
return not has_error
|
return not has_error
|
||||||
|
|
||||||
|
@property
|
||||||
|
def url_identifier(self):
|
||||||
|
"""
|
||||||
|
Returns all of the identifiers that make this URL unique from
|
||||||
|
another simliar one. Targets or end points should never be identified
|
||||||
|
here.
|
||||||
|
"""
|
||||||
|
return (
|
||||||
|
self.secure_protocol, self.api_login, self.api_key, self.mtype,
|
||||||
|
)
|
||||||
|
|
||||||
def url(self, privacy=False, *args, **kwargs):
|
def url(self, privacy=False, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
Returns the URL built dynamically based on specified arguments.
|
Returns the URL built dynamically based on specified arguments.
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
# THE SOFTWARE.
|
# THE SOFTWARE.
|
||||||
from apprise import plugins
|
from apprise.plugins.octopush import NotifyOctopush
|
||||||
from helpers import AppriseURLTester
|
from helpers import AppriseURLTester
|
||||||
|
|
||||||
# Disable logging for a cleaner testing output
|
# Disable logging for a cleaner testing output
|
||||||
|
@ -57,25 +57,25 @@ apprise_url_tests = (
|
||||||
}),
|
}),
|
||||||
('octopush://user@myaccount.com/apikey', {
|
('octopush://user@myaccount.com/apikey', {
|
||||||
# All valid entries, but no target phone numbers defined
|
# All valid entries, but no target phone numbers defined
|
||||||
'instance': plugins.NotifyOctopush.NotifyOctopush,
|
'instance': NotifyOctopush,
|
||||||
'response': False,
|
'response': False,
|
||||||
}),
|
}),
|
||||||
('octopush://user@myaccount.com/apikey/+0987654321', {
|
('octopush://user@myaccount.com/apikey/+0987654321', {
|
||||||
# A valid url
|
# A valid url
|
||||||
'instance': plugins.NotifyOctopush.NotifyOctopush,
|
'instance': NotifyOctopush,
|
||||||
# Our expected url(privacy=True) startswith() response:
|
# Our expected url(privacy=True) startswith() response:
|
||||||
'privacy_url': 'octopush://u...m/****/+0987654321',
|
'privacy_url': 'octopush://u...m/****/+0987654321',
|
||||||
}),
|
}),
|
||||||
('octopush://sender:user@myaccount.com/apikey/+1111111111', {
|
('octopush://sender:user@myaccount.com/apikey/+1111111111', {
|
||||||
# A valid url with sender
|
# A valid url with sender
|
||||||
'instance': plugins.NotifyOctopush.NotifyOctopush,
|
'instance': NotifyOctopush,
|
||||||
# Our expected url(privacy=True) startswith() response:
|
# Our expected url(privacy=True) startswith() response:
|
||||||
'privacy_url': 'octopush://sender:u...m/****/+1111111111',
|
'privacy_url': 'octopush://sender:u...m/****/+1111111111',
|
||||||
}),
|
}),
|
||||||
('octopush://?login=user@myaccount.com&key=key&to=9999999999'
|
('octopush://?login=user@myaccount.com&key=key&to=9999999999'
|
||||||
'&purpose=wholesale', {
|
'&purpose=wholesale', {
|
||||||
# Testing valid purpose change
|
# Testing valid purpose change
|
||||||
'instance': plugins.NotifyOctopush.NotifyOctopush}),
|
'instance': NotifyOctopush}),
|
||||||
('octopush://?login=user@myaccount.com&key=key&to=9999999999'
|
('octopush://?login=user@myaccount.com&key=key&to=9999999999'
|
||||||
'&purpose=invalid', {
|
'&purpose=invalid', {
|
||||||
# Testing invalid purpose change
|
# Testing invalid purpose change
|
||||||
|
@ -83,33 +83,33 @@ apprise_url_tests = (
|
||||||
('octopush://?login=user@myaccount.com&key=key&to=9999999999'
|
('octopush://?login=user@myaccount.com&key=key&to=9999999999'
|
||||||
'&type=premium', {
|
'&type=premium', {
|
||||||
# Testing valid type change
|
# Testing valid type change
|
||||||
'instance': plugins.NotifyOctopush.NotifyOctopush}),
|
'instance': NotifyOctopush}),
|
||||||
('octopush://?login=user@myaccount.com&key=key&to=9999999999'
|
('octopush://?login=user@myaccount.com&key=key&to=9999999999'
|
||||||
'&type=invalid', {
|
'&type=invalid', {
|
||||||
# Testing invalid type change
|
# Testing invalid type change
|
||||||
'instance': TypeError}),
|
'instance': TypeError}),
|
||||||
('octopush://user@myaccount.com/apikey/+3333333333?replies=yes', {
|
('octopush://user@myaccount.com/apikey/+3333333333?replies=yes', {
|
||||||
# Test replies
|
# Test replies
|
||||||
'instance': plugins.NotifyOctopush.NotifyOctopush,
|
'instance': NotifyOctopush,
|
||||||
}),
|
}),
|
||||||
('octopush://sender:user@myaccount.com/apikey/{}/{}/{}/?batch=yes'.format(
|
('octopush://sender:user@myaccount.com/apikey/{}/{}/{}/?batch=yes'.format(
|
||||||
'1' * 10, '2' * 3, '3' * 11), {
|
'1' * 10, '2' * 3, '3' * 11), {
|
||||||
# batch mode, 2 valid targets (1 is invalid and skipped)
|
# batch mode, 2 valid targets (1 is invalid and skipped)
|
||||||
'instance': plugins.NotifyOctopush.NotifyOctopush}),
|
'instance': NotifyOctopush}),
|
||||||
('octopush://_?key=abc123&login=user@myaccount&sender=abc&to=2222222222', {
|
('octopush://_?key=abc123&login=user@myaccount&sender=abc&to=2222222222', {
|
||||||
# use get args to acomplish the same thing
|
# use get args to acomplish the same thing
|
||||||
'instance': plugins.NotifyOctopush.NotifyOctopush,
|
'instance': NotifyOctopush,
|
||||||
# Our expected url(privacy=True) startswith() response:
|
# Our expected url(privacy=True) startswith() response:
|
||||||
'privacy_url': 'octopush://abc:u...t/****/+2222222222',
|
'privacy_url': 'octopush://abc:u...t/****/+2222222222',
|
||||||
}),
|
}),
|
||||||
('octopush://user@myaccount.com/apikey/1234567890', {
|
('octopush://user@myaccount.com/apikey/1234567890', {
|
||||||
'instance': plugins.NotifyOctopush.NotifyOctopush,
|
'instance': NotifyOctopush,
|
||||||
# throw a bizzare code forcing us to fail to look it up
|
# throw a bizzare code forcing us to fail to look it up
|
||||||
'response': False,
|
'response': False,
|
||||||
'requests_response_code': 999,
|
'requests_response_code': 999,
|
||||||
}),
|
}),
|
||||||
('octopush://user@myaccount.com/apikey/1234567890', {
|
('octopush://user@myaccount.com/apikey/1234567890', {
|
||||||
'instance': plugins.NotifyOctopush.NotifyOctopush,
|
'instance': NotifyOctopush,
|
||||||
# Throws a series of connection and transfer exceptions when this flag
|
# Throws a series of connection and transfer exceptions when this flag
|
||||||
# is set and tests that we gracfully handle them
|
# is set and tests that we gracfully handle them
|
||||||
'test_requests_exceptions': True,
|
'test_requests_exceptions': True,
|
||||||
|
|
Loading…
Reference in New Issue