40 lines
1.4 KiB
Python
40 lines
1.4 KiB
Python
#!/usr/bin/env python3.11
|
|
"""
|
|
Test-Script für Tapo-Steckdosen-Steuerung
|
|
Prüft ob die Tapo-Route korrekt funktioniert
|
|
"""
|
|
|
|
import sys
|
|
sys.path.append('.')
|
|
|
|
from app import app
|
|
|
|
def test_tapo_route():
|
|
"""Testet die Tapo-Route"""
|
|
with app.test_client() as client:
|
|
# Test ohne Authentifizierung (sollte Redirect geben)
|
|
response = client.get('/tapo/')
|
|
print(f"Tapo Route Status (ohne Auth): {response.status_code}")
|
|
|
|
if response.status_code == 302:
|
|
print("✅ Route ist verfügbar, Redirect zur Login-Seite (erwartet)")
|
|
elif response.status_code == 404:
|
|
print("❌ Route nicht gefunden - Blueprint nicht registriert")
|
|
else:
|
|
print(f"⚠️ Unerwarteter Status-Code: {response.status_code}")
|
|
|
|
# Test der Blueprint-Registrierung
|
|
print("\nRegistrierte Blueprints:")
|
|
for bp_name, bp in app.blueprints.items():
|
|
print(f" - {bp_name}: {bp.url_prefix}")
|
|
|
|
# Test der Tapo-Controller-Verfügbarkeit
|
|
try:
|
|
from utils.tapo_controller import TAPO_AVAILABLE, tapo_controller
|
|
print(f"\n✅ PyP100 verfügbar: {TAPO_AVAILABLE}")
|
|
print(f"✅ Tapo Controller verfügbar: {hasattr(tapo_controller, 'toggle_plug')}")
|
|
except Exception as e:
|
|
print(f"❌ Fehler beim Import des Tapo Controllers: {e}")
|
|
|
|
if __name__ == "__main__":
|
|
test_tapo_route() |