Merge pull request #61 from weidongh/bugfixes
Fixed the github issue #57: query_entities() doesn't work for retrieving data in unicode
This commit is contained in:
Коммит
3e4404dea4
|
@ -276,7 +276,7 @@ def _convert_response_to_feeds(response, convert_func):
|
|||
xml_entries = _get_children_from_path(xmldoc, 'entry') #in some cases, response contains only entry but no feed
|
||||
for xml_entry in xml_entries:
|
||||
new_node = _clone_node_with_namespaces(xml_entry, xmldoc)
|
||||
feeds.append(convert_func(new_node.toxml()))
|
||||
feeds.append(convert_func(new_node.toxml('utf-8')))
|
||||
|
||||
return feeds
|
||||
|
||||
|
@ -286,7 +286,7 @@ def _validate_not_none(param_name, param):
|
|||
|
||||
def _fill_list_of(xmldoc, element_type):
|
||||
xmlelements = _get_child_nodes(xmldoc, element_type.__name__)
|
||||
return [_parse_response_body(xmlelement.toxml(), element_type) for xmlelement in xmlelements]
|
||||
return [_parse_response_body(xmlelement.toxml('utf-8'), element_type) for xmlelement in xmlelements]
|
||||
|
||||
def _fill_dict(xmldoc, element_name):
|
||||
xmlelements = _get_child_nodes(xmldoc, element_name)
|
||||
|
@ -312,7 +312,7 @@ def _fill_instance_child(xmldoc, element_name, return_type):
|
|||
|
||||
def _fill_instance_element(element, return_type):
|
||||
"""Converts a DOM element into the specified object"""
|
||||
return _parse_response_body(element.toxml(), return_type)
|
||||
return _parse_response_body(element.toxml('utf-8'), return_type)
|
||||
|
||||
|
||||
def _fill_data_minidom(xmldoc, element_name, data_member):
|
||||
|
|
|
@ -564,6 +564,9 @@ def convert_entity_to_xml(source):
|
|||
properties_str += ''.join([' m:type="', mtype, '"'])
|
||||
properties_str += ''.join(['>', xml_escape(value), '</d:', name, '>'])
|
||||
|
||||
if isinstance(properties_str, unicode):
|
||||
properties_str = properties_str.encode(encoding='utf-8')
|
||||
|
||||
#generate the entity_body
|
||||
entity_body = entity_body.format(properties=properties_str)
|
||||
xmlstr = _create_entry(entity_body)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#-------------------------------------------------------------------------
|
||||
#-------------------------------------------------------------------------
|
||||
# Copyright 2011 Microsoft Corporation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -17,7 +17,6 @@ from azure.storage.tableservice import *
|
|||
from azure.storage import EntityProperty, Entity, StorageServiceProperties
|
||||
from azure import WindowsAzureError
|
||||
|
||||
|
||||
from azuretest.util import (credentials,
|
||||
getUniqueTestRunID,
|
||||
STATUS_OK,
|
||||
|
@ -1039,8 +1038,18 @@ class StorageTest(AzureTestCase):
|
|||
|
||||
self.tc.cancel_batch()
|
||||
|
||||
def test_unicode_xml_encoding(self):
|
||||
''' regression test for github issue #57'''
|
||||
# Act
|
||||
self._create_table(self.table_name)
|
||||
self.tc.insert_entity(self.table_name, {'PartitionKey': 'test', 'RowKey': 'test1', 'Description': u'ꀕ'})
|
||||
self.tc.insert_entity(self.table_name, {'PartitionKey': 'test', 'RowKey': 'test2', 'Description': 'ꀕ'})
|
||||
resp = self.tc.query_entities(self.table_name, "PartitionKey eq 'test'")
|
||||
# Assert
|
||||
|
||||
self.assertEquals(len(resp), 2)
|
||||
self.assertEquals(resp[0].Description, u'ꀕ')
|
||||
self.assertEquals(resp[1].Description, u'ꀕ')
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
Загрузка…
Ссылка в новой задаче