#NEWLINE# def testFilteringLeafOnly( self ) : #NEWLINE# #INDENT# ' Test filtering of the tree with leafonly=True ' #NEWLINE# uids = self . uids #NEWLINE# assertEqual = self . assertEqual #NEWLINE# assertTrue = self . assertTrue #NEWLINE# h = S3Hierarchy ( 'test_hierarchy' , filter = ( FS ( 'type' ) == 'D' ) , leafonly = True ) #NEWLINE# nodes = h . nodes #NEWLINE# expected = [ 'HIERARCHY2' , 'HIERARCHY2-1' , 'HIERARCHY2-1-2' ] #NEWLINE# assertEqual ( len ( nodes ) , len ( expected ) ) #NEWLINE# assertTrue ( all ( ( ( node [ uid ] in nodes ) for uid in expected ) ) ) #NEWLINE# for node in nodes . values ( ) : #NEWLINE# #INDENT# assertTrue ( all ( ( ( child_id in nodes ) for child_id in node [ 's' ] ) ) ) #NEWLINE# parent_id = node [ 'p' ] #NEWLINE# if parent_id : #NEWLINE# #INDENT# assertTrue ( ( parent_id in nodes ) )