Files
OSIT-AE-API-FastAPI/tests/archive/test_e2e_hosted_file_live_delete.py
Scott Idem 29f6cf258f chore(tests): reorganize test suite and archive redundant scripts
- Moved legacy/redundant tests to tests/archive/.
- Relocated root-level debug scripts to tests/integration/.
- Updated tests/README.md with final organized inventory.
- Cleaned up root directory from one-off reproduction scripts.
2026-02-03 16:18:57 -05:00

79 lines
2.6 KiB
Python

import requests
import json
# Configuration
BASE_URL = "https://dev-api.oneskyit.com"
API_KEY = "IDF68Em5X4HTZlswRNgepQ"
ACCOUNT_ID = "Q8lR8Ai8hx2FjbQ3C_EH1Q"
LINK_TO_TYPE = "archive_content"
LINK_TO_ID = "bZOa7CtUm0E"
# IDs created in the previous turn
FILE_IDS = ['2R06T6yuQLw', 'dG60rqQK-mA', 'sKMzAD5mlwo', 'Ob-voYn7SkY']
def delete_file(file_id, rm_orphan=False):
print(f"\n--- Deleting File ID: {file_id} (rm_orphan={rm_orphan}) ---")
url = f"{BASE_URL}/hosted_file/{file_id}"
params = {
"link_to_type": LINK_TO_TYPE,
"link_to_id": LINK_TO_ID,
"rm_orphan": str(rm_orphan).lower()
}
headers = {
"X-Aether-API-Key": API_KEY,
"x-account-id": ACCOUNT_ID
}
try:
response = requests.delete(url, headers=headers, params=params)
print(f"Status Code: {response.status_code}")
if response.status_code == 200:
print(f"✅ Success: {response.json().get('status_message')}")
return True
else:
print(f"❌ Failed: {response.text}")
return False
except Exception as e:
print(f"💥 Exception: {e}")
return False
def verify_file_exists(file_id):
url = f"{BASE_URL}/hosted_file/{file_id}"
headers = {
"X-Aether-API-Key": API_KEY,
"x-account-id": ACCOUNT_ID
}
response = requests.get(url, headers=headers)
return response.status_code == 200
if __name__ == "__main__":
print("Starting Live E2E Deletion Tests...")
# 1. Delete one link WITHOUT rm_orphan
# The record should still exist in the DB (but link is gone)
target_1 = FILE_IDS[0]
if delete_file(target_1, rm_orphan=False):
exists = verify_file_exists(target_1)
print(f"Verification: File record exists after link-only delete? {exists}")
if not exists:
print("⚠️ Warning: File record was deleted even though rm_orphan=False (or it was already missing).")
# 2. Delete one link WITH rm_orphan=True
# Since these files only have one link, the record and physical file should be deleted.
target_2 = FILE_IDS[1]
if delete_file(target_2, rm_orphan=True):
exists = verify_file_exists(target_2)
print(f"Verification: File record exists after orphan delete? {exists}")
if exists:
print("❌ Failure: File record still exists after rm_orphan=True.")
else:
print("✅ Success: File record was correctly removed.")
# 3. Cleanup the rest
print("\n--- Cleaning up remaining files ---")
for fid in FILE_IDS[2:]:
delete_file(fid, rm_orphan=True)
print("\nTests Complete.")