/ laxyfile / test_laxyfile.py
swadhin biswas redy to jump in work Β· 7/25/2025
d8c49a5
127 lines Β· 3.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/usr/bin/env python3
"""
Test script for LaxyFile - Verify basic functionality
"""

import sys
import os
from pathlib import Path

# Add current directory to path
sys.path.insert(0, str(Path(__file__).parent))

def test_imports():
    """Test that all modules can be imported"""
    print("πŸ§ͺ Testing imports...")

    try:
        from laxyfile.core.config import Config
        print("βœ… Config module imported successfully")

        from laxyfile.core.file_manager import FileManager, FileInfo
        print("βœ… FileManager module imported successfully")

        from laxyfile.ui.theme import ThemeManager
        print("βœ… ThemeManager module imported successfully")

        from laxyfile.ui.panels import PanelManager
        print("βœ… PanelManager module imported successfully")

        from laxyfile.ui.image_viewer import ImageViewer
        print("βœ… ImageViewer module imported successfully")

        from laxyfile.ai.assistant import AIAssistant
        print("βœ… AIAssistant module imported successfully")

        from laxyfile.utils.logger import Logger
        print("βœ… Logger module imported successfully")

        return True
    except Exception as e:
        print(f"❌ Import failed: {e}")
        return False

def test_basic_functionality():
    """Test basic functionality"""
    print("\nπŸ”§ Testing basic functionality...")

    try:
        # Test config
        from laxyfile.core.config import Config
        config = Config()
        print(f"βœ… Config loaded, theme: {config.get_theme().name}")

        # Test file manager
        from laxyfile.core.file_manager import FileManager
        fm = FileManager()
        files = fm.list_directory(Path.cwd())
        print(f"βœ… FileManager working, found {len(files)} items in current directory")

        # Test theme manager
        from laxyfile.ui.theme import ThemeManager
        theme_manager = ThemeManager(config)
        themes = theme_manager.get_available_themes()
        print(f"βœ… ThemeManager working, available themes: {', '.join(themes)}")

        # Test logger
        from laxyfile.utils.logger import Logger
        logger = Logger()
        logger.info("Test log message")
        print("βœ… Logger working")

        return True
    except Exception as e:
        print(f"❌ Functionality test failed: {e}")
        return False

def test_rich_ui():
    """Test Rich UI components"""
    print("\n🎨 Testing Rich UI...")

    try:
        from rich.console import Console
        from rich.panel import Panel
        from rich.text import Text

        console = Console()

        # Test basic Rich functionality
        test_panel = Panel(
            Text("LaxyFile Test", style="bold green"),
            title="πŸš€ Test Panel",
            border_style="blue"
        )

        console.print(test_panel)
        print("βœ… Rich UI components working")

        return True
    except Exception as e:
        print(f"❌ Rich UI test failed: {e}")
        return False

def main():
    """Main test function"""
    print("πŸš€ LaxyFile Test Suite")
    print("=" * 50)

    # Run tests
    import_success = test_imports()
    func_success = test_basic_functionality()
    ui_success = test_rich_ui()

    print("\n" + "=" * 50)
    print("πŸ“Š Test Results:")
    print(f"   Imports: {'βœ… PASS' if import_success else '❌ FAIL'}")
    print(f"   Functionality: {'βœ… PASS' if func_success else '❌ FAIL'}")
    print(f"   Rich UI: {'βœ… PASS' if ui_success else '❌ FAIL'}")

    if all([import_success, func_success, ui_success]):
        print("\nπŸŽ‰ All tests passed! LaxyFile is ready to run.")
        print("   Run: python main.py")
    else:
        print("\n⚠️  Some tests failed. Please check the installation.")
        print("   Try: pip install -r requirements.txt")

if __name__ == "__main__":
    main()