12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- #!/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()
|