@@ -121,6 +121,55 @@ def test_tasks_can_be_loaded_by_list_and_completion_filter(client):
|
||||
assert [item["title"] for item in response.json()["items"]] == ["收集箱未完成"]
|
||||
|
||||
|
||||
def test_tasks_support_numbered_pagination_with_total(client):
|
||||
inbox = boot(client)
|
||||
for index in range(5):
|
||||
client.post("/api/v1/tasks", json={"title": f"任务 {index}", "list_id": inbox["id"]})
|
||||
|
||||
first = client.get("/api/v1/tasks", params={"list_id": inbox["id"], "page": 1, "page_size": 2})
|
||||
second = client.get("/api/v1/tasks", params={"list_id": inbox["id"], "page": 2, "page_size": 2})
|
||||
|
||||
assert first.status_code == 200
|
||||
assert first.json()["total"] == 5
|
||||
assert first.json()["page"] == 1
|
||||
assert first.json()["page_size"] == 2
|
||||
assert len(first.json()["items"]) == 2
|
||||
assert len(second.json()["items"]) == 2
|
||||
assert {item["id"] for item in first.json()["items"]}.isdisjoint(
|
||||
{item["id"] for item in second.json()["items"]}
|
||||
)
|
||||
|
||||
|
||||
def test_tasks_support_due_range_pagination(client):
|
||||
inbox = boot(client)
|
||||
client.post("/api/v1/tasks", json={"title": "今天", "list_id": inbox["id"], "due_at": "2026-09-05T08:00:00Z"})
|
||||
client.post("/api/v1/tasks", json={"title": "以后", "list_id": inbox["id"], "due_at": "2026-09-08T08:00:00Z"})
|
||||
client.post("/api/v1/tasks", json={"title": "无日期", "list_id": inbox["id"]})
|
||||
|
||||
response = client.get(
|
||||
"/api/v1/tasks",
|
||||
params={"due_from": "2026-09-05T00:00:00Z", "due_to": "2026-09-06T00:00:00Z", "page": 1},
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
assert response.json()["total"] == 1
|
||||
assert [item["title"] for item in response.json()["items"]] == ["今天"]
|
||||
|
||||
|
||||
def test_trash_supports_numbered_pagination_with_total(client):
|
||||
inbox = boot(client)
|
||||
for index in range(3):
|
||||
task = client.post("/api/v1/tasks", json={"title": f"删除 {index}", "list_id": inbox["id"]}).json()
|
||||
client.delete(f"/api/v1/tasks/{task['id']}")
|
||||
|
||||
response = client.get("/api/v1/trash", params={"page": 2, "page_size": 2})
|
||||
|
||||
assert response.status_code == 200
|
||||
assert response.json()["total"] == 3
|
||||
assert response.json()["page"] == 2
|
||||
assert len(response.json()["items"]) == 1
|
||||
|
||||
|
||||
def test_ticktick_preview_import_dedupe_and_json_restore(client):
|
||||
boot(client)
|
||||
csv_data = "Title,List Name,Due Date,Status,ID\nImported,Inbox,2026-10-01,0,ext-1\n"
|
||||
|
||||
Reference in New Issue
Block a user