#NEWLINE# @ mock . patch ( 'oppy.path.path.selectExitNode' , return_value = 'exit_fprint' ) #NEWLINE# @ mock . patch ( 'oppy.path.path.selectGuardNode' , return_value = 'guard_fprint' ) #NEWLINE# @ mock . patch ( 'oppy.path.path.selectMiddleNode' , return_value = 'middle_fprint' ) #NEWLINE# def test_getPath( self , mock_sm , mock_sg , mock_se ) : #NEWLINE# #INDENT# mock_ns = mock . Mock ( ) #NEWLINE# mock_gm = mock . Mock ( ) #NEWLINE# mock_exit_rs = mock . Mock ( ) #NEWLINE# mock_exit_rs . digest = 'exit digest' #NEWLINE# mock_middle_rs = mock . Mock ( ) #NEWLINE# mock_middle_rs . digest = 'middle digest' #NEWLINE# mock_guard_rs = mock . Mock ( ) #NEWLINE# mock_guard_rs . digest = 'guard digest' #NEWLINE# mock_consensus = mock . Mock ( ) #NEWLINE# mock_consensus . routers = { #NEWLINE# #INDENT# 'exit_fprint' : mock_exit_rs , #NEWLINE# 'middle_fprint' : mock_middle_rs , #NEWLINE# 'guard_fprint' : mock_guard_rs , #NEWLINE# #UNINDENT# } #NEWLINE# mock_consensus . bandwidth_weights = 'bandwidth weights' #NEWLINE# mock_exit_request = mock . Mock ( ) #NEWLINE# mock_exit_request . port = 'port' #NEWLINE# mock_descriptors = { #NEWLINE# #INDENT# 'exit digest' : 'exit_fprint' , #NEWLINE# 'middle digest' : 'middle_fprint' , #NEWLINE# 'guard digest' : 'guard_fprint' , #NEWLINE# #UNINDENT# } #NEWLINE# mock_ns . getMicroconsensus = mock . Mock ( ) #NEWLINE# mock_ns . getMicroconsensus . return_value = defer . succeed ( mock_consensus ) #NEWLINE# mock_ns . getMicrodescriptorsForCircuit = mock . Mock ( ) #NEWLINE# mock_ns . getMicrodescriptorsForCircuit . return_value = defer . succeed ( mock_descriptors ) #NEWLINE# mock_gm . getUsableGuards = mock . Mock ( ) #NEWLINE# mock_gm . getUsableGuards . return_value = defer . succeed ( 'guards' ) #NEWLINE# mock_fast = True #NEWLINE# mock_stable = True #NEWLINE# mock_internal = False #NEWLINE# mock_bwweightscale = path . DEFAULT_BWWEIGHTSCALE #NEWLINE# ret = path . getPath ( mock_ns , mock_gm , mock_exit_request , mock_fast , mock_stable , mock_internal ) #NEWLINE# mock_se . assert_called_once_with ( mock_consensus . bandwidth_weights , mock_bwweightscale , mock_consensus . routers , mock_descriptors , mock_fast , mock_stable , mock_internal , mock_exit_request . port ) #NEWLINE# mock_sg . assert_called_once_with ( mock_consensus . routers , mock_descriptors , 'guards' , mock_fast , mock_stable , 'exit_fprint' , mock_consensus ) #NEWLINE# mock_sm . assert_called_once_with ( mock_consensus . bandwidth_weights , mock_bwweightscale , mock_consensus . routers , mock_descriptors , mock_fast , mock_stable , 'exit_fprint' , mock_exit_rs , 'guard_fprint' , mock_guard_rs ) #NEWLINE# self . assertEqual ( self . successResultOf ( ret ) , path . Path ( path . PathNode ( 'guard_fprint' , mock_guard_rs ) , path . PathNode ( 'middle_fprint' , mock_middle_rs ) , path . PathNode ( 'exit_fprint' , mock_exit_rs ) ) )