V3 Migration Phase 2-4: Implementation of specialized Binary Actions (Upload, Stream, Delete) and Orphan management logic. Full E2E coverage.
This commit is contained in:
70
tests/e2e/test_e2e_v3_action_delete.py
Normal file
70
tests/e2e/test_e2e_v3_action_delete.py
Normal file
@@ -0,0 +1,70 @@
|
||||
import requests
|
||||
import json
|
||||
import io
|
||||
|
||||
# Configuration
|
||||
BASE_URL = "https://dev-api.oneskyit.com/v3/action/hosted_file"
|
||||
API_KEY = "IDF68Em5X4HTZlswRNgepQ"
|
||||
ACCOUNT_ID = "Q8lR8Ai8hx2FjbQ3C_EH1Q"
|
||||
LINK_TO_TYPE = "archive_content"
|
||||
LINK_TO_ID = "bZOa7CtUm0E"
|
||||
|
||||
def test_v3_delete_flow():
|
||||
print(f"--- Starting V3 Action Delete Tests ---")
|
||||
|
||||
headers = {
|
||||
"X-Aether-API-Key": API_KEY,
|
||||
"x-account-id": ACCOUNT_ID
|
||||
}
|
||||
|
||||
# 1. Setup: Upload a fresh file to test with
|
||||
print("\n[Step 1] Uploading test file...")
|
||||
files = [("file_list", ("v3_delete_test.txt", io.BytesIO(b"Delete me"), "text/plain"))]
|
||||
data = {
|
||||
"account_id": ACCOUNT_ID,
|
||||
"link_to_type": LINK_TO_TYPE,
|
||||
"link_to_id": LINK_TO_ID
|
||||
}
|
||||
up_resp = requests.post(f"{BASE_URL}/upload", headers=headers, files=files, data=data)
|
||||
file_id = up_resp.json()['data'][0]['id']
|
||||
print(f"Created file: {file_id}")
|
||||
|
||||
# 2. Test Fake Delete
|
||||
print("\n[Step 2] Testing Fake Delete (Testing Mode)...")
|
||||
params_fake = {
|
||||
"link_to_type": LINK_TO_TYPE,
|
||||
"link_to_id": LINK_TO_ID,
|
||||
"fake_delete": "true"
|
||||
}
|
||||
resp_fake = requests.delete(f"{BASE_URL}/{file_id}", headers=headers, params=params_fake)
|
||||
print(f"Status: {resp_fake.status_code}")
|
||||
print(f"Response: {json.dumps(resp_fake.json()['data'], indent=2)}")
|
||||
assert resp_fake.json()['data']['fake_delete'] == True
|
||||
|
||||
# 3. Test Real Delete (Link Only)
|
||||
print("\n[Step 3] Testing Real Delete (Link Only, rm_orphan=False)...")
|
||||
params_link = {
|
||||
"link_to_type": LINK_TO_TYPE,
|
||||
"link_to_id": LINK_TO_ID,
|
||||
"rm_orphan": "false"
|
||||
}
|
||||
resp_link = requests.delete(f"{BASE_URL}/{file_id}", headers=headers, params=params_link)
|
||||
print(f"Status: {resp_link.status_code}")
|
||||
print(f"Response: {json.dumps(resp_link.json()['data'], indent=2)}")
|
||||
assert resp_link.json()['data']['link_removed'] == True
|
||||
assert resp_link.json()['data']['is_orphan'] == True # Should be orphan now, but not removed
|
||||
|
||||
# 4. Test Orphan Cleanup (rm_orphan=True)
|
||||
print("\n[Step 4] Testing Orphan Cleanup (rm_orphan=True, method=delete)...")
|
||||
params_orphan = {
|
||||
"rm_orphan": "true",
|
||||
"method": "delete"
|
||||
}
|
||||
resp_orphan = requests.delete(f"{BASE_URL}/{file_id}", headers=headers, params=params_orphan)
|
||||
print(f"Status: {resp_orphan.status_code}")
|
||||
print(f"Response: {json.dumps(resp_orphan.json()['data'], indent=2)}")
|
||||
assert resp_orphan.json()['data']['physical_removed'] == True
|
||||
assert resp_orphan.json()['data']['record_removed'] == True
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_v3_delete_flow()
|
||||
Reference in New Issue
Block a user