feat: delete habits from detail sheet
This commit is contained in:
@@ -272,6 +272,22 @@ def test_habits_numeric_accumulation_pause_archive_grid_and_stats(client):
|
||||
assert client.get(f"/api/v1/habits/{habit_id}/stats").json()["total"] == 8
|
||||
|
||||
|
||||
def test_habit_permanent_delete_removes_habit_and_history(client):
|
||||
boot(client)
|
||||
created = client.post(
|
||||
"/api/v1/habits",
|
||||
json={"name": "待删除习惯", "kind": "numeric", "target": 3, "schedule_type": "daily"},
|
||||
)
|
||||
habit_id = created.json()["id"]
|
||||
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}/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())
|
||||
assert client.get(f"/api/v1/habits/{habit_id}/stats").status_code == 404
|
||||
|
||||
|
||||
def test_boolean_interval_habit_schedule(client):
|
||||
boot(client)
|
||||
habit = client.post(
|
||||
|
||||
Reference in New Issue
Block a user