chore(tests): consolidate E2E test suite into standardized primary scripts
- Combined 10+ one-off tests into 4 primary functional suites (Search, Auth, Lifecycle, Vision). - Archived original scripts to tests/archive/. - Updated README with the new standardized inventory. - Applied clean output formatting across the new suite.
This commit is contained in:
90
tests/e2e/test_e2e_v3_actions_file_lifecycle.py
Normal file
90
tests/e2e/test_e2e_v3_actions_file_lifecycle.py
Normal file
@@ -0,0 +1,90 @@
|
||||
import requests
|
||||
import io
|
||||
import json
|
||||
import os
|
||||
|
||||
# --- Configuration ---
|
||||
API_BASE = "https://dev-api.oneskyit.com/v3/action"
|
||||
API_KEY = "PMM4n50teUCaOMMTN8qOJA"
|
||||
ACCOUNT_ID = "Q8lR8Ai8hx2FjbQ3C_EH1Q" # OSIT
|
||||
# Linking target for test files
|
||||
LINK_TYPE = "archive_content"
|
||||
LINK_ID = "bZOa7CtUm0E"
|
||||
|
||||
def get_headers():
|
||||
return {
|
||||
"X-Aether-API-Key": API_KEY,
|
||||
"x-account-id": ACCOUNT_ID,
|
||||
"x-no-account-id": "bypass"
|
||||
}
|
||||
|
||||
def test_file_lifecycle():
|
||||
print(f"--- Starting Hosted File Lifecycle Test ---")
|
||||
|
||||
# 1. UPLOAD
|
||||
print("\n[Step 1] Uploading test file...")
|
||||
test_content = b"Lifecycle Test Content: " + os.urandom(8).hex().encode()
|
||||
files = [("file_list", ("lifecycle_test.txt", io.BytesIO(test_content), "text/plain"))]
|
||||
data = {"account_id": ACCOUNT_ID, "link_to_type": LINK_TYPE, "link_to_id": LINK_ID}
|
||||
|
||||
up_resp = requests.post(f"{API_BASE}/hosted_file/upload", headers=get_headers(), files=files, data=data)
|
||||
if up_resp.status_code != 200:
|
||||
print(f" ❌ Upload Failed: {up_resp.text}")
|
||||
return False
|
||||
|
||||
file_info = up_resp.json()['data'][0]
|
||||
file_id = file_info['id']
|
||||
file_hash = file_info['hash_sha256']
|
||||
subdir = file_hash[:2]
|
||||
expected_path = f"/srv/aether_api/srv/ae_hosted_files/{subdir}/{file_hash}.file"
|
||||
print(f" ✅ Uploaded: {file_id} (Hash: {file_hash[:10]}...)")
|
||||
print(f" 🔍 Expected physical path: {expected_path}")
|
||||
|
||||
# 2. DOWNLOAD (Direct)
|
||||
print("\n[Step 2] Downloading by ID...")
|
||||
dl_resp = requests.get(f"{API_BASE}/hosted_file/{file_id}/download", headers=get_headers())
|
||||
if dl_resp.status_code == 200 and dl_resp.content == test_content:
|
||||
print(f" ✅ Downloaded content matches original.")
|
||||
else:
|
||||
print(f" ❌ Download Failed or content mismatch. Status: {dl_resp.status_code}")
|
||||
print(f" Original: {test_content}")
|
||||
print(f" Received: {dl_resp.content}")
|
||||
return False
|
||||
|
||||
# 3. DOWNLOAD (Hash + Query Auth)
|
||||
print("\n[Step 3] Downloading by Hash (Query Auth)...")
|
||||
hash_url = f"{API_BASE}/hosted_file/hash/{file_hash}/download?api_key={API_KEY}"
|
||||
h_dl_resp = requests.get(hash_url)
|
||||
if h_dl_resp.status_code == 200:
|
||||
print(f" ✅ Hash download successful.")
|
||||
else:
|
||||
print(f" ❌ Hash download failed: {h_dl_resp.status_code}")
|
||||
return False
|
||||
|
||||
# 4. DELETE (Clean Cleanup)
|
||||
print("\n[Step 4] Deleting test file (rm_orphan=true)...")
|
||||
del_params = {"rm_orphan": "true", "method": "delete"}
|
||||
del_resp = requests.delete(f"{API_BASE}/hosted_file/{file_id}", headers=get_headers(), params=del_params)
|
||||
if del_resp.status_code == 200:
|
||||
print(f" ✅ Deletion request successful.")
|
||||
else:
|
||||
print(f" ❌ Deletion failed: {del_resp.text}")
|
||||
return False
|
||||
|
||||
# 5. VERIFY DELETED
|
||||
print("\n[Step 5] Verifying record is gone...")
|
||||
check_resp = requests.get(f"https://dev-api.oneskyit.com/v3/crud/hosted_file/{file_id}", headers=get_headers())
|
||||
if check_resp.status_code == 404:
|
||||
print(f" ✅ Success: Record purged from DB.")
|
||||
else:
|
||||
print(f" ❌ Failure: Record still exists after deletion.")
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
if __name__ == "__main__":
|
||||
if test_file_lifecycle():
|
||||
print("\n🎉 HOSTED FILE LIFECYCLE VERIFIED!")
|
||||
else:
|
||||
print("\n❌ LIFECYCLE TEST FAILED.")
|
||||
exit(1)
|
||||
Reference in New Issue
Block a user