Repository navigation
tests: add missing HTTP API tests for dataset management endpoints removed in #14222 - #14390
Conversation
Signed-off-by: noob <[email protected]>
Signed-off-by: noob <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds 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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
test/testcases/test_http_api/test_dataset_management/test_ingestion_logs.py (1)
59-62: Emptydataset_idexercises Flask routing, not the endpoint.Passing
""builds a URL like/datasets//ingestions, which Flask typically rejects at the routing layer (404) before reachinglist_ingestion_logs. The assertioncode != 0will 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 bytest_list_ingestion_logs_invalid_idabove. 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
📒 Files selected for processing (2)
test/testcases/test_http_api/test_dataset_management/test_ingestion_logs.pytest/testcases/test_http_api/test_file_management_within_dataset/test_metadata_config.py
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
|
LGTM |
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/andtest_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
POST /v1/kb/update_metadata_settingPUT /api/v1/datasets/<id>/metadata/configGET /api/v1/datasets/<id>/auto_metadataGET /api/v1/datasets/<id>/metadata/configPUT /api/v1/datasets/<id>/auto_metadataPUT /api/v1/datasets/<id>/metadata/configGET /v1/kb/<kb_id>/basic_infoGET /api/v1/datasets/<id>/ingestions/summaryPOST /v1/kb/list_pipeline_logsGET /api/v1/datasets/<id>/ingestionsChanges
test_file_management_within_dataset/test_metadata_config.py(new, 10 tests)Covers
GET/PUT /datasets/<id>/metadata/config(migrated fromtest_kb_tags_meta.py'stest_update_metadata_settingandtest_document_metadata.py's negative tests):test_dataset_management/test_ingestion_logs.py(extended, +2 tests)Covers
GET /datasets/<id>/ingestionsedge cases (migrated fromtest_kb_pipeline_tasks.py):Type of change