/ laxyfile / test_minimal_integration.py
swadhin biswas redy to jump in work Β· 7/25/2025
d8c49a5
85 lines Β· 2.6 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
#!/usr/bin/env python3
"""
Minimal integration test to validate core functionality
"""

import asyncio
import tempfile
from pathlib import Path
import sys

# Add the current directory to Python path
sys.path.insert(0, '.')

from laxyfile.core.config import Config
from laxyfile.core.advanced_file_manager import AdvancedFileManager
from laxyfile.utils.logging_system import initialize_logging, get_logger, LogCategory


async def test_minimal_integration():
    """Test minimal component integration"""
    print("πŸ§ͺ Testing LaxyFile Minimal Integration...")

    # Create temporary config directory
    with tempfile.TemporaryDirectory() as temp_dir:
        config_dir = Path(temp_dir)

        # Create test configuration
        config = Config(config_dir=config_dir)
        config.data.update({
            'logging': {
                'console': {'enabled': True, 'level': 'INFO'},
                'file': {'enabled': False},
                'performance': {'enabled': False},
                'error': {'enabled': False}
            }
        })

        try:
            print("  βœ… Created configuration")

            # Initialize logging
            logging_system = initialize_logging(config)
            logger = get_logger('test', LogCategory.SYSTEM)
            print("  βœ… Initialized logging system")

            # Test file manager
            print("  πŸ”„ Testing file manager...")
            file_manager = AdvancedFileManager(config)
            await file_manager.initialize()
            print("  βœ… File manager initialized")

            # Test directory listing
            current_dir = Path.cwd()
            files = await file_manager.list_directory(current_dir)
            print(f"  βœ… Listed {len(files)} files in current directory")

            # Test file operations
            if files:
                first_file = files[0]
                print(f"  πŸ“„ First file: {first_file.name} ({first_file.size} bytes)")

            # Test caching
            cache_stats = file_manager.get_cache_stats()
            print(f"  πŸ“Š Cache stats: {cache_stats}")

            print("πŸŽ‰ Minimal integration test completed successfully!")
            return True

        except Exception as e:
            print(f"  ❌ Integration test failed: {e}")
            import traceback
            traceback.print_exc()
            return False


async def main():
    """Run the minimal integration test"""
    success = await test_minimal_integration()
    if not success:
        sys.exit(1)
    print("\n✨ Core functionality is working correctly!")


if __name__ == "__main__":
    asyncio.run(main())