feat(data_store): implement V3 cascading lookup and ID Vision standardization
- Added GET /v3/data_store/code/{code} with hierarchical context-aware fallback.
- Implemented ID Vision standard in Data_Store_Base (string IDs, internal int exclusion).
- Enhanced Data_Store_Base robustness to handle stringified 'NULL' values from the database.
- Fixed legacy router bugs by removing undefined parameters (inc_event_cfg, inc_event_location).
- Corrected type hints and resolved UnboundLocalError in data_store methods.
- Updated Frontend Integration Guide with Section 8: Data Store V3.
- Added unified E2E test script: tests/e2e/test_e2e_v3_data_store_lookup.py.
This commit is contained in:
93
tests/e2e/test_e2e_v3_data_store_lookup.py
Normal file
93
tests/e2e/test_e2e_v3_data_store_lookup.py
Normal file
@@ -0,0 +1,93 @@
|
||||
import requests
|
||||
import json
|
||||
import argparse
|
||||
|
||||
# --- Configuration ---
|
||||
BASE_URL = "https://dev-api.oneskyit.com"
|
||||
AGENT_API_KEY = "IDF68Em5X4HTZlswRNgepQ"
|
||||
|
||||
# Default Contexts for Testing
|
||||
CONTEXTS = {
|
||||
"account_1": "_XY7DXtc9MY",
|
||||
"account_5": "xFP7AhU8Zlc",
|
||||
"account_22": "3Iid1aIRY5j",
|
||||
"account_23": "nqOzejLCDXM",
|
||||
"event_1358": "nmBfuGFeR0k"
|
||||
}
|
||||
|
||||
def run_lookup(code, description, account_id=None, for_type=None, for_id=None, version="v3"):
|
||||
"""
|
||||
Performs a Data Store lookup and prints standardized results.
|
||||
"""
|
||||
print(f"[{version.upper()}] {description}")
|
||||
|
||||
headers = {
|
||||
"X-Aether-API-Key": AGENT_API_KEY,
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
|
||||
if account_id:
|
||||
headers["X-Account-ID"] = account_id
|
||||
else:
|
||||
headers["X-No-Account-ID"] = "bypass"
|
||||
|
||||
if version == "v3":
|
||||
url = f"{BASE_URL}/v3/data_store/code/{code}"
|
||||
params = {"for_type": for_type, "for_id": for_id}
|
||||
response = requests.get(url, headers=headers, params=params)
|
||||
else:
|
||||
# Legacy Endpoint
|
||||
if for_type and for_id:
|
||||
url = f"{BASE_URL}/data_store/code/{code}/{for_type}/{for_id}"
|
||||
else:
|
||||
url = f"{BASE_URL}/data_store/code/{code}"
|
||||
response = requests.get(url, headers=headers)
|
||||
|
||||
print(f" URL: {response.url}")
|
||||
print(f" Status: {response.status_code}")
|
||||
|
||||
if response.status_code == 200:
|
||||
data = response.json().get('data')
|
||||
if data:
|
||||
obj = data[0] if isinstance(data, list) else data
|
||||
rec_id = obj.get('id') or obj.get('data_store_id') or obj.get('data_store_id_random')
|
||||
print(f" Result: SUCCESS")
|
||||
print(f" ID: {rec_id}")
|
||||
print(f" Name: {obj.get('name')}")
|
||||
else:
|
||||
print(f" Result: NULL (No record found or validation failed)")
|
||||
else:
|
||||
print(f" Result: ERROR - {response.text[:200]}")
|
||||
print("-" * 60)
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description="Aether Data Store V3 Lookup Tester")
|
||||
parser.add_argument("--code", default="event_launcher_main_info", help="The Data Store code to test")
|
||||
args = parser.parse_args()
|
||||
|
||||
print(f"=== Aether Data Store Unified Tester ===")
|
||||
print(f"Target: {BASE_URL}")
|
||||
print(f"Code: {args.code}\n")
|
||||
|
||||
# 1. Global Context
|
||||
run_lookup(args.code, "Scenario: Global Context (Bypass Account)")
|
||||
|
||||
# 2. Account 1 Context
|
||||
run_lookup(args.code, "Scenario: Account 1 Context", account_id=CONTEXTS["account_1"])
|
||||
|
||||
# 3. Account 22 Context
|
||||
run_lookup(args.code, "Scenario: Account 22 Context", account_id=CONTEXTS["account_22"])
|
||||
|
||||
# 4. Object Specific Context (Event 1358 - belongs to Account 1)
|
||||
run_lookup(args.code, "Scenario: Event 1358 (under Account 1)",
|
||||
account_id=CONTEXTS["account_1"],
|
||||
for_type="event",
|
||||
for_id=CONTEXTS["event_1358"])
|
||||
|
||||
# 5. Cross-Account Security Check (Event 1358 requested by Account 23)
|
||||
run_lookup(args.code, "Scenario: Security Check (Event 1358 by Account 23 - SHOULD BE NULL)",
|
||||
account_id=CONTEXTS["account_23"],
|
||||
for_type="event",
|
||||
for_id=CONTEXTS["event_1358"])
|
||||
|
||||
print("\nTests Complete.")
|
||||
Reference in New Issue
Block a user