Skip to content

tests: add missing HTTP API tests for dataset management endpoints removed in #14222 - #14390

Merged
wangq8 merged 6 commits into
infiniflow:mainfrom
euvre:add-missing-test
Apr 27, 2026
Merged

wangq8 merged 6 commits into
infiniflow:mainfrom
euvre:add-missing-test

Conversation

@euvre

@euvre euvre commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Summary

PR #14222 consolidated KB (web) API endpoints into RESTful Dataset (HTTP) API endpoints and deleted the web API test suite under test_web_api/test_kb_app/ and test_web_api/test_document_app/. While most test coverage was migrated to the HTTP API test suite, some tests were not ported over. This PR adds back the missing coverage.

Route migration reference

Old Web API New HTTP API Missing tests
POST /v1/kb/update_metadata_setting PUT /api/v1/datasets/<id>/metadata/config auth & error paths
GET /api/v1/datasets/<id>/auto_metadata GET /api/v1/datasets/<id>/metadata/config auth & CRUD
PUT /api/v1/datasets/<id>/auto_metadata PUT /api/v1/datasets/<id>/metadata/config auth & CRUD
GET /v1/kb/<kb_id>/basic_info GET /api/v1/datasets/<id>/ingestions/summary covered
POST /v1/kb/list_pipeline_logs GET /api/v1/datasets/<id>/ingestions edge cases missing

Changes

test_file_management_within_dataset/test_metadata_config.py (new, 10 tests)

Covers GET/PUT /datasets/<id>/metadata/config (migrated from test_kb_tags_meta.py's test_update_metadata_setting and test_document_metadata.py's negative tests):

  • Authorization for dataset metadata config GET/PUT
  • Authorization for document metadata config PUT
  • Success, invalid dataset, missing payload, not found scenarios

test_dataset_management/test_ingestion_logs.py (extended, +2 tests)

Covers GET /datasets/<id>/ingestions edge cases (migrated from test_kb_pipeline_tasks.py):

  • Missing dataset ID
  • Abnormal date filter

Type of change

  • Other: Test coverage improvement

euvre added 2 commits April 27, 2026 11:46
Signed-off-by: noob <[email protected]>
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. 🧪 test Pull requests that update test cases. labels Apr 27, 2026
@coderabbitai

coderabbitai Bot commented Apr 27, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 06dd8465-354b-41bd-87d7-f550b72cf916

📥 Commits

Reviewing files that changed from the base of the PR and between 4c5c66a and 901e858.

📒 Files selected for processing (2)
  • test/testcases/test_http_api/test_dataset_management/test_ingestion_logs.py
  • test/testcases/test_http_api/test_file_management_within_dataset/test_metadata_config.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • test/testcases/test_http_api/test_dataset_management/test_ingestion_logs.py
  • test/testcases/test_http_api/test_file_management_within_dataset/test_metadata_config.py

📝 Walkthrough

Walkthrough

Adds pytest suites: an edge-case test for the ingestion-log listing endpoint (date-range inversion) and a new test module exercising dataset/document metadata config endpoints, covering authorization failures, invalid IDs, and payload scenarios.

Changes

Cohort / File(s) Summary
Ingestion Log API Tests
test/testcases/test_http_api/test_dataset_management/test_ingestion_logs.py
Adds an edge-case test class using clear_datasets and a test that calls list_ingestion_logs with create_date_from > create_date_to, asserting a non-zero code response.
Metadata Configuration API Tests
test/testcases/test_http_api/test_file_management_within_dataset/test_metadata_config.py
New test module that adds request helpers and tests for dataset/document metadata config endpoints: authorization checks (401), successful GET when dataset exists, and various invalid-id and payload update assertions (non-zero code).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

python

Suggested reviewers

  • yuzhichang
  • JinHai-CN
  • yingfeng

Poem

🐰 I hopped through tests with a twitching nose,
Chasing logs where the odd date flows,
I checked configs for datasets and docs,
Sniffed out auth holes and missing mocks,
A tiny hop — the test garden grows!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 6.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the PR as adding missing HTTP API tests for dataset management endpoints that were removed in a previous PR.
Description check ✅ Passed The description includes the required 'What problem does this PR solve?' section with detailed context and a 'Type of change' selection, addressing the missing test coverage systematically.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@euvre euvre added the ci Continue Integration label Apr 27, 2026
@euvre
euvre marked this pull request as draft April 27, 2026 06:18
@euvre
euvre marked this pull request as ready for review April 27, 2026 06:18

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
test/testcases/test_http_api/test_dataset_management/test_ingestion_logs.py (1)

59-62: Empty dataset_id exercises Flask routing, not the endpoint.

Passing "" builds a URL like /datasets//ingestions, which Flask typically rejects at the routing layer (404) before reaching list_ingestion_logs. The assertion code != 0 will pass, but the test doesn't actually validate the endpoint's missing-id handling. If the intent is to cover the API's behavior for an unknown dataset, a synthetic value (e.g. "nonexistent_id") would be more meaningful — though that's already covered by test_list_ingestion_logs_invalid_id above. Consider removing this test as it duplicates the invalid-id case at the routing level.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/testcases/test_http_api/test_dataset_management/test_ingestion_logs.py`
around lines 59 - 62, The test function
test_list_ingestion_logs_missing_dataset_id exercises Flask routing (URL
`/datasets//ingestions`) rather than the endpoint logic and duplicates
test_list_ingestion_logs_invalid_id; remove
test_list_ingestion_logs_missing_dataset_id from test_ingestion_logs.py (or, if
you intended to exercise the endpoint rather than routing, replace the empty
string argument to list_ingestion_logs(HttpApiAuth, "") with a synthetic
non-existent id like "nonexistent_id" so the request reaches list_ingestion_logs
and validates endpoint behavior).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@test/testcases/test_http_api/test_dataset_management/test_ingestion_logs.py`:
- Around line 64-81: The test test_list_ingestion_logs_abnormal_date_filter
currently sends a normal date range but claims to test an abnormal range and
permissively accepts code 102; update the test to assert the correct contract
for a newly-created dataset: call list_ingestion_logs(HttpApiAuth, dataset_id,
params={... "create_date_from":"2025-01-01","create_date_to":"2025-02-01"}) and
change the assertions to expect success (res["code"] == 0) and an empty logs
list (e.g., res["data"]["logs"] == []), and update the test docstring to
describe that it verifies a valid date range returns an empty result for a
dataset with no ingestions; reference the test function name
test_list_ingestion_logs_abnormal_date_filter and the helper list_ingestion_logs
when making these edits.

In
`@test/testcases/test_http_api/test_file_management_within_dataset/test_metadata_config.py`:
- Around line 125-128: The test name and assertions are inconsistent:
test_update_document_metadata_config_not_found currently uses add_document_func
(so dataset/doc exist) and sends an empty payload to
update_document_metadata_config; pick one behavior and make the test explicit —
either (A) rename to test_update_document_metadata_config_missing_payload, keep
the existing setup (use add_document_func to get dataset_id/doc_id), call
update_document_metadata_config(HttpApiAuth, dataset_id, doc_id, {}) and assert
the specific non-zero error code expected for a missing payload (not a
permissive in [0,102]); or (B) keep the not-found name, generate a synthetic
non-existent doc_id (rather than add_document_func), call
update_document_metadata_config with that id and assert code != 0 (or the exact
non-zero code used by sibling tests). Update the test function name and
assertion accordingly and reference
test_update_document_metadata_config_not_found, add_document_func, and
update_document_metadata_config when making the change.

---

Nitpick comments:
In `@test/testcases/test_http_api/test_dataset_management/test_ingestion_logs.py`:
- Around line 59-62: The test function
test_list_ingestion_logs_missing_dataset_id exercises Flask routing (URL
`/datasets//ingestions`) rather than the endpoint logic and duplicates
test_list_ingestion_logs_invalid_id; remove
test_list_ingestion_logs_missing_dataset_id from test_ingestion_logs.py (or, if
you intended to exercise the endpoint rather than routing, replace the empty
string argument to list_ingestion_logs(HttpApiAuth, "") with a synthetic
non-existent id like "nonexistent_id" so the request reaches list_ingestion_logs
and validates endpoint behavior).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0d8b8b4c-ff83-456a-a438-e1cb66e56ff1

📥 Commits

Reviewing files that changed from the base of the PR and between 0b46ab0 and 4c5c66a.

📒 Files selected for processing (2)
  • test/testcases/test_http_api/test_dataset_management/test_ingestion_logs.py
  • test/testcases/test_http_api/test_file_management_within_dataset/test_metadata_config.py

@codecov

codecov Bot commented Apr 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.30%. Comparing base (6a23dfe) to head (901e858).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #14390   +/-   ##
=======================================
  Coverage   95.30%   95.30%           
=======================================
  Files          10       10           
  Lines         703      703           
  Branches      112      112           
=======================================
  Hits          670      670           
  Misses         16       16           
  Partials       17       17           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@xugangqiang

Copy link
Copy Markdown
Contributor

LGTM

@wangq8
wangq8 merged commit d780139 into infiniflow:main Apr 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:XS This PR changes 0-9 lines, ignoring generated files. 🧪 test Pull requests that update test cases.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants