Use unicode responses recieved from Amazon (#320)

This commit is contained in:
Chris Caron 2020-11-14 13:52:00 -05:00 committed by GitHub
parent 3531912991
commit 2c2722f61f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 8 deletions

View File

@ -361,7 +361,7 @@ class NotifySNS(NotifyBase):
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:
self.logger.info(
@ -375,7 +375,7 @@ class NotifySNS(NotifyBase):
self.logger.debug('Socket Exception: %s' % str(e))
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):
"""

View File

@ -288,7 +288,7 @@ def test_aws_topic_handling(mock_post):
# A request
robj = mock.Mock()
robj.content = ''
robj.text = ''
robj.status_code = requests.codes.ok
if data.find('=CreateTopic') >= 0:
@ -323,11 +323,11 @@ def test_aws_topic_handling(mock_post):
# A request
robj = mock.Mock()
robj.content = ''
robj.text = ''
robj.status_code = requests.codes.ok
if data.find('=CreateTopic') >= 0:
robj.content = arn_response
robj.text = arn_response
# Manipulate Topic Publishing only (not phone)
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:
robj = mock.Mock()
robj.content = "<CreateTopicResponse></CreateTopicResponse>"
robj.text = "<CreateTopicResponse></CreateTopicResponse>"
robj.status_code = requests.codes.ok
# 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
robj = mock.Mock()
robj.content = ''
robj.text = ''
robj.status_code = requests.codes.bad_request
mock_post.return_value = robj
assert a.notify(title='', body='test') is False
# Handle case where we get a valid response and TopicARN
robj = mock.Mock()
robj.content = arn_response
robj.text = arn_response
robj.status_code = requests.codes.ok
mock_post.return_value = robj
# We would have failed to make Post