Files
Brancheneinstufung2/connector-superoffice/tools/cleanup_test_data.py
Floke d021b6b71c refactor: [30388f42] Strukturiere Root-Skripte thematisch neu
- Organisiert eine Vielzahl von Skripten aus dem Root-Verzeichnis in thematische Unterordner, um die Übersichtlichkeit zu verbessern und die Migration vorzubereiten.
- Verschiebt SuperOffice-bezogene Test- und Hilfsskripte in .
- Verschiebt Notion-bezogene Synchronisations- und Import-Skripte in .
- Archiviert eindeutig veraltete und ungenutzte Skripte in .
- Die zentralen Helfer  und  bleiben im Root, da sie von mehreren Tools als Abhängigkeit genutzt werden.
2026-03-06 10:16:08 +00:00

41 lines
1.3 KiB
Python

import sys
import os
import requests
from dotenv import load_dotenv
# Ensure we use the correct config and client
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'connector-superoffice')))
from superoffice_client import SuperOfficeClient
def cleanup():
print("🧹 Cleaning up Test Data...")
client = SuperOfficeClient()
if not client.access_token:
print("❌ Auth failed.")
return
# Objects to delete (Reverse order of dependency)
to_delete = [
("Sale", 342539),
("Appointment", 993350),
("Appointment", 993347),
("Person", 193092),
("Contact", 171185) # Attempting to delete the company too
]
for entity_type, entity_id in to_delete:
print(f"🗑️ Deleting {entity_type} {entity_id}...")
try:
# SuperOffice DELETE usually returns 204 No Content
# Our client returns None on success if response body is empty, or the JSON if not.
# We need to catch exceptions if it fails.
resp = client._delete(f"{entity_type}/{entity_id}")
print(f"✅ Deleted {entity_type} {entity_id}")
except Exception as e:
print(f"⚠️ Failed to delete {entity_type} {entity_id}: {e}")
if __name__ == "__main__":
cleanup()