Initial commit: clean project structure
- Backend: FastAPI + SQLAlchemy + Celery (Python 3.11+) - Frontend: Vue 3 + TypeScript + Pinia + Tailwind - Admin Frontend: separate Vue 3 app for management - Docker Compose: 9 services orchestration - Specs: design prototypes, memory system PRD, product roadmap Cleanup performed: - Removed temporary debug scripts from backend root - Removed deprecated admin_app.py (embedded UI) - Removed duplicate docs from admin-frontend - Updated .gitignore for Vite cache and egg-info
This commit is contained in:
68
backend/tests/test_universes.py
Normal file
68
backend/tests/test_universes.py
Normal file
@@ -0,0 +1,68 @@
|
||||
"""Story universe API tests."""
|
||||
|
||||
|
||||
def _create_profile(auth_client):
|
||||
response = auth_client.post(
|
||||
"/api/profiles",
|
||||
json={
|
||||
"name": "小明",
|
||||
"gender": "male",
|
||||
"interests": ["太空"],
|
||||
"growth_themes": ["勇气"],
|
||||
},
|
||||
)
|
||||
assert response.status_code == 201
|
||||
return response.json()["id"]
|
||||
|
||||
|
||||
def test_create_list_update_universe(auth_client):
|
||||
profile_id = _create_profile(auth_client)
|
||||
|
||||
payload = {
|
||||
"name": "星际冒险",
|
||||
"protagonist": {"name": "小明", "role": "船长"},
|
||||
"recurring_characters": [{"name": "小七", "role": "机器人"}],
|
||||
"world_settings": {"world_name": "星际学院"},
|
||||
}
|
||||
|
||||
response = auth_client.post(f"/api/profiles/{profile_id}/universes", json=payload)
|
||||
assert response.status_code == 201
|
||||
data = response.json()
|
||||
assert data["name"] == payload["name"]
|
||||
|
||||
universe_id = data["id"]
|
||||
|
||||
response = auth_client.get(f"/api/profiles/{profile_id}/universes")
|
||||
assert response.status_code == 200
|
||||
list_data = response.json()
|
||||
assert list_data["total"] == 1
|
||||
|
||||
response = auth_client.put(
|
||||
f"/api/universes/{universe_id}",
|
||||
json={"name": "星际冒险·第二季"},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["name"] == "星际冒险·第二季"
|
||||
|
||||
|
||||
def test_add_achievement(auth_client):
|
||||
profile_id = _create_profile(auth_client)
|
||||
|
||||
response = auth_client.post(
|
||||
f"/api/profiles/{profile_id}/universes",
|
||||
json={
|
||||
"name": "梦幻森林",
|
||||
"protagonist": {"name": "小红"},
|
||||
},
|
||||
)
|
||||
assert response.status_code == 201
|
||||
universe_id = response.json()["id"]
|
||||
|
||||
response = auth_client.post(
|
||||
f"/api/universes/{universe_id}/achievements",
|
||||
json={"type": "勇气", "description": "克服黑暗"},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert {"type": "勇气", "description": "克服黑暗"} in data["achievements"]
|
||||
Reference in New Issue
Block a user