#NEWLINE# def test_to_json( self ) : #NEWLINE# #INDENT# child_obj = SomeModelToJson ( foo = 57 , bar = 'hello' ) #NEWLINE# obj = SomeModelToJson ( child = child_obj , foo = 42 , bar = 'world' ) #NEWLINE# json = obj . to_json ( include_defaults = True ) #NEWLINE# json_string = obj . to_json_string ( include_defaults = True ) #NEWLINE# self . assertEqual ( { #NEWLINE# #INDENT# 'child' : { #NEWLINE# #INDENT# 'id' : child_obj . _id , #NEWLINE# 'type' : 'SomeModelToJson' , #NEWLINE# #UNINDENT# } , #NEWLINE# 'id' : obj . _id , #NEWLINE# 'name' : None , #NEWLINE# 'tags' : [ ] , #NEWLINE# 'foo' : 42 , #NEWLINE# 'bar' : 'world' , #NEWLINE# #UNINDENT# } , json ) #NEWLINE# self . assertEqual ( ( ( ( '{"bar":"world",' + '"child":{"id":"%s","type":"SomeModelToJson"},' ) + '"foo":42,"id":"%s","name":null,"tags":[]}' ) % ( child_obj . _id , obj . _id ) ) , json_string )