def test_create_backup_return(self): ''' Test create_backup method - return ''' mock_hana_inst = MagicMock() mock_hana = MagicMock(return_value=mock_hana_inst) with patch.object(hanamod, '_init', mock_hana): hanamod.create_backup('key', 'pass', 'db', 'bakcup', 'prd', '00', 'pass') mock_hana.assert_called_once_with('prd', '00', 'pass') mock_hana_inst.create_backup.assert_called_once_with( 'key', 'pass', 'db', 'bakcup')
def test_create_backup_raise(self): ''' Test create_backup method - raise ''' mock_hana_inst = MagicMock() mock_hana_inst.create_backup.side_effect = hanamod.hana.HanaError( 'hana error') mock_hana = MagicMock(return_value=mock_hana_inst) with patch.object(hanamod, '_init', mock_hana): with pytest.raises(exceptions.CommandExecutionError) as err: hanamod.create_backup('key', 'pass', 'db', 'bakcup', 'prd', '00', 'pass') mock_hana.assert_called_once_with('prd', '00', 'pass') mock_hana_inst.create_backup.assert_called_once_with( 'key', 'pass', 'db', 'bakcup') assert 'hana error' in str(err)