Skip to content

Commit

Permalink
Merge pull request #38 from Mediaclash/master
Browse files Browse the repository at this point in the history
Support Unicode when decoding json responses from createsend API
  • Loading branch information
tobio authored Dec 13, 2016
2 parents 4f2f276 + b6ba30b commit 5540ec2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion createsend/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class VerifiedHTTPSConnection(HTTPSConnection):
***REMOVED******REMOVED******REMOVED***raise

def json_to_py(j):
***REMOVED***o = json.loads(j.decode())
***REMOVED***o = json.loads(j.decode('utf-8'))
***REMOVED***if isinstance(o, dict):
***REMOVED*** return dict_to_object(o)
***REMOVED***else:
Expand Down
16 changes: 16 additions & 0 deletions test/fixtures/custom_fields_utf8.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[
***REMOVED***{
***REMOVED******REMOVED***"FieldName": "salary_range",
***REMOVED******REMOVED***"Key": "[]",
***REMOVED******REMOVED***"DataType": "MultiSelectOne",
***REMOVED******REMOVED***"FieldOptions": ["£0-20k", "£20-30k", "£30k+"],
***REMOVED******REMOVED***"VisibleInPreferenceCenter": true
***REMOVED***},
***REMOVED***{
***REMOVED******REMOVED***"FieldName": "age",
***REMOVED******REMOVED***"Key": "[age]",
***REMOVED******REMOVED***"DataType": "Number",
***REMOVED******REMOVED***"FieldOptions": [],
***REMOVED******REMOVED***"VisibleInPreferenceCenter": true
***REMOVED***}
]
10 changes: 10 additions & 0 deletions test/test_list.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-

from six.moves.urllib.parse import quote
import unittest

Expand Down Expand Up @@ -88,6 +90,14 @@ class ListTestCase(object):
***REMOVED******REMOVED***self.assertEquals(cfs[0].DataType, "Text")
***REMOVED******REMOVED***self.assertEquals(cfs[0].FieldOptions, [])
***REMOVED******REMOVED***self.assertEquals(cfs[0].VisibleInPreferenceCenter, True)
***REMOVED***
***REMOVED***def test_custom_fields_utf8(self):
***REMOVED******REMOVED***self.list.stub_request("lists/%s/customfields.json" % self.list.list_id, "custom_fields_utf8.json")
***REMOVED******REMOVED***cfs = self.list.custom_fields()
***REMOVED******REMOVED***self.assertEquals(len(cfs), 2)
***REMOVED******REMOVED***self.assertEquals(cfs[0].FieldName, "salary_range")
***REMOVED******REMOVED***self.assertEquals(cfs[0].FieldOptions, [u"£0-20k", u"£20-30k", u"£30k+"])


***REMOVED***def test_segments(self):
***REMOVED******REMOVED***self.list.stub_request("lists/%s/segments.json" % self.list.list_id, "segments.json")
Expand Down

0 comments on commit 5540ec2

Please sign in to comment.