#!/usr/bin/env python3
"""
Test script to demonstrate configurable heartbeat interval
"""

import os
import sys
from pathlib import Path

# Add the src directory to the path
project_root = Path(__file__).parent
sys.path.insert(0, str(project_root / 'src'))

def test_heartbeat_config():
    """Test the configurable heartbeat interval."""
    print("๐Ÿงช Testing Configurable Bot Heartbeat")
    print("=" * 50)
    
    # Test with different values
    test_values = [
        ("10", "Fast monitoring (10 seconds)"),
        ("30", "Default monitoring (30 seconds)"), 
        ("60", "Slow monitoring (60 seconds)"),
        ("300", "Very slow monitoring (5 minutes)"),
        ("3", "Too fast (should warn)"),
        ("700", "Too slow (should warn)")
    ]
    
    for value, description in test_values:
        print(f"\n๐Ÿ” Testing: {description}")
        
        # Set environment variable
        os.environ['BOT_HEARTBEAT_SECONDS'] = value
        
        # Reload config (simulate fresh import)
        if 'config' in sys.modules:
            del sys.modules['config']
        
        try:
            from config import Config
            
            print(f"   ๐Ÿ“Š BOT_HEARTBEAT_SECONDS: {Config.BOT_HEARTBEAT_SECONDS}")
            
            # Test validation
            is_valid = Config.validate()
            print(f"   โœ… Validation: {'PASSED' if is_valid else 'FAILED'}")
            
            # Show what the monitoring message would say
            print(f"   ๐Ÿ“ฑ Monitoring message: 'Order monitoring: Active ({Config.BOT_HEARTBEAT_SECONDS}s interval)'")
            
        except Exception as e:
            print(f"   โŒ Error: {e}")
    
    print(f"\n๐ŸŽ‰ Heartbeat configuration test complete!")
    print(f"๐Ÿ’ก Set BOT_HEARTBEAT_SECONDS in your .env file to customize the monitoring interval")

if __name__ == "__main__":
    test_heartbeat_config()