Files
motia/bitbylaw/scripts/tools/test_put_response_detail.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

128 lines
3.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
"""
Test: Welche Felder sind bei PUT wirklich änderbar?
====================================================
"""
import asyncio
import sys
import os
import json
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
from services.advoware import AdvowareAPI
TEST_BETNR = 104860
BOLD = '\033[1m'
RED = '\033[91m'
GREEN = '\033[92m'
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
def warning(self, msg): pass
class SimpleContext:
def __init__(self):
self.logger = SimpleLogger()
async def main():
print(f"\n{BOLD}=== PUT Response Analyse ==={RESET}\n")
context = SimpleContext()
advo = AdvowareAPI(context=context)
# Finde Test-Adresse
all_addresses = await advo.api_call(
f'/api/v1/advonet/Beteiligte/{TEST_BETNR}/Adressen',
method='GET'
)
test_addr = None
for addr in all_addresses:
bemerkung = addr.get('bemerkung') or ''
if 'TEST-SOFTDELETE' in bemerkung:
test_addr = addr
break
if not test_addr:
print_error("Test-Adresse nicht gefunden")
return
index = test_addr.get('reihenfolgeIndex')
print_info(f"Test-Adresse Index: {index}")
print_info("\nVORHER:")
print(json.dumps(test_addr, indent=2, ensure_ascii=False))
# PUT mit ALLEN Feldern inklusive gueltigBis
print_info("\n=== Sende PUT mit ALLEN Feldern ===")
update_data = {
"strasse": "GEÄNDERT Straße",
"plz": "11111",
"ort": "GEÄNDERT Ort",
"land": "AT",
"postfach": "PF 123",
"postfachPLZ": "11112",
"anschrift": "GEÄNDERT Anschrift",
"standardAnschrift": True,
"bemerkung": "VERSUCH: bemerkung ändern",
"gueltigVon": "2025-01-01T00:00:00", # ← GEÄNDERT
"gueltigBis": "2027-12-31T23:59:59" # ← NEU GESETZT
}
print(json.dumps(update_data, indent=2, ensure_ascii=False))
result = await advo.api_call(
f'/api/v1/advonet/Beteiligte/{TEST_BETNR}/Adressen/{index}',
method='PUT',
json_data=update_data
)
print_info("\n=== PUT Response: ===")
print(json.dumps(result, indent=2, ensure_ascii=False))
# GET und vergleichen
print_info("\n=== GET nach PUT: ===")
all_addresses = await advo.api_call(
f'/api/v1/advonet/Beteiligte/{TEST_BETNR}/Adressen',
method='GET'
)
updated_addr = next((a for a in all_addresses if a.get('reihenfolgeIndex') == index), None)
if updated_addr:
print(json.dumps(updated_addr, indent=2, ensure_ascii=False))
print(f"\n{BOLD}=== VERGLEICH: Was wurde wirklich geändert? ==={RESET}\n")
fields = ['strasse', 'plz', 'ort', 'land', 'postfach', 'postfachPLZ',
'anschrift', 'standardAnschrift', 'bemerkung', 'gueltigVon', 'gueltigBis']
for field in fields:
sent = update_data.get(field)
received = updated_addr.get(field)
if sent == received:
print_success(f"{field:20s}: ✓ GEÄNDERT → {received}")
else:
print_error(f"{field:20s}: ✗ NICHT geändert (sent: {sent}, got: {received})")
if __name__ == "__main__":
asyncio.run(main())