#NEWLINE# @ patch ( 'os.path.isfile' , MagicMock ( return_value = True ) ) #NEWLINE# def test_push_failed( self ) : #NEWLINE# #INDENT# '\n        Test if push fails.\n        ' #NEWLINE# path = '/srv/salt/saltines' #NEWLINE# file_data = 'Remember to keep your files well salted.' #NEWLINE# mock_buf_size = len ( file_data ) #NEWLINE# mock_id = "You don't need to see his identification." #NEWLINE# ret = None #NEWLINE# class MockChannel ( object ) : #NEWLINE# #INDENT# @ staticmethod #NEWLINE# def factory( __opts__ ) : #NEWLINE# #INDENT# return MockChannel ( ) #NEWLINE# #UNINDENT# def send( self , load ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# #UNINDENT# class MockAuth ( object ) : #NEWLINE# #INDENT# def gen_token( self , salt ) : #NEWLINE# #INDENT# return 'token info' #NEWLINE# #UNINDENT# #UNINDENT# def mock_auth_factory( ) : #NEWLINE# #INDENT# return MockAuth ( ) #NEWLINE# #UNINDENT# with patch ( 'salt.transport.Channel' , MockChannel ) : #NEWLINE# #INDENT# with patch ( 'salt.modules.cp._auth' , mock_auth_factory ) : #NEWLINE# #INDENT# with patch ( 'salt.utils.fopen' , mock_open ( read_data = file_data ) ) : #NEWLINE# #INDENT# with patch . dict ( cp . __opts__ , { #NEWLINE# #INDENT# 'file_buffer_size' : mock_buf_size , #NEWLINE# 'id' : mock_id , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# self . assertEqual ( cp . push ( mock_id ) , ret )