mirror of https://github.com/caronc/apprise
Use unicode responses recieved from Amazon (#320)
parent
3531912991
commit
2c2722f61f
|
@ -361,7 +361,7 @@ class NotifySNS(NotifyBase):
|
||||||
|
|
||||||
self.logger.debug('Response Details:\r\n{}'.format(r.content))
|
self.logger.debug('Response Details:\r\n{}'.format(r.content))
|
||||||
|
|
||||||
return (False, NotifySNS.aws_response_to_dict(r.content))
|
return (False, NotifySNS.aws_response_to_dict(r.text))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.logger.info(
|
self.logger.info(
|
||||||
|
@ -375,7 +375,7 @@ class NotifySNS(NotifyBase):
|
||||||
self.logger.debug('Socket Exception: %s' % str(e))
|
self.logger.debug('Socket Exception: %s' % str(e))
|
||||||
return (False, NotifySNS.aws_response_to_dict(None))
|
return (False, NotifySNS.aws_response_to_dict(None))
|
||||||
|
|
||||||
return (True, NotifySNS.aws_response_to_dict(r.content))
|
return (True, NotifySNS.aws_response_to_dict(r.text))
|
||||||
|
|
||||||
def aws_prepare_request(self, payload, reference=None):
|
def aws_prepare_request(self, payload, reference=None):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -288,7 +288,7 @@ def test_aws_topic_handling(mock_post):
|
||||||
|
|
||||||
# A request
|
# A request
|
||||||
robj = mock.Mock()
|
robj = mock.Mock()
|
||||||
robj.content = ''
|
robj.text = ''
|
||||||
robj.status_code = requests.codes.ok
|
robj.status_code = requests.codes.ok
|
||||||
|
|
||||||
if data.find('=CreateTopic') >= 0:
|
if data.find('=CreateTopic') >= 0:
|
||||||
|
@ -323,11 +323,11 @@ def test_aws_topic_handling(mock_post):
|
||||||
|
|
||||||
# A request
|
# A request
|
||||||
robj = mock.Mock()
|
robj = mock.Mock()
|
||||||
robj.content = ''
|
robj.text = ''
|
||||||
robj.status_code = requests.codes.ok
|
robj.status_code = requests.codes.ok
|
||||||
|
|
||||||
if data.find('=CreateTopic') >= 0:
|
if data.find('=CreateTopic') >= 0:
|
||||||
robj.content = arn_response
|
robj.text = arn_response
|
||||||
|
|
||||||
# Manipulate Topic Publishing only (not phone)
|
# Manipulate Topic Publishing only (not phone)
|
||||||
elif data.find('=Publish') >= 0 and data.find('TopicArn=') >= 0:
|
elif data.find('=Publish') >= 0 and data.find('TopicArn=') >= 0:
|
||||||
|
@ -347,7 +347,7 @@ def test_aws_topic_handling(mock_post):
|
||||||
|
|
||||||
# Handle case where TopicArn is missing:
|
# Handle case where TopicArn is missing:
|
||||||
robj = mock.Mock()
|
robj = mock.Mock()
|
||||||
robj.content = "<CreateTopicResponse></CreateTopicResponse>"
|
robj.text = "<CreateTopicResponse></CreateTopicResponse>"
|
||||||
robj.status_code = requests.codes.ok
|
robj.status_code = requests.codes.ok
|
||||||
|
|
||||||
# Assign ourselves a new function
|
# Assign ourselves a new function
|
||||||
|
@ -356,14 +356,14 @@ def test_aws_topic_handling(mock_post):
|
||||||
|
|
||||||
# Handle case where we fails get a bad response
|
# Handle case where we fails get a bad response
|
||||||
robj = mock.Mock()
|
robj = mock.Mock()
|
||||||
robj.content = ''
|
robj.text = ''
|
||||||
robj.status_code = requests.codes.bad_request
|
robj.status_code = requests.codes.bad_request
|
||||||
mock_post.return_value = robj
|
mock_post.return_value = robj
|
||||||
assert a.notify(title='', body='test') is False
|
assert a.notify(title='', body='test') is False
|
||||||
|
|
||||||
# Handle case where we get a valid response and TopicARN
|
# Handle case where we get a valid response and TopicARN
|
||||||
robj = mock.Mock()
|
robj = mock.Mock()
|
||||||
robj.content = arn_response
|
robj.text = arn_response
|
||||||
robj.status_code = requests.codes.ok
|
robj.status_code = requests.codes.ok
|
||||||
mock_post.return_value = robj
|
mock_post.return_value = robj
|
||||||
# We would have failed to make Post
|
# We would have failed to make Post
|
||||||
|
|
Loading…
Reference in New Issue