#NEWLINE# @ mock . patch . object ( vm_utils , '_get_all_vdis_in_sr' ) #NEWLINE# def test_count_children( self , mock_get_all_vdis_in_sr ) : #NEWLINE# #INDENT# vdis = [ ( 'child1' , { #NEWLINE# #INDENT# 'sm_config' : { #NEWLINE# #INDENT# 'vhd-parent' : 'parent1' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) , ( 'child2' , { #NEWLINE# #INDENT# 'sm_config' : { #NEWLINE# #INDENT# 'vhd-parent' : 'parent2' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) , ( 'child3' , { #NEWLINE# #INDENT# 'sm_config' : { #NEWLINE# #INDENT# 'vhd-parent' : 'parent1' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) ] #NEWLINE# mock_get_all_vdis_in_sr . return_value = vdis #NEWLINE# self . assertEqual ( 2 , vm_utils . _count_children ( 'session' , 'parent1' , 'sr' ) )