#NEWLINE# def _create_mock_session( self , disk = True , progress = ( - 1 ) ) : #NEWLINE# #INDENT# device_url = mock . Mock ( ) #NEWLINE# device_url . disk = session_invoke_api_side_effect #NEWLINE# device_url . url = 'http://*/ds/disk1.vmdk' #NEWLINE# lease_info = mock . Mock ( ) #NEWLINE# lease_info . deviceUrl = [ device_url ] #NEWLINE# session = mock . Mock ( ) #NEWLINE# def session_invoke_api_side_effect( module , method , * args , **kwargs ) : #NEWLINE# #INDENT# if ( module == session . vim ) : #NEWLINE# #INDENT# if ( method == 'ImportVApp' ) : #NEWLINE# #INDENT# return mock . Mock ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( method == 'HttpNfcLeaseProgress' ) : #NEWLINE# #INDENT# self . assertEqual ( progress , kwargs [ 'percent' ] ) #NEWLINE# return #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return lease_info #NEWLINE# #UNINDENT# session . invoke_api . side_effect = session_invoke_api_side_effect #NEWLINE# vim_cookie = mock . Mock ( ) #NEWLINE# vim_cookie . name = 'name' #NEWLINE# vim_cookie . value = 'value' #NEWLINE# session . vim . client . options . transport . cookiejar = [ vim_cookie ] #NEWLINE# return session