fix: harden habit input and lifecycle
This commit is contained in:
@@ -246,7 +246,15 @@ def test_habit_reorder_rejects_foreign_or_missing_ids(client):
|
||||
|
||||
def test_habit_logs_support_date_range_filter(client):
|
||||
boot(client)
|
||||
habit = client.post("/api/v1/habits", json={"name": "跑步", "kind": "boolean", "schedule_type": "daily"}).json()
|
||||
habit = client.post(
|
||||
"/api/v1/habits",
|
||||
json={
|
||||
"name": "跑步",
|
||||
"kind": "boolean",
|
||||
"schedule_type": "daily",
|
||||
"start_date": "2026-08-01",
|
||||
},
|
||||
).json()
|
||||
hid = habit["id"]
|
||||
for day in ("2026-08-01", "2026-08-15", "2026-09-01"):
|
||||
client.post(f"/api/v1/habits/{hid}/logs", json={"day": day, "value": 1})
|
||||
@@ -323,6 +331,7 @@ def test_habit_permanent_delete_removes_habit_and_history(client):
|
||||
today = datetime.now(UTC).date().isoformat()
|
||||
assert client.put(f"/api/v1/habits/{habit_id}/logs/{today}", json={"value": 2}).status_code == 200
|
||||
|
||||
assert client.delete(f"/api/v1/habits/{habit_id}").status_code == 204
|
||||
assert client.delete(f"/api/v1/habits/{habit_id}/permanent").status_code == 204
|
||||
assert all(row["id"] != habit_id for row in client.get("/api/v1/habits").json())
|
||||
assert all(row["id"] != habit_id for row in client.get("/api/v1/habits", params={"archived": True}).json())
|
||||
|
||||
Reference in New Issue
Block a user