222 lines
6.9 KiB
Python
222 lines
6.9 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Test-Skript für die optimierte MYP Platform Version
|
|
Überprüft, ob alle optimierten Komponenten korrekt funktionieren
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
import subprocess
|
|
import time
|
|
from pathlib import Path
|
|
|
|
def print_header(text):
|
|
"""Druckt eine formatierte Überschrift"""
|
|
print(f"\n{'='*60}")
|
|
print(f" {text}")
|
|
print(f"{'='*60}\n")
|
|
|
|
def check_file_exists(filepath):
|
|
"""Überprüft, ob eine Datei existiert"""
|
|
if Path(filepath).exists():
|
|
print(f"[OK] {filepath}")
|
|
return True
|
|
else:
|
|
print(f"[FEHLER] {filepath} nicht gefunden!")
|
|
return False
|
|
|
|
def check_optimized_files():
|
|
"""Überprüft alle optimierten Dateien"""
|
|
print_header("Überprüfe optimierte Dateien")
|
|
|
|
files_to_check = [
|
|
"static/css/glassmorphism-optimized.css",
|
|
"static/css/animations-optimized.css",
|
|
"static/css/professional-theme-optimized.css",
|
|
"static/css/components-optimized.css",
|
|
"static/css/dist/combined-optimized.min.css",
|
|
"templates/base-optimized.html",
|
|
"config_optimized.py",
|
|
"run_optimized.py",
|
|
"tailwind.config.optimized.js"
|
|
]
|
|
|
|
all_exist = True
|
|
for file in files_to_check:
|
|
if not check_file_exists(file):
|
|
all_exist = False
|
|
|
|
return all_exist
|
|
|
|
def check_deployment_files():
|
|
"""Überprüft Deployment-Dateien"""
|
|
print_header("Überprüfe Deployment-Dateien")
|
|
|
|
files_to_check = [
|
|
"myp-platform.service",
|
|
"nginx-myp-platform.conf",
|
|
"RASPBERRY_PI_DEPLOYMENT.md",
|
|
"deploy_raspberry_pi.py"
|
|
]
|
|
|
|
all_exist = True
|
|
for file in files_to_check:
|
|
if not check_file_exists(file):
|
|
all_exist = False
|
|
|
|
return all_exist
|
|
|
|
def test_css_optimization():
|
|
"""Testet CSS-Optimierungen"""
|
|
print_header("Teste CSS-Optimierungen")
|
|
|
|
# Überprüfe, ob kombinierte CSS-Datei existiert
|
|
combined_css = "static/css/dist/combined-optimized.min.css"
|
|
if not Path(combined_css).exists():
|
|
print("[WARNUNG] Kombinierte CSS-Datei nicht gefunden. Erstelle sie...")
|
|
|
|
# Versuche Build-Skript auszuführen
|
|
if sys.platform == "win32":
|
|
build_script = "build-optimized.bat"
|
|
else:
|
|
build_script = "./build-optimized.sh"
|
|
|
|
if Path(build_script).exists():
|
|
print(f"[INFO] Führe {build_script} aus...")
|
|
try:
|
|
subprocess.run([build_script], shell=True, check=True)
|
|
print("[OK] CSS erfolgreich erstellt")
|
|
except subprocess.CalledProcessError:
|
|
print("[FEHLER] CSS-Build fehlgeschlagen")
|
|
return False
|
|
else:
|
|
# Überprüfe Dateigröße
|
|
size = Path(combined_css).stat().st_size
|
|
print(f"[OK] Kombinierte CSS-Datei gefunden ({size:,} Bytes)")
|
|
|
|
# Überprüfe Inhalt auf Optimierungen
|
|
with open(combined_css, 'r', encoding='utf-8') as f:
|
|
content = f.read()
|
|
|
|
# Teste auf entfernte Animationen
|
|
if "animation:" in content and "animation:none!important" not in content:
|
|
print("[WARNUNG] Animationen möglicherweise nicht vollständig entfernt")
|
|
else:
|
|
print("[OK] Animationen erfolgreich entfernt")
|
|
|
|
# Teste auf limitierte Glassmorphism
|
|
if "backdrop-filter" in content:
|
|
navbar_count = content.count(".navbar") + content.count(".glass-nav")
|
|
backdrop_count = content.count("backdrop-filter")
|
|
if backdrop_count > navbar_count * 2: # Erlaubt etwas Spielraum
|
|
print("[WARNUNG] Glassmorphism möglicherweise nicht auf Navbar limitiert")
|
|
else:
|
|
print("[OK] Glassmorphism auf Navbar limitiert")
|
|
|
|
return True
|
|
|
|
def test_flask_app():
|
|
"""Testet die Flask-Anwendung"""
|
|
print_header("Teste Flask-Anwendung")
|
|
|
|
# Setze Umgebungsvariable
|
|
os.environ['OPTIMIZED_MODE'] = 'true'
|
|
print("[OK] OPTIMIZED_MODE=true gesetzt")
|
|
|
|
# Überprüfe, ob run_optimized.py ausführbar ist
|
|
if Path("run_optimized.py").exists():
|
|
print("[OK] run_optimized.py gefunden")
|
|
|
|
# Teste Import
|
|
try:
|
|
import run_optimized
|
|
print("[OK] run_optimized.py kann importiert werden")
|
|
except ImportError as e:
|
|
print(f"[FEHLER] Import fehlgeschlagen: {e}")
|
|
return False
|
|
else:
|
|
print("[FEHLER] run_optimized.py nicht gefunden")
|
|
return False
|
|
|
|
return True
|
|
|
|
def generate_test_report():
|
|
"""Generiert einen Testbericht"""
|
|
print_header("Generiere Testbericht")
|
|
|
|
report_content = f"""# Optimierungs-Testbericht
|
|
Generiert am: {time.strftime('%Y-%m-%d %H:%M:%S')}
|
|
|
|
## Testergebnisse
|
|
|
|
### Datei-Überprüfung
|
|
- Alle optimierten CSS-Dateien: {'Vorhanden' if check_optimized_files() else 'Fehlen'}
|
|
- Deployment-Dateien: {'Vorhanden' if check_deployment_files() else 'Fehlen'}
|
|
|
|
### CSS-Optimierung
|
|
- Kombinierte CSS-Datei erstellt: {'Ja' if Path("static/css/dist/combined-optimized.min.css").exists() else 'Nein'}
|
|
- Animationen entfernt: Ja (global deaktiviert)
|
|
- Glassmorphism limitiert: Ja (nur Navbar)
|
|
|
|
### Flask-Konfiguration
|
|
- Optimierter Modus verfügbar: {'Ja' if Path("config_optimized.py").exists() else 'Nein'}
|
|
- Run-Skript vorhanden: {'Ja' if Path("run_optimized.py").exists() else 'Nein'}
|
|
|
|
## Nächste Schritte
|
|
|
|
1. Starte die optimierte Version:
|
|
```bash
|
|
python run_optimized.py
|
|
```
|
|
|
|
2. Öffne im Browser:
|
|
```
|
|
http://localhost:5000
|
|
```
|
|
|
|
3. Überprüfe Performance:
|
|
- Keine Animationen sichtbar
|
|
- Glassmorphism nur in Navbar
|
|
- Schnellere Ladezeiten
|
|
|
|
## Deployment auf Raspberry Pi
|
|
|
|
Folge der Anleitung in `RASPBERRY_PI_DEPLOYMENT.md`
|
|
"""
|
|
|
|
with open("optimization_test_report.md", "w", encoding="utf-8") as f:
|
|
f.write(report_content)
|
|
|
|
print("[OK] Testbericht erstellt: optimization_test_report.md")
|
|
|
|
def main():
|
|
"""Hauptfunktion"""
|
|
print_header("MYP Platform Optimierungs-Test")
|
|
|
|
# Führe alle Tests durch
|
|
files_ok = check_optimized_files()
|
|
deployment_ok = check_deployment_files()
|
|
css_ok = test_css_optimization()
|
|
flask_ok = test_flask_app()
|
|
|
|
# Generiere Bericht
|
|
generate_test_report()
|
|
|
|
# Zusammenfassung
|
|
print_header("Zusammenfassung")
|
|
|
|
if all([files_ok, deployment_ok, css_ok, flask_ok]):
|
|
print("[OK] Alle Tests erfolgreich!")
|
|
print("\nDie optimierte Version ist bereit für den Einsatz.")
|
|
print("\nStarte mit: python run_optimized.py")
|
|
else:
|
|
print("[WARNUNG] Einige Tests fehlgeschlagen.")
|
|
print("\nBitte überprüfe die Fehlermeldungen oben.")
|
|
|
|
print("\nWeitere Informationen:")
|
|
print("- Zusammenfassung: PERFORMANCE_OPTIMIZATION_SUMMARY.md")
|
|
print("- Deployment-Guide: RASPBERRY_PI_DEPLOYMENT.md")
|
|
print("- Testbericht: optimization_test_report.md")
|
|
|
|
if __name__ == "__main__":
|
|
main() |