"Refactor doc files, rename COMMON_ERRORS.md to COMMON_ERRORS.md and add DRUCKER_STATUS_UPDATE.md"
This commit is contained in:
parent
cf077ffcb8
commit
7e3d0a8a97
Binary file not shown.
1
backend/app/docs/DRUCKER_STATUS_UPDATE.md
Normal file
1
backend/app/docs/DRUCKER_STATUS_UPDATE.md
Normal file
@ -0,0 +1 @@
|
||||
|
@ -1,86 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test-Skript für die Drucker-Funktionen
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
from app import check_printer_status, check_multiple_printers_status
|
||||
from models import get_db_session, Printer
|
||||
|
||||
def test_ping_function():
|
||||
"""Teste die Ping-Funktion mit localhost"""
|
||||
print("Teste Ping-Funktion...")
|
||||
|
||||
# Test mit localhost
|
||||
status, active = check_printer_status("127.0.0.1", timeout=3)
|
||||
print(f"Localhost Test: Status={status}, Active={active}")
|
||||
|
||||
# Test mit ungültiger IP
|
||||
status, active = check_printer_status("192.168.999.999", timeout=2)
|
||||
print(f"Ungültige IP Test: Status={status}, Active={active}")
|
||||
|
||||
# Test mit leerer IP
|
||||
status, active = check_printer_status("", timeout=1)
|
||||
print(f"Leere IP Test: Status={status}, Active={active}")
|
||||
|
||||
def test_multiple_printers():
|
||||
"""Teste die Mehrfach-Drucker-Funktion"""
|
||||
print("\nTeste Mehrfach-Drucker-Funktion...")
|
||||
|
||||
test_printers = [
|
||||
{'id': 1, 'name': 'Test1', 'ip_address': '127.0.0.1', 'location': 'Test'},
|
||||
{'id': 2, 'name': 'Test2', 'ip_address': '192.168.1.999', 'location': 'Test'},
|
||||
{'id': 3, 'name': 'Test3', 'ip_address': '', 'location': 'Test'}
|
||||
]
|
||||
|
||||
results = check_multiple_printers_status(test_printers, timeout=3)
|
||||
|
||||
for printer in test_printers:
|
||||
printer_id = printer['id']
|
||||
if printer_id in results:
|
||||
status, active = results[printer_id]
|
||||
print(f"Drucker {printer['name']} ({printer['ip_address']}): {status}, {active}")
|
||||
else:
|
||||
print(f"Drucker {printer['name']}: Kein Ergebnis")
|
||||
|
||||
def test_database_printers():
|
||||
"""Teste mit echten Druckern aus der Datenbank"""
|
||||
print("\nTeste echte Drucker aus der Datenbank...")
|
||||
|
||||
try:
|
||||
db_session = get_db_session()
|
||||
printers = db_session.query(Printer).all()
|
||||
|
||||
if not printers:
|
||||
print("Keine Drucker in der Datenbank gefunden")
|
||||
db_session.close()
|
||||
return
|
||||
|
||||
print(f"Gefunden: {len(printers)} Drucker")
|
||||
|
||||
for printer in printers:
|
||||
ip_to_check = printer.plug_ip if printer.plug_ip else printer.ip_address
|
||||
print(f"Drucker: {printer.name}, IP: {ip_to_check}")
|
||||
|
||||
if ip_to_check:
|
||||
status, active = check_printer_status(ip_to_check, timeout=3)
|
||||
print(f" -> Status: {status}, Active: {active}")
|
||||
else:
|
||||
print(f" -> Keine IP-Adresse verfügbar")
|
||||
|
||||
db_session.close()
|
||||
|
||||
except Exception as e:
|
||||
print(f"Fehler beim Testen der Datenbank-Drucker: {e}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("=== Drucker-Funktionen Test ===")
|
||||
|
||||
test_ping_function()
|
||||
test_multiple_printers()
|
||||
test_database_printers()
|
||||
|
||||
print("\n=== Test abgeschlossen ===")
|
Loading…
x
Reference in New Issue
Block a user