#NEWLINE# def test_available_children( self ) : #NEWLINE# #INDENT# ( left , right ) = make_a_nice_tree ( self . root_node , self . widgy_site ) #NEWLINE# subbucket = list ( left . get_children ( ) ) [ ( - 1 ) ] #NEWLINE# resp = self . get ( self . root_node . to_json ( self . widgy_site ) [ 'available_children_url' ] ) #NEWLINE# self . assertEqual ( resp . status_code , 200 ) #NEWLINE# data = decode_json_request ( resp ) #NEWLINE# def select( cls_name ) : #NEWLINE# #INDENT# possible_parent_urls = [ ] #NEWLINE# for ( node_url , child_classes ) in data . items ( ) : #NEWLINE# #INDENT# for i in child_classes : #NEWLINE# #INDENT# if ( i [ '__class__' ] == cls_name ) : #NEWLINE# #INDENT# possible_parent_urls . append ( node_url ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return possible_parent_urls #NEWLINE# #UNINDENT# bucket_parents = select ( 'core_tests.bucket' ) #NEWLINE# immovablebucket_parents = select ( 'core_tests.immovablebucket' ) #NEWLINE# pickybucket_parents = select ( 'core_tests.pickybucket' ) #NEWLINE# rawtext_parents = select ( 'core_tests.rawtextwidget' ) #NEWLINE# cantgoanywhere_parents = select ( 'core_tests.cantgoanywherewidget' ) #NEWLINE# def lists_equal( instances , urls ) : #NEWLINE# #INDENT# urls = sorted ( map ( str , urls ) ) #NEWLINE# instance_urls = sorted ( ( str ( i . get_api_url ( self . widgy_site ) ) for i in instances ) ) #NEWLINE# self . assertEqual ( instance_urls , urls ) #NEWLINE# #UNINDENT# lists_equal ( [ ] , cantgoanywhere_parents ) #NEWLINE# lists_equal ( [ right , left , subbucket , self . root_node ] , bucket_parents ) #NEWLINE# lists_equal ( [ right , left , subbucket , self . root_node ] , immovablebucket_parents ) #NEWLINE# lists_equal ( [ right , left , subbucket , self . root_node ] , pickybucket_parents ) #NEWLINE# lists_equal ( [ right , left , subbucket ] , rawtext_parents )