#!/usr/bin/env python3
"""
Simple test to verify the config_tab.py fixes
"""

import sys
sys.path.append('src')

from excel_filter.gui_components.config_tab import ConfigTab

def test_methods():
    """Test that the methods are properly implemented"""
    print("Testing ConfigTab methods...")
    
    # Test that the class can be instantiated
    try:
        # Create a minimal mock frame
        import tkinter as tk
        root = tk.Tk()
        
        win11_colors = {'primary': '#0078d4', 'light': '#f0f0f0', 'dark': '#e0e0e0', 'accent': '#005a9e'}
        pattern_presets = {"test": "test"}
        pattern_descriptions = {"test": "test"}
        
        config_tab = ConfigTab(root, win11_colors, pattern_presets, pattern_descriptions)
        
        # Test that methods exist and are callable
        assert hasattr(config_tab, 'select_all_columns'), "select_all_columns method missing"
        assert hasattr(config_tab, 'deselect_all_columns'), "deselect_all_columns method missing"
        assert hasattr(config_tab, 'process_file'), "process_file method missing"
        assert hasattr(config_tab, 'save_config'), "save_config method missing"
        assert hasattr(config_tab, 'load_config'), "load_config method missing"
        assert hasattr(config_tab, 'browse_input_file'), "browse_input_file method missing"
        assert hasattr(config_tab, 'browse_output_file'), "browse_output_file method missing"
        assert hasattr(config_tab, 'update_columns_selection'), "update_columns_selection method missing"
        
        # Test that methods are callable
        config_tab.select_all_columns()
        config_tab.deselect_all_columns()
        config_tab.process_file()
        config_tab.save_config()
        config_tab.load_config()
        config_tab.browse_input_file()
        config_tab.browse_output_file()
        config_tab.update_columns_selection()
        
        print("[SUCCESS] All methods are properly implemented and callable!")
        
        # Test with some data
        config_tab.input_file_var.set("test_input.xlsx")
        config_tab.output_file_var.set("test_output.xlsx")
        config_tab.pattern_var.set("error|warning")
        
        # This should work now (previously would have done nothing)
        config_tab.process_file()
        
        print("[SUCCESS] Process file method works with valid data!")
        
        root.destroy()
        return True
        
    except Exception as e:
        print(f"[ERROR] Error: {e}")
        return False

if __name__ == "__main__":
    success = test_methods()
    if success:
        print("\n[INFO] All tests passed! The config_tab.py fixes are working correctly.")
    else:
        print("\n[ERROR] Some tests failed. Please check the implementation.")
