ComfyUI/tests-unit
Matt Miller 33109e0a04
Some checks failed
Python Linting / Run Ruff (push) Has been cancelled
Python Linting / Run Pylint (push) Has been cancelled
feat(jobs): cursor-based pagination on GET /api/jobs (BE-943) (#14363)
* refactor(pagination): hoist cursor codec to utils/ for cross-domain reuse

The keyset cursor codec was asset-namespaced (app/assets/services/cursor.py)
but the wire format and encode/decode logic are domain-agnostic. Move it to
utils/cursor.py so the jobs endpoint can share one codec instead of importing
across domains or duplicating it.

* feat(jobs): cursor-based pagination on GET /api/jobs (BE-943)

Mirror the cloud jobs cursor (BE-885) on the OSS Python server so the
frontend sees one contract across runtimes.

- apply_sorting now appends the job id as a tiebreaker, making (create_time,
  id) a stable keyset; without it, ties could reorder between pages.
- get_all_jobs accepts an opaque 'after' cursor (honored only for created_at
  sort, like cloud), keyset-filters the sorted in-memory list, and returns
  has_more + a next_cursor. Minted in offset mode too so a client can bootstrap
  into keyset pagination.
- server.py /api/jobs parses 'after', returns next_cursor in the pagination
  object, and maps a malformed cursor to 400 INVALID_CURSOR.
- Reuses the shared utils.cursor codec (base64url JSON {s,v,id,o}) so the wire
  format matches cloud and assets exactly.

Tests: asc/desc multi-page round-trip, same-create_time tiebreaker, last-page
no-cursor, offset-mode bootstrap, execution_duration ignores cursor, malformed
cursor raises.

* refactor(jobs): return NamedTuple page, early-out on empty job set

Review feedback on the jobs cursor pagination:
- get_all_jobs now returns JobsPage, a NamedTuple, instead of a bare
  4-tuple (callers unpack positionally either way).
- Early-out when the filtered job set is empty so paging code never has
  to reason about indexing into an empty list. A malformed 'after'
  cursor is still decoded first and rejected with INVALID_CURSOR.
- Document that job ids are server-assigned UUIDs, always present and
  unique — the empty-string fallback in _job_id_key only shields
  sorted() from a malformed dict, it is not part of the keyset
  contract.
2026-06-09 21:28:25 -07:00
..
app_test Generalize frontend version warning to all comfy* requirements.txt entries (#13875) 2026-05-14 16:13:30 -07:00
assets_test feat(jobs): cursor-based pagination on GET /api/jobs (BE-943) (#14363) 2026-06-09 21:28:25 -07:00
comfy_api_test fix(api-io): serialize MultiCombo multi_select as object config (#13484) 2026-05-05 13:58:32 -07:00
comfy_extras_test Revert "Add SeedVR2 support (CORE-6) (#14110)" (#14359) 2026-06-08 18:00:20 -04:00
comfy_quant Properly save mixed ops. (#11772) 2026-01-10 02:03:57 -05:00
comfy_test Revert "Add SeedVR2 support (CORE-6) (#14110)" (#14359) 2026-06-08 18:00:20 -04:00
execution_test Revert "Include workflow_id in all execution WebSocket messages (CORE-198) (#…" (#13901) 2026-05-14 15:35:42 -07:00
folder_paths_test feat(security): add System User protection with __ prefix (#10966) 2025-11-28 21:28:42 -05:00
prompt_server_test fix: return millisecond timestamps from get_file_info() (#12996) 2026-05-06 10:56:09 +08:00
seeder_test feat(assets): register output files as assets after prompt execution (#12812) 2026-03-24 20:48:55 -07:00
server/utils Remove unused GET /files API endpoint (#6714) 2025-02-05 18:48:36 -05:00
server_test fix: use no-store cache headers to prevent stale frontend chunks (#12911) 2026-03-14 18:25:09 -04:00
utils Normalize extra_model_config.yaml paths to prevent duplicates. (#6885) 2025-02-20 07:09:45 -05:00
deploy_environment_test.py Add deploy environment header (Comfy-Env) to partner node API calls (#13425) 2026-05-04 20:17:56 -07:00
feature_flags_test.py feat: add generic --feature-flag CLI arg and --list-feature-flags registry (#13685) 2026-05-04 19:50:26 -07:00
README.md Minor: update tests-unit README.md (#4896) 2024-09-12 04:53:08 -04:00
requirements.txt refactor(assets): modular architecture + async two-phase scanner & background seeder (#12621) 2026-03-07 20:37:25 -05:00
websocket_feature_flags_test.py Support for async node functions (#8830) 2025-07-10 14:46:19 -04:00

Pytest Unit Tests

Install test dependencies

pip install -r tests-unit/requirements.txt

Run tests

pytest tests-unit/