#NEWLINE# def test_add_child( self ) : #NEWLINE# #INDENT# bucket = self . root_node . to_json ( self . widgy_site ) [ 'children' ] [ 0 ] #NEWLINE# db_bucket = Node . objects . get ( id = extract_id ( bucket [ 'url' ] ) ) #NEWLINE# self . assertEqual ( db_bucket . get_children_count ( ) , 0 ) #NEWLINE# new_child = self . post ( self . node_url , { #NEWLINE# #INDENT# '__class__' : 'core_tests.rawtextwidget' , #NEWLINE# 'parent_id' : bucket [ 'url' ] , #NEWLINE# 'right_id' : None , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertEqual ( new_child . status_code , 201 ) #NEWLINE# new_child = decode_json_request ( new_child ) [ 'node' ] #NEWLINE# self . assertEqual ( new_child [ 'parent_id' ] , bucket [ 'url' ] ) #NEWLINE# self . assertEqual ( new_child [ 'content' ] [ '__class__' ] , 'core_tests.rawtextwidget' ) #NEWLINE# db_bucket = Node . objects . get ( id = extract_id ( bucket [ 'url' ] ) ) #NEWLINE# self . assertEqual ( db_bucket . get_children_count ( ) , 1 ) #NEWLINE# new_child [ 'content' ] [ 'attributes' ] [ 'text' ] = 'foobar' #NEWLINE# r = self . put ( new_child [ 'content' ] [ 'url' ] , new_child [ 'content' ] ) #NEWLINE# self . assertEqual ( r . status_code , 200 ) #NEWLINE# r = self . get ( new_child [ 'content' ] [ 'url' ] ) #NEWLINE# self . assertEqual ( r . status_code , 200 ) #NEWLINE# textcontent = decode_json_request ( r ) #NEWLINE# self . assertEqual ( textcontent [ 'attributes' ] [ 'text' ] , 'foobar' ) #NEWLINE# new_child [ 'parent_id' ] = self . root_node . to_json ( self . widgy_site ) [ 'children' ] [ 1 ] [ 'url' ] #NEWLINE# r = self . put ( new_child [ 'url' ] , new_child ) #NEWLINE# self . assertEqual ( r . status_code , 200 )