#NEWLINE# @ patch ( 'os.path.exists' , MagicMock ( return_value = True ) ) #NEWLINE# def test_cache_local_file_success( self ) : #NEWLINE# #INDENT# '\n        Test if cache_local_file succeeds.\n        ' #NEWLINE# path = 'saltk//saltines' #NEWLINE# dest_file = '/srv/salt/cheese/saltines' #NEWLINE# ret = dest_file #NEWLINE# class MockFileClient ( object ) : #NEWLINE# #INDENT# def cache_local_file( self , path ) : #NEWLINE# #INDENT# return dest_file #NEWLINE# #UNINDENT# #UNINDENT# mock_file_client = MockFileClient ( ) #NEWLINE# with patch ( 'salt.modules.cp.is_cached' , MagicMock ( return_value = False ) ) : #NEWLINE# #INDENT# with patch . dict ( cp . __context__ , { #NEWLINE# #INDENT# 'cp.fileclient' : mock_file_client , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# self . assertEqual ( cp . cache_local_file ( self ) , ret )