Fix returning objects with object attributes set to 'None'

This commit is contained in:
Christophe de Vienne 2013-05-13 18:14:11 +02:00
parent 9cb0b58db6
commit d05fb583eb
4 changed files with 18 additions and 0 deletions

View File

@ -45,6 +45,8 @@ def tojson(datatype, value):
def myspecialtype_tojson(datatype, value):
return str(value)
"""
if value is None:
return None
if wsme.types.iscomplex(datatype):
d = dict()
for attr in wsme.types.list_attributes(datatype):

View File

@ -574,6 +574,15 @@ class ProtocolTestCase(unittest.TestCase):
_rt=NestedOuter)
self.assertEquals(r, value)
def test_setnested_nullobj(self):
value = {'inner': None}
r = self.call(
'argtypes/setnested',
value=(value, NestedOuter),
_rt=NestedOuter
)
self.assertEquals(r, value)
def test_setbytesarray(self):
value = [b("1"), b("2"), b("three")]
r = self.call('argtypes/setbytesarray',

View File

@ -47,6 +47,8 @@ def prepare_value(value, datatype):
def prepare_result(value, datatype):
print(value, datatype)
if value is None:
return None
if datatype == wsme.types.binary:
return base64.decodestring(value.encode('ascii'))
if isusertype(datatype):

View File

@ -172,6 +172,8 @@ def tosuds(client, value):
value, datatype = value
else:
datatype = type(value)
if value is None:
return None
if isinstance(datatype, list):
if datatype[0] in array_types:
tname = array_types[datatype[0]]
@ -416,3 +418,6 @@ class TestSOAP(wsme.tests.protocol.ProtocolTestCase):
def test_return_objectdictattribute(self):
pass
def test_setnested_nullobj(self):
pass # TODO write a soap adapted version of this test.