Files
motia/bitbylaw/scripts/kommunikation_sync/test_kommart_values.py
bitbylaw 7856dd1d68 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.
2026-02-08 23:05:56 +00:00

110 lines
3.3 KiB
Python

"""
Test: Was liefert kommArt im Vergleich zu kommKz?
kommArt sollte sein:
- 0 = Telefon/Fax
- 1 = Email
- 2 = Internet
Wenn kommArt funktioniert, können wir damit unterscheiden!
"""
import asyncio
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("ADVOWARE kommArt vs kommKz")
print("="*70)
context = SimpleContext()
advo = AdvowareAPI(context)
# Hole Beteiligte mit Kommunikationen
result = await advo.api_call(f'api/v1/advonet/Beteiligte/{TEST_BETNR}')
beteiligte = result[0]
kommunikationen = beteiligte.get('kommunikation', [])
print(f"\n{len(kommunikationen)} Kommunikationen gefunden\n")
print(f"{'ID':>8s} | {'kommKz':>6s} | {'kommArt':>7s} | {'Wert':40s}")
print("-" * 70)
kommkz_values = []
kommart_values = []
for k in kommunikationen:
komm_id = k.get('id')
kommkz = k.get('kommKz', 'N/A')
kommart = k.get('kommArt', 'N/A')
wert = k.get('tlf', '')[:40]
kommkz_values.append(kommkz)
kommart_values.append(kommart)
# Markiere wenn Wert aussagekräftig ist
kommkz_str = f"{kommkz}" if kommkz != 0 else f"{kommkz}"
kommart_str = f"{kommart}" if kommart != 0 else f"{kommart}"
print(f"{komm_id:8d} | {kommkz_str:>6s} | {kommart_str:>7s} | {wert}")
print_section("ANALYSE")
# Statistik
print(f"\n📊 kommKz Werte:")
print(f" • Alle Werte: {set(kommkz_values)}")
print(f" • Alle sind 0: {all(v == 0 for v in kommkz_values)}")
print(f"\n📊 kommArt Werte:")
print(f" • Alle Werte: {set(kommart_values)}")
print(f" • Alle sind 0: {all(v == 0 for v in kommart_values)}")
print_section("FAZIT")
if not all(v == 0 for v in kommart_values):
print("\n✅ kommArt IST BRAUCHBAR!")
print("\nMapping:")
print(" 0 = Telefon/Fax")
print(" 1 = Email")
print(" 2 = Internet")
print("\n🎉 PERFEKT! Wir können unterscheiden:")
print(" • kommArt=0 → Telefon (zu phoneNumberData)")
print(" • kommArt=1 → Email (zu emailAddressData)")
print(" • kommArt=2 → Internet (überspringen oder zu Notiz)")
print("\n💡 Advoware → EspoCRM:")
print(" 1. Nutze kommArt um Typ zu erkennen")
print(" 2. Speichere in bemerkung: [ESPOCRM:hash:kommArt]")
print(" 3. Bei Reverse-Sync: Nutze kommArt aus bemerkung")
else:
print("\n❌ kommArt ist AUCH 0 - genau wie kommKz")
print("\n→ Wir müssen Typ aus Wert ableiten (Email vs. Telefon)")
print("'@' im Wert → Email")
print("'+' oder Ziffern → Telefon")
print("\n→ Feinere Unterscheidung (TelGesch vs TelPrivat) NICHT möglich")
if __name__ == "__main__":
asyncio.run(main())