Add tests for Kommunikation Sync implementation and verification scripts
- Implemented comprehensive tests for the Kommunikation Sync functionality, covering base64 encoding, marker parsing, creation, type detection, and integration scenarios. - Added a verification script to check for unique IDs in Advoware communications, ensuring stability and integrity of the IDs. - Created utility scripts for code validation, notification testing, and PUT response detail analysis to enhance development and testing processes. - Updated README with details on new tools and their usage.
This commit is contained in:
152
bitbylaw/scripts/analysis/analyze_beteiligte_endpoint.py
Normal file
152
bitbylaw/scripts/analysis/analyze_beteiligte_endpoint.py
Normal file
@@ -0,0 +1,152 @@
|
||||
"""
|
||||
Detaillierte Analyse: Was liefert /api/v1/advonet/Beteiligte/{id}?
|
||||
|
||||
Prüfe:
|
||||
1. Kommunikation-Array: Alle Felder
|
||||
2. kommKz und kommArt Werte
|
||||
3. Adressen-Array (falls enthalten)
|
||||
4. Vollständige Struktur
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
from services.advoware import AdvowareAPI
|
||||
|
||||
TEST_BETNR = 104860
|
||||
|
||||
|
||||
class SimpleContext:
|
||||
class Logger:
|
||||
def info(self, msg): print(f"[INFO] {msg}")
|
||||
def error(self, msg): print(f"[ERROR] {msg}")
|
||||
def warning(self, msg): print(f"[WARN] {msg}")
|
||||
def debug(self, msg): pass
|
||||
|
||||
def __init__(self):
|
||||
self.logger = self.Logger()
|
||||
|
||||
|
||||
def print_section(title):
|
||||
print("\n" + "="*70)
|
||||
print(title)
|
||||
print("="*70)
|
||||
|
||||
|
||||
async def main():
|
||||
print("\n" + "="*70)
|
||||
print("DETAILLIERTE ANALYSE: Beteiligte Endpoint")
|
||||
print("="*70)
|
||||
|
||||
context = SimpleContext()
|
||||
advo = AdvowareAPI(context)
|
||||
|
||||
# Hole kompletten Beteiligte
|
||||
print(f"\n📋 GET /api/v1/advonet/Beteiligte/{TEST_BETNR}")
|
||||
result = await advo.api_call(f'api/v1/advonet/Beteiligte/{TEST_BETNR}')
|
||||
|
||||
print(f"\nResponse Type: {type(result)}")
|
||||
if isinstance(result, list):
|
||||
print(f"Response Length: {len(result)}")
|
||||
beteiligte = result[0]
|
||||
else:
|
||||
beteiligte = result
|
||||
|
||||
# Zeige Top-Level Struktur
|
||||
print_section("TOP-LEVEL FELDER")
|
||||
print(f"\nVerfügbare Keys:")
|
||||
for key in sorted(beteiligte.keys()):
|
||||
value = beteiligte[key]
|
||||
if isinstance(value, list):
|
||||
print(f" • {key:30s}: [{len(value)} items]")
|
||||
elif isinstance(value, dict):
|
||||
print(f" • {key:30s}: {{dict}}")
|
||||
else:
|
||||
value_str = str(value)[:50]
|
||||
print(f" • {key:30s}: {value_str}")
|
||||
|
||||
# Kommunikationen
|
||||
print_section("KOMMUNIKATION ARRAY")
|
||||
|
||||
kommunikationen = beteiligte.get('kommunikation', [])
|
||||
print(f"\n✅ {len(kommunikationen)} Kommunikationen gefunden")
|
||||
|
||||
if kommunikationen:
|
||||
print(f"\n📋 Erste Kommunikation - ALLE Felder:")
|
||||
first = kommunikationen[0]
|
||||
print(json.dumps(first, indent=2, ensure_ascii=False))
|
||||
|
||||
print(f"\n📊 Übersicht aller Kommunikationen:")
|
||||
print(f"\n{'ID':>8s} | {'kommKz':>6s} | {'kommArt':>7s} | {'online':>6s} | {'Wert':40s} | {'Bemerkung'}")
|
||||
print("-" * 120)
|
||||
|
||||
for k in kommunikationen:
|
||||
komm_id = k.get('id', 'N/A')
|
||||
kommkz = k.get('kommKz', 'N/A')
|
||||
kommart = k.get('kommArt', 'N/A')
|
||||
online = k.get('online', False)
|
||||
wert = (k.get('tlf') or '')[:40]
|
||||
bemerkung = (k.get('bemerkung') or '')[:20]
|
||||
|
||||
# Highlighting
|
||||
kommkz_str = f"✅ {kommkz}" if kommkz not in [0, 'N/A'] else f"❌ {kommkz}"
|
||||
kommart_str = f"✅ {kommart}" if kommart not in [0, 'N/A'] else f"❌ {kommart}"
|
||||
|
||||
print(f"{komm_id:8} | {kommkz_str:>6s} | {kommart_str:>7s} | {str(online):>6s} | {wert:40s} | {bemerkung}")
|
||||
|
||||
# Adressen
|
||||
print_section("ADRESSEN ARRAY")
|
||||
|
||||
adressen = beteiligte.get('adressen', [])
|
||||
print(f"\n✅ {len(adressen)} Adressen gefunden")
|
||||
|
||||
if adressen:
|
||||
print(f"\n📋 Erste Adresse - Struktur:")
|
||||
first_addr = adressen[0]
|
||||
print(json.dumps(first_addr, indent=2, ensure_ascii=False))
|
||||
|
||||
# Bankverbindungen
|
||||
print_section("BANKVERBINDUNGEN")
|
||||
|
||||
bankverb = beteiligte.get('bankkverbindungen', []) # Typo im API?
|
||||
if not bankverb:
|
||||
bankverb = beteiligte.get('bankverbindungen', [])
|
||||
|
||||
print(f"\n✅ {len(bankverb)} Bankverbindungen gefunden")
|
||||
|
||||
if bankverb:
|
||||
print(f"\n📋 Erste Bankverbindung - Keys:")
|
||||
print(list(bankverb[0].keys()))
|
||||
|
||||
# Analyse
|
||||
print_section("ZUSAMMENFASSUNG")
|
||||
|
||||
print(f"\n📊 Verfügbare Daten:")
|
||||
print(f" • Kommunikationen: {len(kommunikationen)}")
|
||||
print(f" • Adressen: {len(adressen)}")
|
||||
print(f" • Bankverbindungen: {len(bankverb)}")
|
||||
|
||||
print(f"\n🔍 kommKz/kommArt Status:")
|
||||
if kommunikationen:
|
||||
kommkz_values = [k.get('kommKz', 0) for k in kommunikationen]
|
||||
kommart_values = [k.get('kommArt', 0) for k in kommunikationen]
|
||||
|
||||
kommkz_non_zero = [v for v in kommkz_values if v != 0]
|
||||
kommart_non_zero = [v for v in kommart_values if v != 0]
|
||||
|
||||
print(f" • kommKz unique values: {set(kommkz_values)}")
|
||||
print(f" • kommKz non-zero count: {len(kommkz_non_zero)} / {len(kommunikationen)}")
|
||||
|
||||
print(f" • kommArt unique values: {set(kommart_values)}")
|
||||
print(f" • kommArt non-zero count: {len(kommart_non_zero)} / {len(kommunikationen)}")
|
||||
|
||||
if kommkz_non_zero:
|
||||
print(f"\n ✅✅✅ JACKPOT! kommKz HAT WERTE im Beteiligte-Endpoint!")
|
||||
print(f" → Wir können den Typ korrekt erkennen!")
|
||||
elif kommart_non_zero:
|
||||
print(f"\n ✅ kommArt hat Werte (Email/Phone unterscheidbar)")
|
||||
else:
|
||||
print(f"\n ❌ Beide sind 0 - müssen Typ aus Wert ableiten")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
Reference in New Issue
Block a user