mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-06-01 11:57:24 +08:00
fix(assets): address bot review comments
- Soften offset param prose: it's not deprecated, just not preferred for sequential walks. Random-access UIs (jump-to-page, item count displays) legitimately still want offset, so dropping the 'deprecated' framing rather than promoting it to a machine-readable deprecated:true flag. - Add explicit HTTP status assertions before every json() / next_cursor read in test_list_cursor.py so a failing request surfaces as an HTTP error instead of a confusing KeyError on a 4xx/5xx body.
This commit is contained in:
parent
9b0042d78c
commit
33a57cc9e8
@ -1518,8 +1518,11 @@ paths:
|
|||||||
type: integer
|
type: integer
|
||||||
default: 0
|
default: 0
|
||||||
description: |
|
description: |
|
||||||
Deprecated in favor of `after` cursor pagination. When both are
|
Offset-based pagination. Cursor pagination via `after` is preferred
|
||||||
supplied, `after` wins and `offset` is ignored.
|
for sequential walks (stable across concurrent inserts/deletes) but
|
||||||
|
`offset` remains fully supported for random access (jump-to-page
|
||||||
|
UIs, "showing items X–Y of N" displays). When both are supplied,
|
||||||
|
`after` wins and `offset` is ignored.
|
||||||
- name: after
|
- name: after
|
||||||
in: query
|
in: query
|
||||||
schema:
|
schema:
|
||||||
|
|||||||
@ -109,6 +109,7 @@ def test_cursor_wins_over_offset(http: requests.Session, api_base: str, asset_fa
|
|||||||
},
|
},
|
||||||
timeout=120,
|
timeout=120,
|
||||||
)
|
)
|
||||||
|
assert r.status_code == 200, r.text
|
||||||
cursor = r.json()["next_cursor"]
|
cursor = r.json()["next_cursor"]
|
||||||
assert cursor is not None
|
assert cursor is not None
|
||||||
|
|
||||||
@ -144,6 +145,7 @@ def test_next_cursor_absent_when_no_more_results(http: requests.Session, api_bas
|
|||||||
},
|
},
|
||||||
timeout=120,
|
timeout=120,
|
||||||
)
|
)
|
||||||
|
assert r.status_code == 200, r.text
|
||||||
body = r.json()
|
body = r.json()
|
||||||
assert body["has_more"] is False
|
assert body["has_more"] is False
|
||||||
assert "next_cursor" not in body
|
assert "next_cursor" not in body
|
||||||
@ -159,6 +161,7 @@ def test_cursor_pagination_first_page_mints_cursor(http: requests.Session, api_b
|
|||||||
params={"include_tags": "unit-tests,cursor-first-page", "sort": "name", "order": "asc", "limit": "2"},
|
params={"include_tags": "unit-tests,cursor-first-page", "sort": "name", "order": "asc", "limit": "2"},
|
||||||
timeout=120,
|
timeout=120,
|
||||||
)
|
)
|
||||||
|
assert r.status_code == 200, r.text
|
||||||
body = r.json()
|
body = r.json()
|
||||||
assert body["has_more"] is True
|
assert body["has_more"] is True
|
||||||
assert body.get("next_cursor"), "first page must mint a cursor when more rows exist"
|
assert body.get("next_cursor"), "first page must mint a cursor when more rows exist"
|
||||||
@ -175,6 +178,7 @@ def test_cursor_no_spurious_cursor_when_page_size_equals_remainder(http: request
|
|||||||
params={"include_tags": "unit-tests,cursor-exact-multiple", "sort": "name", "order": "asc", "limit": "2"},
|
params={"include_tags": "unit-tests,cursor-exact-multiple", "sort": "name", "order": "asc", "limit": "2"},
|
||||||
timeout=120,
|
timeout=120,
|
||||||
)
|
)
|
||||||
|
assert r.status_code == 200, r.text
|
||||||
cursor = r.json()["next_cursor"]
|
cursor = r.json()["next_cursor"]
|
||||||
assert cursor is not None
|
assert cursor is not None
|
||||||
# Page 2 — should exhaust the set with no cursor for a phantom page 3
|
# Page 2 — should exhaust the set with no cursor for a phantom page 3
|
||||||
@ -183,6 +187,7 @@ def test_cursor_no_spurious_cursor_when_page_size_equals_remainder(http: request
|
|||||||
params={"include_tags": "unit-tests,cursor-exact-multiple", "sort": "name", "order": "asc", "limit": "2", "after": cursor},
|
params={"include_tags": "unit-tests,cursor-exact-multiple", "sort": "name", "order": "asc", "limit": "2", "after": cursor},
|
||||||
timeout=120,
|
timeout=120,
|
||||||
)
|
)
|
||||||
|
assert r2.status_code == 200, r2.text
|
||||||
body = r2.json()
|
body = r2.json()
|
||||||
assert len(body["assets"]) == 2
|
assert len(body["assets"]) == 2
|
||||||
assert body["has_more"] is False
|
assert body["has_more"] is False
|
||||||
@ -245,6 +250,7 @@ def test_cursor_order_mismatch_returns_400(http: requests.Session, api_base: str
|
|||||||
},
|
},
|
||||||
timeout=120,
|
timeout=120,
|
||||||
)
|
)
|
||||||
|
assert r.status_code == 200, r.text
|
||||||
cursor = r.json()["next_cursor"]
|
cursor = r.json()["next_cursor"]
|
||||||
assert cursor is not None
|
assert cursor is not None
|
||||||
|
|
||||||
@ -321,5 +327,6 @@ def test_cursor_pagination_stable_after_delete(http: requests.Session, api_base:
|
|||||||
},
|
},
|
||||||
timeout=120,
|
timeout=120,
|
||||||
)
|
)
|
||||||
|
assert r2.status_code == 200, r2.text
|
||||||
body2 = r2.json()
|
body2 = r2.json()
|
||||||
assert [a["name"] for a in body2["assets"]] == names[2:]
|
assert [a["name"] for a in body2["assets"]] == names[2:]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user