#NEWLINE# def test_get_file_map_memoization( self ) : #NEWLINE# #INDENT# node = factories . NodeFactory ( ) #NEWLINE# comp1 = factories . NodeFactory ( parent = node ) #NEWLINE# comp1a = factories . NodeFactory ( parent = comp1 ) #NEWLINE# comp2 = factories . NodeFactory ( parent = node ) #NEWLINE# file_trees = { n . _id : file_tree_factory ( 3 , 3 , 3 ) for n in [ node , comp1 , comp1a , comp2 ] } #NEWLINE# patches = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# mocks = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for n in [ node , comp1 , comp1a , comp2 ] : #NEWLINE# #INDENT# file_tree = file_trees [ n . _id ] #NEWLINE# osfstorage = n . get_addon ( 'osfstorage' ) #NEWLINE# mocked = mock . Mock ( return_value = file_tree ) #NEWLINE# patch = mock . patch . object ( osfstorage , '_get_file_tree' , mocked ) #NEWLINE# patch . start ( ) #NEWLINE# patches [ n . _id ] = patch #NEWLINE# mocks [ n . _id ] = mocked #NEWLINE# n_patch = mock . patch . object ( n , 'get_addon' , mock . Mock ( return_value = osfstorage ) ) #NEWLINE# n_patch . start ( ) #NEWLINE# patches [ osfstorage . _id ] = n_patch #NEWLINE# #UNINDENT# file_map = archiver_utils . get_file_map ( node ) #NEWLINE# file_map = { sha256 : value for ( sha256 , value , _ ) in file_map } #NEWLINE# for mocked in mocks . values ( ) : #NEWLINE# #INDENT# assert_equal ( mocked . call_count , 1 ) #NEWLINE# #UNINDENT# file_map = archiver_utils . get_file_map ( node ) #NEWLINE# file_map = { sha256 : value for ( sha256 , value , _ ) in file_map } #NEWLINE# for mocked in mocks . values ( ) : #NEWLINE# #INDENT# assert_equal ( mocked . call_count , 1 ) #NEWLINE# #UNINDENT# for patch in patches . values ( ) : #NEWLINE# #INDENT# patch . stop ( )