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:
77
backend/tests/test_push_configs.py
Normal file
77
backend/tests/test_push_configs.py
Normal file
@@ -0,0 +1,77 @@
|
||||
"""Push config API tests."""
|
||||
|
||||
|
||||
def _create_profile(auth_client) -> str:
|
||||
response = auth_client.post(
|
||||
"/api/profiles",
|
||||
json={"name": "小明", "gender": "male"},
|
||||
)
|
||||
assert response.status_code == 201
|
||||
return response.json()["id"]
|
||||
|
||||
|
||||
def test_create_list_update_push_config(auth_client):
|
||||
profile_id = _create_profile(auth_client)
|
||||
|
||||
response = auth_client.put(
|
||||
"/api/push-configs",
|
||||
json={
|
||||
"child_profile_id": profile_id,
|
||||
"push_time": "20:30",
|
||||
"push_days": [1, 3, 5],
|
||||
"enabled": True,
|
||||
},
|
||||
)
|
||||
assert response.status_code == 201
|
||||
data = response.json()
|
||||
assert data["child_profile_id"] == profile_id
|
||||
assert data["push_time"].startswith("20:30")
|
||||
assert data["push_days"] == [1, 3, 5]
|
||||
assert data["enabled"] is True
|
||||
|
||||
response = auth_client.get("/api/push-configs")
|
||||
assert response.status_code == 200
|
||||
payload = response.json()
|
||||
assert payload["total"] == 1
|
||||
|
||||
response = auth_client.put(
|
||||
"/api/push-configs",
|
||||
json={
|
||||
"child_profile_id": profile_id,
|
||||
"enabled": False,
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["enabled"] is False
|
||||
assert data["push_time"].startswith("20:30")
|
||||
assert data["push_days"] == [1, 3, 5]
|
||||
|
||||
|
||||
def test_push_config_validation(auth_client):
|
||||
profile_id = _create_profile(auth_client)
|
||||
|
||||
response = auth_client.put(
|
||||
"/api/push-configs",
|
||||
json={"child_profile_id": profile_id},
|
||||
)
|
||||
assert response.status_code == 400
|
||||
|
||||
response = auth_client.put(
|
||||
"/api/push-configs",
|
||||
json={
|
||||
"child_profile_id": profile_id,
|
||||
"push_time": "19:00",
|
||||
"push_days": [7],
|
||||
},
|
||||
)
|
||||
assert response.status_code == 400
|
||||
|
||||
response = auth_client.put(
|
||||
"/api/push-configs",
|
||||
json={
|
||||
"child_profile_id": profile_id,
|
||||
"push_time": None,
|
||||
},
|
||||
)
|
||||
assert response.status_code == 400
|
||||
Reference in New Issue
Block a user