From dc0db8496b3879ff88ba8b3d3dbe58e6efd3d475 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Mathieu?= Date: Sat, 17 Jan 2026 15:09:22 +0100 Subject: [PATCH] =?UTF-8?q?Tests:=20Upload-Test=20hinzugef=C3=BCgt=20-=20p?= =?UTF-8?q?r=C3=BCft=20Server-Verf=C3=BCgbarkeit=20und=20Konfiguration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test_dicom2pacs.py | 76 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/test_dicom2pacs.py b/test_dicom2pacs.py index c86c9d3..ccf8036 100755 --- a/test_dicom2pacs.py +++ b/test_dicom2pacs.py @@ -215,6 +215,81 @@ def test_birthdate_formatting(): print(f"✗ Fehler: {e}") return False +def test_upload_functionality(): + """Test Upload-Funktionalität""" + print("\nTeste Upload-Funktionalität...") + try: + import asyncio + import network_utils + + # Lade Konfiguration + config_path = os.path.expanduser("~/.dicom2pacs.conf") + server_url = None + server_username = None + server_pw = None + + if os.path.exists(config_path): + with open(config_path, 'r') as f: + for line in f: + line = line.strip() + if line.startswith('server_url='): + server_url = line.split('=', 1)[1] + elif line.startswith('server_username='): + server_username = line.split('=', 1)[1] + elif line.startswith('server_pw='): + server_pw = line.split('=', 1)[1] + + if not server_url: + print("⚠ Keine Server-URL in Konfiguration gefunden - Upload-Test übersprungen") + print(" Bitte konfigurieren Sie die Server-URL in ~/.dicom2pacs.conf") + return True # Nicht kritisch, Test überspringen + + # Test 1: Server-Verfügbarkeit prüfen + print(" Prüfe Server-Verfügbarkeit...") + try: + loop = asyncio.new_event_loop() + asyncio.set_event_loop(loop) + availability = loop.run_until_complete(network_utils.check_server_availability(server_url)) + loop.close() + + if availability: + print(f" ✓ Server ist erreichbar: {server_url}") + + # Test 2: Prüfe ob Test-DICOM-Dateien vorhanden sind + test_dir = os.path.expanduser("~/Downloads/test_dicom") + if os.path.exists(test_dir): + import file_management + result = file_management.find_dicom_files(test_dir) + if result != 'non_found': + files, count = result + if count > 0: + print(f" ✓ {count} Test-DICOM-Dateien gefunden") + print(" ⚠ Upload-Test würde echte Dateien hochladen - wird übersprungen") + print(" (Für echten Upload-Test: Manuell mit test_dicom2pacs.sh durchführen)") + return True + else: + print(" ⚠ Keine DICOM-Dateien im Test-Ordner") + else: + print(" ⚠ Keine DICOM-Dateien im Test-Ordner") + else: + print(" ⚠ Test-Ordner nicht gefunden: ~/Downloads/test_dicom") + + return True + else: + print(f" ⚠ Server ist nicht erreichbar: {server_url}") + print(" (Upload-Test kann nicht durchgeführt werden)") + return True # Nicht kritisch, Server könnte offline sein + except Exception as e: + print(f" ⚠ Fehler beim Prüfen der Server-Verfügbarkeit: {e}") + return True # Nicht kritisch + + except ImportError as e: + print(f"✗ Import-Fehler: {e}") + return False + except Exception as e: + print(f"✗ Fehler: {e}") + return False + def main(): """Hauptfunktion für alle Tests""" print("=== dicom2pacs Automatisierte Tests ===\n") @@ -226,6 +301,7 @@ def main(): ("Konfiguration", test_config_loading), ("Patientenname-Formatierung", test_patient_name_formatting), ("Geburtsdatum-Formatierung", test_birthdate_formatting), + ("Upload-Funktionalität", test_upload_functionality), ] results = []