Bug fixes for uploading the files. I though the changes being made where not supposed to break legacy endpoints. Not sure what happened. Either way things are almost back to normal.
This commit is contained in:
73
tests/e2e/test_e2e_hosted_file_live_upload.py
Normal file
73
tests/e2e/test_e2e_hosted_file_live_upload.py
Normal file
@@ -0,0 +1,73 @@
|
||||
import requests
|
||||
import io
|
||||
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"
|
||||
|
||||
def test_live_file_uploads():
|
||||
print(f"--- Starting Live E2E Upload Tests against {BASE_URL} ---")
|
||||
|
||||
headers = {
|
||||
"X-Aether-API-Key": API_KEY,
|
||||
"x-account-id": ACCOUNT_ID # Route expects this as a header
|
||||
}
|
||||
|
||||
# 1. Single File Upload
|
||||
print("\n[Test 1] Single File Upload...")
|
||||
files = [
|
||||
("file_list", ("e2e_test_single.txt", io.BytesIO(b"Live E2E Single Upload Test Content"), "text/plain"))
|
||||
]
|
||||
data = {
|
||||
"account_id": ACCOUNT_ID,
|
||||
"link_to_type": LINK_TO_TYPE,
|
||||
"link_to_id": LINK_TO_ID
|
||||
}
|
||||
|
||||
url = f"{BASE_URL}/hosted_file/upload_files"
|
||||
|
||||
try:
|
||||
response = requests.post(url, headers=headers, files=files, data=data)
|
||||
print(f"Status: {response.status_code}")
|
||||
|
||||
if response.status_code == 200:
|
||||
result = response.json()
|
||||
file_data = result.get('data', [])[0]
|
||||
print(f"✅ Success! Created hosted_file_id: {file_data.get('id')}")
|
||||
print(f"Response snippet: {json.dumps(file_data, indent=2)[:200]}...")
|
||||
else:
|
||||
print(f"❌ Failed: {response.text}")
|
||||
return
|
||||
except Exception as e:
|
||||
print(f"💥 Exception: {e}")
|
||||
return
|
||||
|
||||
# 2. Triple File Upload
|
||||
print("\n[Test 2] Triple File Upload...")
|
||||
files = [
|
||||
("file_list", ("e2e_multi_1.txt", io.BytesIO(b"Content 1"), "text/plain")),
|
||||
("file_list", ("e2e_multi_2.txt", io.BytesIO(b"Content 2"), "text/plain")),
|
||||
("file_list", ("e2e_multi_3.txt", io.BytesIO(b"Content 3"), "text/plain")),
|
||||
]
|
||||
|
||||
try:
|
||||
response = requests.post(url, headers=headers, files=files, data=data)
|
||||
print(f"Status: {response.status_code}")
|
||||
|
||||
if response.status_code == 200:
|
||||
result = response.json()
|
||||
data_list = result.get('data', [])
|
||||
print(f"✅ Success! Uploaded {len(data_list)} files.")
|
||||
for i, f in enumerate(data_list):
|
||||
print(f" File {i+1} ID: {f.get('id')} | Name: {f.get('filename')}")
|
||||
else:
|
||||
print(f"❌ Failed: {response.text}")
|
||||
except Exception as e:
|
||||
print(f"💥 Exception: {e}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_live_file_uploads()
|
||||
Reference in New Issue
Block a user