fix: unify completed item visibility
This commit is contained in:
@@ -1,7 +1,14 @@
|
||||
from datetime import UTC, datetime, timedelta
|
||||
from datetime import datetime, timedelta
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
from sqlalchemy import event
|
||||
|
||||
BUSINESS_TIME_ZONE = ZoneInfo("Asia/Shanghai")
|
||||
|
||||
|
||||
def local_today():
|
||||
return datetime.now(BUSINESS_TIME_ZONE).date()
|
||||
|
||||
|
||||
def boot(client):
|
||||
response = client.post(
|
||||
@@ -299,12 +306,12 @@ def test_habits_numeric_accumulation_pause_archive_grid_and_stats(client):
|
||||
)
|
||||
assert habit.status_code == 201
|
||||
habit_id = habit.json()["id"]
|
||||
today = datetime.now(UTC).date().isoformat()
|
||||
today = local_today().isoformat()
|
||||
for value in (6, 7):
|
||||
assert client.post(f"/api/v1/habits/{habit_id}/logs", json={"day": today, "value": value}).status_code == 200
|
||||
assert client.get(f"/api/v1/habits/{habit_id}/logs").json()[0]["value"] == 10
|
||||
assert client.put(f"/api/v1/habits/{habit_id}/logs/{today}", json={"value": 8}).json()["value"] == 8
|
||||
yesterday = (datetime.now(UTC).date() - timedelta(days=1)).isoformat()
|
||||
yesterday = (local_today() - timedelta(days=1)).isoformat()
|
||||
assert client.post(f"/api/v1/habits/{habit_id}/pauses", json={"start_date": yesterday, "end_date": today}).status_code == 201
|
||||
grid = client.get("/api/v1/habits/grid", params={"week": yesterday}).json()
|
||||
assert len(grid["days"]) == 7 and grid["habits"][0]["cells"]
|
||||
@@ -328,7 +335,7 @@ def test_habit_permanent_delete_removes_habit_and_history(client):
|
||||
json={"name": "待删除习惯", "kind": "numeric", "target": 3, "schedule_type": "daily"},
|
||||
)
|
||||
habit_id = created.json()["id"]
|
||||
today = datetime.now(UTC).date().isoformat()
|
||||
today = local_today().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
|
||||
@@ -346,7 +353,7 @@ def test_boolean_interval_habit_schedule(client):
|
||||
)
|
||||
assert habit.status_code == 201
|
||||
assert client.post(
|
||||
f"/api/v1/habits/{habit.json()['id']}/logs", json={"day": datetime.now(UTC).date().isoformat(), "value": 1}
|
||||
f"/api/v1/habits/{habit.json()['id']}/logs", json={"day": local_today().isoformat(), "value": 1}
|
||||
).json()["value"] == 1
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user