116 lines
3.8 KiB
Python
116 lines
3.8 KiB
Python
#!/usr/bin/env python3
|
|
"""Test script to verify that installation_method is correctly saved"""
|
|
|
|
import requests
|
|
import json
|
|
import os
|
|
import time
|
|
|
|
# Konfiguration
|
|
BASE_URL = "http://localhost:5000"
|
|
TEST_PROJECT_NAME = "test-install-method"
|
|
TEST_PROJECT_URL = "https://github.com/defunkt/jquery-pjax.git" # Kleines Test-Repository
|
|
|
|
def test_installation_method(method):
|
|
"""Teste Installation mit spezifischer Methode"""
|
|
print(f"\n🧪 Teste Installation mit Methode: {method}")
|
|
|
|
# Lösche Projekt falls es existiert
|
|
project_path = f"c:\\Users\\Simon.Speedy\\Documents\\dev projekte\\Test\\app installer\\projects\\{TEST_PROJECT_NAME}"
|
|
if os.path.exists(project_path):
|
|
import shutil
|
|
shutil.rmtree(project_path)
|
|
print(f"🗑️ Existierendes Projekt {TEST_PROJECT_NAME} entfernt")
|
|
|
|
# Installiere Projekt
|
|
data = {
|
|
'project_url': TEST_PROJECT_URL,
|
|
'project_name': TEST_PROJECT_NAME,
|
|
'installation_method': method
|
|
}
|
|
|
|
print(f"📤 Sende POST-Request an /install_project mit:")
|
|
print(f" - URL: {TEST_PROJECT_URL}")
|
|
print(f" - Name: {TEST_PROJECT_NAME}")
|
|
print(f" - Methode: {method}")
|
|
|
|
response = requests.post(f"{BASE_URL}/install_project", data=data)
|
|
|
|
if response.status_code == 200:
|
|
result = response.json()
|
|
print(f"✅ Response: {result}")
|
|
|
|
if result.get('success'):
|
|
# Warte kurz für Dateisystem
|
|
time.sleep(1)
|
|
|
|
# Prüfe version_app_in Datei
|
|
version_file = os.path.join(project_path, "version_app_in")
|
|
if os.path.exists(version_file):
|
|
with open(version_file, 'r', encoding='utf-8') as f:
|
|
version_data = json.load(f)
|
|
|
|
saved_method = version_data.get('installation_method', 'NICHT_GEFUNDEN')
|
|
print(f"💾 Gespeicherte Methode in version_app_in: {saved_method}")
|
|
|
|
if saved_method == method:
|
|
print(f"✅ ERFOLG: Methode '{method}' korrekt gespeichert!")
|
|
return True
|
|
else:
|
|
print(f"❌ FEHLER: Erwartet '{method}', gefunden '{saved_method}'")
|
|
return False
|
|
else:
|
|
print(f"❌ FEHLER: version_app_in Datei nicht gefunden!")
|
|
return False
|
|
else:
|
|
print(f"❌ Installation fehlgeschlagen: {result.get('message')}")
|
|
return False
|
|
else:
|
|
print(f"❌ HTTP-Fehler: {response.status_code}")
|
|
return False
|
|
|
|
def main():
|
|
print("🚀 Starte Test der installation_method Bugfix")
|
|
|
|
# Teste verschiedene Methoden
|
|
test_methods = [
|
|
'clone',
|
|
'native_python',
|
|
'docker_build',
|
|
'dockerfile'
|
|
]
|
|
|
|
results = {}
|
|
|
|
for method in test_methods:
|
|
try:
|
|
results[method] = test_installation_method(method)
|
|
except Exception as e:
|
|
print(f"❌ Fehler beim Testen von Methode '{method}': {e}")
|
|
results[method] = False
|
|
|
|
# Kurze Pause zwischen Tests
|
|
time.sleep(2)
|
|
|
|
# Zusammenfassung
|
|
print("\n" + "="*50)
|
|
print("📊 TESTERGEBNISSE:")
|
|
print("="*50)
|
|
|
|
success_count = 0
|
|
for method, success in results.items():
|
|
status = "✅ BESTANDEN" if success else "❌ FEHLGESCHLAGEN"
|
|
print(f" {method:15} - {status}")
|
|
if success:
|
|
success_count += 1
|
|
|
|
print(f"\n🎯 {success_count}/{len(test_methods)} Tests bestanden")
|
|
|
|
if success_count == len(test_methods):
|
|
print("🎉 Alle Tests erfolgreich! Der Bug ist behoben!")
|
|
else:
|
|
print("⚠️ Einige Tests fehlgeschlagen. Weitere Arbeit erforderlich.")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|