- Moved scattered Python test scripts from root and 'admin/development/' to 'tests/'. - Beautified the HTML email body for account creation links in 'app/methods/person_methods.py' with a modern responsive design.
68 lines
2.1 KiB
Python
68 lines
2.1 KiB
Python
import requests
|
|
import json
|
|
import sys
|
|
|
|
# Configuration
|
|
BASE_URL = "https://dev-api.oneskyit.com/v3/crud"
|
|
|
|
# --- AUTHENTICATION CONFIG ---
|
|
ACCOUNT_ID = "nqOzejLCDXM" # Legacy Header Fallback
|
|
|
|
def get_headers():
|
|
headers = {
|
|
"Content-Type": "application/json",
|
|
"X-Account-ID": ACCOUNT_ID
|
|
}
|
|
return headers
|
|
|
|
def test_endpoint(method, path, description, query=None, params=None):
|
|
"""
|
|
Helper to run a test and print results.
|
|
"""
|
|
print(f"--- Testing: {description} ---")
|
|
url = f"{BASE_URL}{path}"
|
|
|
|
request_headers = get_headers()
|
|
|
|
try:
|
|
if method == "GET":
|
|
response = requests.get(url, headers=request_headers, params=params)
|
|
elif method == "POST":
|
|
response = requests.post(url, headers=request_headers, json=query, params=params)
|
|
|
|
print(f"URL: {response.url}")
|
|
print(f"Status Code: {response.status_code}")
|
|
|
|
data = response.json()
|
|
|
|
# Check if the result is a list or single object
|
|
result_data = data.get('data')
|
|
if isinstance(result_data, list):
|
|
print(f"Result Count: {len(result_data)}")
|
|
if len(result_data) > 0:
|
|
print(f"First Item Example: {json.dumps(result_data[0], indent=2)}")
|
|
else:
|
|
print(f"Result Type: {type(result_data)}")
|
|
print(f"Result Data: {json.dumps(result_data, indent=2)}")
|
|
|
|
if response.status_code != 200:
|
|
print(f"Error Message: {data.get('status_message')}")
|
|
|
|
except Exception as e:
|
|
print(f"Error during test: {e}")
|
|
print("-" * 40 + "\n")
|
|
|
|
if __name__ == "__main__":
|
|
print(f"Starting Aether V3 Account Tests against {BASE_URL}\n")
|
|
|
|
# 1. List Accounts
|
|
test_endpoint("GET", "/account/", "List Accounts (GET)")
|
|
|
|
# 2. Search Accounts (Full Text)
|
|
test_endpoint("POST", "/account/search", "Search Accounts (POST - All)", query={"q": "%"})
|
|
|
|
# 3. Search Accounts (Specific Name)
|
|
test_endpoint("POST", "/account/search", "Search Accounts (POST - Specific)", query={"and": [{"field": "name", "op": "icontains", "value": "Sky"}]})
|
|
|
|
print("Tests Complete.")
|