Merged
fix(registry): reject size=0 on the services list endpoint #348
fix(registry): reject size=0 on the services list endpoint #348
Merged
庄昭雄Add on Oct 18
Total: 2 files changed+32-0
MAgentRegistry/a2x_registry/backend/routers/dataset.py+5-0File content is under review, please try again later
@@ -0,0 +1,27 @@
1+# coding: utf-8
2+"""GET /api/datasets/{dataset}/services?size=0 must be a client error.
3+ 
4+``size`` is a page size; the handler divides by it when it computes page
5+counts, so ``size=0`` used to fail with a server error instead of a 4xx.
6+``size`` must be ``-1`` (all) or a positive page size, and these tests pin
7+that contract through the same ``lite_app`` client the other backend tests
8+use.
9+"""
10+ 
11+ 
12+def test_size_zero_is_rejected_as_a_request_error(lite_app):
13+ assert lite_app.post("/api/datasets", json={"name": "demo"}).status_code == 200
14+ 
15+ response = lite_app.get("/api/datasets/demo/services", params={"size": 0})
16+ 
17+ assert response.status_code == 400, response.text
18+ assert "size" in response.json()["detail"]
19+ 
20+ 
21+def test_size_minus_one_still_returns_every_service(lite_app):
22+ assert lite_app.post("/api/datasets", json={"name": "demo"}).status_code == 200
23+ 
24+ response = lite_app.get("/api/datasets/demo/services", params={"size": -1})
25+ 
26+ assert response.status_code == 200, response.text
27+ assert response.json() == []