Initial commit
This commit is contained in:
73
archive/old_tests/test_event_capture.py
Normal file
73
archive/old_tests/test_event_capture.py
Normal file
@@ -0,0 +1,73 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test de la capture d'événements
|
||||
"""
|
||||
|
||||
import sys
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).parent / "geniusia2"))
|
||||
|
||||
from core.event_capture import EventCapture
|
||||
from core.logger import Logger
|
||||
|
||||
def test_event_capture():
|
||||
"""Test de la capture d'événements."""
|
||||
print("=" * 60)
|
||||
print("Test de Capture d'Événements")
|
||||
print("=" * 60)
|
||||
print()
|
||||
|
||||
logger = Logger()
|
||||
capture = EventCapture(logger=logger, pattern_threshold=3)
|
||||
|
||||
def on_pattern(pattern):
|
||||
print(f"\n🎯 PATTERN DÉTECTÉ !")
|
||||
print(f" Répétitions: {pattern['repetitions']}")
|
||||
print(f" Longueur: {pattern['length']}")
|
||||
print(f" Fenêtre: {pattern['window']}")
|
||||
|
||||
capture.register_pattern_callback(on_pattern)
|
||||
|
||||
print("1. Démarrage de la capture...")
|
||||
if capture.start():
|
||||
print(" ✓ Capture démarrée")
|
||||
else:
|
||||
print(" ✗ Échec du démarrage")
|
||||
return False
|
||||
|
||||
print("\n2. Effectuez des actions répétitives (clics, frappes)...")
|
||||
print(" Le test s'arrêtera dans 30 secondes")
|
||||
print()
|
||||
|
||||
try:
|
||||
for i in range(30):
|
||||
time.sleep(1)
|
||||
events = capture.get_recent_events(5)
|
||||
if events:
|
||||
print(f"\r Événements capturés: {len(capture.events)}", end="", flush=True)
|
||||
except KeyboardInterrupt:
|
||||
print("\n\n⏹️ Arrêt demandé")
|
||||
|
||||
print("\n\n3. Arrêt de la capture...")
|
||||
capture.stop()
|
||||
print(" ✓ Capture arrêtée")
|
||||
|
||||
print(f"\n4. Résumé:")
|
||||
print(f" Total d'événements: {len(capture.events)}")
|
||||
|
||||
recent = capture.get_recent_events(10)
|
||||
if recent:
|
||||
print(f"\n Derniers événements:")
|
||||
for e in recent[-5:]:
|
||||
print(f" - {e['type']} à {e['timestamp'].strftime('%H:%M:%S')}")
|
||||
|
||||
print("\n" + "=" * 60)
|
||||
print("✓ Test terminé")
|
||||
print("=" * 60)
|
||||
return True
|
||||
|
||||
if __name__ == "__main__":
|
||||
success = test_event_capture()
|
||||
sys.exit(0 if success else 1)
|
||||
Reference in New Issue
Block a user