templates: support include_total for search and categories endpoints; update docs; add tests
This commit is contained in:
@@ -247,6 +247,16 @@ def test_templates_search_pagination_and_sorting(client: TestClient):
|
||||
# We can't assert exact order of timestamps easily; just ensure we got results
|
||||
assert isinstance(resp.json(), list) and len(resp.json()) >= 5
|
||||
|
||||
# include_total=true returns object with items and total
|
||||
resp = client.get(
|
||||
"/api/templates/search",
|
||||
params={"sort_by": "name", "sort_dir": "asc", "include_total": True},
|
||||
)
|
||||
assert resp.status_code == 200, resp.text
|
||||
data = resp.json()
|
||||
assert isinstance(data, dict) and "items" in data and "total" in data
|
||||
assert isinstance(data["items"], list) and isinstance(data["total"], int)
|
||||
|
||||
|
||||
def test_templates_search_active_filtering(client: TestClient):
|
||||
# Create two templates, mark one inactive directly
|
||||
@@ -373,6 +383,13 @@ def test_templates_categories_listing(client: TestClient):
|
||||
assert resp.status_code == 200
|
||||
rows_all = resp.json()
|
||||
by_cat_all = {r["category"]: r["count"] for r in rows_all}
|
||||
|
||||
# include_total=true shape
|
||||
resp = client.get("/api/templates/categories", params={"include_total": True, "active_only": False})
|
||||
assert resp.status_code == 200
|
||||
data = resp.json()
|
||||
assert isinstance(data, dict) and "items" in data and "total" in data
|
||||
assert isinstance(data["items"], list) and isinstance(data["total"], int)
|
||||
assert by_cat_all.get("K1", 0) >= 2
|
||||
assert by_cat_all.get("K2", 0) >= 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user