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:
151
bitbylaw/scripts/adressen_sync/test_hauptadresse_explizit.py
Normal file
151
bitbylaw/scripts/adressen_sync/test_hauptadresse_explizit.py
Normal file
@@ -0,0 +1,151 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test: Hauptadresse explizit setzen
|
||||
===================================
|
||||
|
||||
Teste:
|
||||
1. Kann standardAnschrift beim POST gesetzt werden?
|
||||
2. Kann es mehrere Hauptadressen geben?
|
||||
3. Wird alte Hauptadresse automatisch deaktiviert?
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import sys
|
||||
import os
|
||||
from datetime import datetime
|
||||
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
|
||||
|
||||
from services.advoware import AdvowareAPI
|
||||
|
||||
TEST_BETNR = 104860
|
||||
|
||||
BOLD = '\033[1m'
|
||||
GREEN = '\033[92m'
|
||||
RED = '\033[91m'
|
||||
YELLOW = '\033[93m'
|
||||
BLUE = '\033[94m'
|
||||
RESET = '\033[0m'
|
||||
|
||||
def print_success(text):
|
||||
print(f"{GREEN}✓ {text}{RESET}")
|
||||
|
||||
def print_error(text):
|
||||
print(f"{RED}✗ {text}{RESET}")
|
||||
|
||||
def print_info(text):
|
||||
print(f"{BLUE}ℹ {text}{RESET}")
|
||||
|
||||
class SimpleLogger:
|
||||
def info(self, msg): pass
|
||||
def error(self, msg): pass
|
||||
def debug(self, msg): pass
|
||||
|
||||
class SimpleContext:
|
||||
def __init__(self):
|
||||
self.logger = SimpleLogger()
|
||||
|
||||
|
||||
async def main():
|
||||
print(f"\n{BOLD}TEST: standardAnschrift explizit setzen{RESET}\n")
|
||||
|
||||
context = SimpleContext()
|
||||
advo = AdvowareAPI(context=context)
|
||||
|
||||
# Test 1: Erstelle mit standardAnschrift = true
|
||||
print_info("Test 1: Erstelle Adresse mit standardAnschrift = true")
|
||||
|
||||
address_data = {
|
||||
"strasse": "Hauptadresse Explizit Test",
|
||||
"plz": "11111",
|
||||
"ort": "Hauptstadt",
|
||||
"land": "DE",
|
||||
"standardAnschrift": True, # ← EXPLIZIT gesetzt!
|
||||
"bemerkung": f"TEST-HAUPT-EXPLIZIT: {datetime.now()}"
|
||||
}
|
||||
|
||||
result = await advo.api_call(
|
||||
f'/api/v1/advonet/Beteiligte/{TEST_BETNR}/Adressen',
|
||||
method='POST',
|
||||
json_data=address_data
|
||||
)
|
||||
|
||||
created = result[0]
|
||||
print(f" Response standardAnschrift: {created.get('standardAnschrift')}")
|
||||
|
||||
# GET und prüfen
|
||||
print_info("\nHole alle Adressen und prüfe...")
|
||||
all_addresses = await advo.api_call(
|
||||
f'/api/v1/advonet/Beteiligte/{TEST_BETNR}/Adressen',
|
||||
method='GET'
|
||||
)
|
||||
|
||||
hauptadressen = [a for a in all_addresses if a.get('standardAnschrift')]
|
||||
|
||||
print(f"\n{BOLD}Ergebnis:{RESET}")
|
||||
print(f" Anzahl Hauptadressen: {len(hauptadressen)}")
|
||||
|
||||
if len(hauptadressen) > 0:
|
||||
print_success(f"\n✓ {len(hauptadressen)} Adresse(n) mit standardAnschrift = true:")
|
||||
for ha in hauptadressen:
|
||||
print(f" Index {ha.get('reihenfolgeIndex')}: {ha.get('strasse')}")
|
||||
print(f" bemerkung: {ha.get('bemerkung', 'N/A')[:50]}")
|
||||
else:
|
||||
print_error("\n✗ KEINE Hauptadresse trotz standardAnschrift = true beim POST!")
|
||||
|
||||
# Test 2: Erstelle ZWEITE mit standardAnschrift = true
|
||||
print(f"\n{BOLD}Test 2: Erstelle ZWEITE Adresse mit standardAnschrift = true{RESET}")
|
||||
|
||||
address_data2 = {
|
||||
"strasse": "Zweite Hauptadresse Test",
|
||||
"plz": "22222",
|
||||
"ort": "Zweitstadt",
|
||||
"land": "DE",
|
||||
"standardAnschrift": True,
|
||||
"bemerkung": f"TEST-HAUPT-ZWEI: {datetime.now()}"
|
||||
}
|
||||
|
||||
await advo.api_call(
|
||||
f'/api/v1/advonet/Beteiligte/{TEST_BETNR}/Adressen',
|
||||
method='POST',
|
||||
json_data=address_data2
|
||||
)
|
||||
|
||||
# GET erneut
|
||||
all_addresses = await advo.api_call(
|
||||
f'/api/v1/advonet/Beteiligte/{TEST_BETNR}/Adressen',
|
||||
method='GET'
|
||||
)
|
||||
|
||||
hauptadressen = [a for a in all_addresses if a.get('standardAnschrift')]
|
||||
|
||||
print(f"\n{BOLD}Ergebnis nach 2. Adresse:{RESET}")
|
||||
print(f" Anzahl Hauptadressen: {len(hauptadressen)}")
|
||||
|
||||
if len(hauptadressen) == 1:
|
||||
print_success("\n✓ Es gibt nur EINE Hauptadresse!")
|
||||
print_success("✓ Alte Hauptadresse wurde automatisch deaktiviert")
|
||||
print(f" Aktuelle Hauptadresse: {hauptadressen[0].get('strasse')}")
|
||||
elif len(hauptadressen) == 2:
|
||||
print_error("\n✗ Es gibt ZWEI Hauptadressen!")
|
||||
print_error("✗ Advoware erlaubt mehrere Hauptadressen")
|
||||
for ha in hauptadressen:
|
||||
print(f" - {ha.get('strasse')}")
|
||||
elif len(hauptadressen) == 0:
|
||||
print_error("\n✗ KEINE Hauptadresse!")
|
||||
print_error("✗ standardAnschrift wird nicht gespeichert")
|
||||
|
||||
print(f"\n{BOLD}FAZIT:{RESET}")
|
||||
if len(hauptadressen) == 1:
|
||||
print_success("✓ Advoware verwaltet automatisch EINE Hauptadresse")
|
||||
print_success("✓ Neue Hauptadresse deaktiviert alte automatisch")
|
||||
elif len(hauptadressen) > 1:
|
||||
print_error("✗ Mehrere Hauptadressen möglich")
|
||||
else:
|
||||
print_error("✗ standardAnschrift ist möglicherweise READ-ONLY")
|
||||
|
||||
print(f"\n{YELLOW}⚠️ Test-Adressen mit 'TEST-HAUPT' bereinigen{RESET}\n")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
Reference in New Issue
Block a user