feat(models): implement Vision ID pattern for event_device and event_session
- Migrated event_device and event_session models to the V3 Vision ID pattern (string-based public IDs). - Added root_validator for automatic id_random mapping and integer stripping. - Implemented fields_to_exclude_from_db to protect database updates from convenience/view fields. - Fixed description_json type in Journal_Base for correct JSON parsing. - Added E2E verification tests for event_device and event_session V3 endpoints.
This commit is contained in:
60
tests/e2e/test_e2e_v3_event_device.py
Normal file
60
tests/e2e/test_e2e_v3_event_device.py
Normal file
@@ -0,0 +1,60 @@
|
||||
import requests
|
||||
import json
|
||||
import sys
|
||||
|
||||
# Configuration
|
||||
BASE_URL = "https://dev-api.oneskyit.com/v3/crud"
|
||||
# Using the API key found in the database
|
||||
API_KEY = "PHDXUJxx6IgmLNKxIBezTQ"
|
||||
# Event Device ID found in the database
|
||||
DEVICE_ID = "GZvFjgIIZQg"
|
||||
|
||||
def get_headers():
|
||||
headers = {
|
||||
"Content-Type": "application/json",
|
||||
"X-Aether-API-Key": API_KEY,
|
||||
"X-No-Account-ID": "bypass"
|
||||
}
|
||||
return headers
|
||||
|
||||
def test_get_event_device():
|
||||
print(f"--- Testing: Get Event Device by ID ({DEVICE_ID}) ---")
|
||||
url = f"{BASE_URL}/event_device/{DEVICE_ID}"
|
||||
|
||||
headers = get_headers()
|
||||
|
||||
try:
|
||||
response = requests.get(url, headers=headers)
|
||||
|
||||
print(f"URL: {response.url}")
|
||||
print(f"Status Code: {response.status_code}")
|
||||
|
||||
if response.status_code == 200:
|
||||
data = response.json().get('data', {})
|
||||
print("✅ SUCCESS: Found Event Device.")
|
||||
|
||||
# Verify Vision ID pattern (Strings only for ID fields)
|
||||
vision_fields = ["id", "event_device_id", "account_id", "event_id", "event_location_id"]
|
||||
for field in vision_fields:
|
||||
val = data.get(field)
|
||||
print(f" Field '{field}': {val} (type: {type(val).__name__})")
|
||||
if val is not None:
|
||||
assert isinstance(val, str), f"Error: Field '{field}' should be a string, but got {type(val).__name__}"
|
||||
|
||||
# Check for any unexpected integer IDs
|
||||
for key, val in data.items():
|
||||
if key.endswith("_id") and not key.endswith("external_id"):
|
||||
if isinstance(val, int):
|
||||
print(f" ❌ FAILURE: Integer leakage detected in field '{key}': {val}")
|
||||
# assert False, f"Integer leakage in '{key}'"
|
||||
else:
|
||||
print(f"❌ FAILURE: {response.text}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error during test: {e}")
|
||||
print("-" * 40 + "\n")
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(f"Starting Aether V3 Event Device E2E Tests against {BASE_URL}\n")
|
||||
test_get_event_device()
|
||||
print("Tests Complete.")
|
||||
59
tests/e2e/test_e2e_v3_event_session.py
Normal file
59
tests/e2e/test_e2e_v3_event_session.py
Normal file
@@ -0,0 +1,59 @@
|
||||
import requests
|
||||
import json
|
||||
import sys
|
||||
|
||||
# Configuration
|
||||
BASE_URL = "https://dev-api.oneskyit.com/v3/crud"
|
||||
# Using the API key found in the database
|
||||
API_KEY = "PHDXUJxx6IgmLNKxIBezTQ"
|
||||
# Event Session ID found in the database
|
||||
SESSION_ID = "F0PZd1bNcuD"
|
||||
|
||||
def get_headers():
|
||||
headers = {
|
||||
"Content-Type": "application/json",
|
||||
"X-Aether-API-Key": API_KEY,
|
||||
"X-No-Account-ID": "bypass"
|
||||
}
|
||||
return headers
|
||||
|
||||
def test_get_event_session():
|
||||
print(f"--- Testing: Get Event Session by ID ({SESSION_ID}) ---")
|
||||
url = f"{BASE_URL}/event_session/{SESSION_ID}"
|
||||
|
||||
headers = get_headers()
|
||||
|
||||
try:
|
||||
response = requests.get(url, headers=headers)
|
||||
|
||||
print(f"URL: {response.url}")
|
||||
print(f"Status Code: {response.status_code}")
|
||||
|
||||
if response.status_code == 200:
|
||||
data = response.json().get('data', {})
|
||||
print("✅ SUCCESS: Found Event Session.")
|
||||
|
||||
# Verify Vision ID pattern (Strings only for ID fields)
|
||||
vision_fields = ["id", "event_session_id", "event_id", "event_location_id", "event_track_id", "poc_event_person_id", "poc_person_id"]
|
||||
for field in vision_fields:
|
||||
val = data.get(field)
|
||||
print(f" Field '{field}': {val} (type: {type(val).__name__})")
|
||||
if val is not None:
|
||||
assert isinstance(val, str), f"Error: Field '{field}' should be a string, but got {type(val).__name__}"
|
||||
|
||||
# Check for any unexpected integer IDs
|
||||
for key, val in data.items():
|
||||
if key.endswith("_id") and not key.endswith("external_id"):
|
||||
if isinstance(val, int):
|
||||
print(f" ❌ FAILURE: Integer leakage detected in field '{key}': {val}")
|
||||
else:
|
||||
print(f"❌ FAILURE: {response.text}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error during test: {e}")
|
||||
print("-" * 40 + "\n")
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(f"Starting Aether V3 Event Session E2E Tests against {BASE_URL}\n")
|
||||
test_get_event_session()
|
||||
print("Tests Complete.")
|
||||
Reference in New Issue
Block a user