48 lines
1.4 KiB
Python
48 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Test script to verify extra_data in API response"""
|
|
import asyncio
|
|
import sys
|
|
import os
|
|
import json
|
|
|
|
# Add backend to path
|
|
sys.path.append(os.path.join(os.getcwd(), "backend"))
|
|
|
|
from app.database import AsyncSessionLocal
|
|
from app.services.db_service import celestial_body_service
|
|
|
|
async def test_api_data():
|
|
"""Simulate API response building"""
|
|
async with AsyncSessionLocal() as session:
|
|
# Get Earth
|
|
body = await celestial_body_service.get_body_by_id("399", session)
|
|
|
|
if not body:
|
|
print("Earth not found in database")
|
|
return
|
|
|
|
# Build response dict like API does
|
|
body_dict = {
|
|
"id": body.id,
|
|
"name": body.name,
|
|
"name_zh": body.name_zh,
|
|
"type": body.type,
|
|
"description": body.description,
|
|
"is_active": body.is_active,
|
|
"extra_data": body.extra_data,
|
|
"positions": []
|
|
}
|
|
|
|
print("=== Database Body Object ===")
|
|
print(f"Body ID: {body.id}")
|
|
print(f"Body Name: {body.name}")
|
|
print(f"Body Type: {body.type}")
|
|
print(f"Extra Data Type: {type(body.extra_data)}")
|
|
print(f"Extra Data: {body.extra_data}")
|
|
|
|
print("\n=== API Response Dict ===")
|
|
print(json.dumps(body_dict, indent=2, default=str))
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(test_api_data())
|