diff --git a/createsend/utils.py b/createsend/utils.py index 5207675..43861d2 100644 --- a/createsend/utils.py +++ b/createsend/utils.py @@ -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: diff --git a/test/fixtures/custom_fields_utf8.json b/test/fixtures/custom_fields_utf8.json new file mode 100644 index 0000000..b07aa79 --- /dev/null +++ b/test/fixtures/custom_fields_utf8.json @@ -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***} +] \ No newline at end of file diff --git a/test/test_list.py b/test/test_list.py index 974b4af..d67a3d2 100644 --- a/test/test_list.py +++ b/test/test_list.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + from six.moves.urllib.parse import quote import unittest @@ -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")