Commit 6c9d9b5f authored by Romain Courteaud's avatar Romain Courteaud

Fix encoding handling in hypermedia api.

parent 9d52538a
......@@ -82,19 +82,19 @@ else:\n
assert same_type(dict_data, {})\n
result = "<?xml version=\'1.0\' encoding=\'utf-8\'?><instance>\\n"\n
for key, value in dict_data.items():\n
result += """ <parameter id="%s">%s</parameter>\\n""" % (key, value)\n
result += """ <parameter id="%s">%s</parameter>\\n""" % (key.encode("UTF-8"), value.encode("UTF-8"))\n
result += "</instance>"\n
return result\n
\n
try:\n
parameter_kw = {\n
\'software_release\': data_dict[\'software_release\'],\n
\'software_title\': data_dict[\'title\'],\n
\'software_type\': data_dict[\'software_type\'],\n
\'software_release\': data_dict[\'software_release\'].encode("UTF-8"),\n
\'software_title\': data_dict[\'title\'].encode("UTF-8"),\n
\'software_type\': data_dict[\'software_type\'].encode("UTF-8"),\n
\'instance_xml\': dictToXml(data_dict[\'parameter\']),\n
\'sla_xml\': dictToXml(data_dict[\'sla\']),\n
\'shared\': data_dict[\'slave\'],\n
\'state\': data_dict[\'status\'],\n
\'state\': data_dict[\'status\'].encode("UTF-8"),\n
}\n
except KeyError:\n
response.setStatus(400)\n
......
# -*- coding: utf-8 -*-
# Copyright (c) 2002-2013 Nexedi SA and Contributors. All Rights Reserved.
import transaction
from Products.SlapOS.tests.testSlapOSMixin import \
......@@ -95,11 +96,11 @@ class TestSlapOSHypermediaPersonScenario(testSlapOSMixin):
'Content-Type': request_link_dict['type'],
},
body=json.dumps({
'software_release': 'http://example.org',
'title': 'a great title',
'software_type': 'foo',
'parameter': {'param1': 'value1', 'param2': 'value2'},
'sla': {'param3': 'value3', 'param4': 'value4'},
'software_release': 'http://example.orgé',
'title': 'a great titleé',
'software_type': 'fooé',
'parameter': {'param1é': 'value1é', 'param2é': 'value2é'},
'sla': {'param3é': 'value3é', 'param4é': 'value4é'},
'slave': False,
'status': 'started',
}),
......
# -*- coding: utf-8 -*-
# Copyright (c) 2002-2013 Nexedi SA and Contributors. All Rights Reserved.
import transaction
from Products.SlapOS.tests.testSlapOSMixin import \
......@@ -423,11 +424,11 @@ class TestSlapOSPerson_requestHateoasHostingSubscription(testSlapOSMixin):
@simulate('Base_getRequestBody', '*args, **kwargs',
'return """%s"""' % json.dumps({
'software_release': 'http://example.org',
'title': 'a great title',
'software_type': 'foo',
'parameter': {'param1': 'value1', 'param2': 'value2'},
'sla': {'param3': 'value3', 'param4': 'value4'},
'software_release': 'http://example.orgé',
'title': 'a great titleé',
'software_type': 'fooé',
'parameter': {'param1é': 'value1é', 'param2é': 'value2é'},
'sla': {'param3': 'value3é', 'param4é': 'value4é'},
'slave': False,
'status': 'started',
}))
......
1
\ No newline at end of file
2
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment