Repository navigation
Feat: add new tests and tescases for restful api suite - #15223
Conversation
📝 WalkthroughWalkthroughAdds comprehensive REST API contract test coverage for dataset update operations, including tests for name deduplication (case-insensitive), metadata field persistence, chunk method and parser configuration updates with default fallback behavior, embedding model authorization-conditional outcomes, permission normalization, and concurrent update stress testing. ChangesDataset Update REST API Contract Tests
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
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: 1
🧹 Nitpick comments (2)
test/testcases/restful_api/test_datasets.py (2)
375-392: ⚡ Quick winAdd lightweight logging in new environment-dependent and concurrent update flows.
The new update suite introduces
xfail,skipif(DOC_ENGINE), and concurrent request paths; adding debug logs for payload/code outcomes will make flaky triage much faster without changing assertions.As per coding guidelines, "
**/*.py: Add logging for new flows".Also applies to: 487-560, 564-581
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/testcases/restful_api/test_datasets.py` around lines 375 - 392, In test_dataset_update_embedding_model_contract add lightweight debug logging using the module logger (e.g., logger = logging.getLogger(__name__)) to record create_res.status_code, create_payload (create_res.json()), update_res.status_code and update_payload (update_res.json()), and log the xfail/skip branch details before calling pytest.xfail so you can see the payload/code outcomes; apply the same pattern to the other update tests referenced (the functions covering lines ~487-560 and ~564-581) so every environment-dependent or concurrent update path logs response status and JSON payloads for faster triage while keeping existing assertions unchanged.
157-174: ⚡ Quick winRemove duplicated
idsmaintenance in parametrized matrices.The explicit
ids=[...]duplicates the case-name data and is easy to desync when editing. Generate IDs from the case tuples to keep one source of truth.Suggested pattern
`@pytest.mark.parametrize`( "name, parser_config", [ ("auto_keywords_min", {"auto_keywords": 0}), ... ], - ids=[ - "auto_keywords_min", - ... - ], + ids=lambda c: c[0], )Also applies to: 193-303
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/testcases/restful_api/test_datasets.py` around lines 157 - 174, The pytest.mark.parametrize call that passes "chunk_method" currently repeats the same list in both the values and the ids which risks desync; update the decorator (the parametrize for "chunk_method") to remove the explicit ids argument and instead let pytest auto-generate IDs or generate them programmatically from the values list (e.g., map str over the chunk_method list) so there's a single source of truth; apply the same change to the other parametrized matrices in this file that duplicate ids (the other parametrize blocks around lines 193–303).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@test/testcases/restful_api/test_datasets.py`:
- Around line 403-405: The two parametrized test cases
("whitespace_only_model_name" and "whitespace_only_provider") currently expect
the generic error "Both model_name and provider must be non-empty strings";
update their expected error fragment (the third element of each tuple) to the
validator's whitespace-specific message emitted for whitespace-only inputs
(replace the third field in the tuples for "whitespace_only_model_name" and
"whitespace_only_provider" with the exact whitespace-specific error string from
the validator so the test matches upstream behavior).
---
Nitpick comments:
In `@test/testcases/restful_api/test_datasets.py`:
- Around line 375-392: In test_dataset_update_embedding_model_contract add
lightweight debug logging using the module logger (e.g., logger =
logging.getLogger(__name__)) to record create_res.status_code, create_payload
(create_res.json()), update_res.status_code and update_payload
(update_res.json()), and log the xfail/skip branch details before calling
pytest.xfail so you can see the payload/code outcomes; apply the same pattern to
the other update tests referenced (the functions covering lines ~487-560 and
~564-581) so every environment-dependent or concurrent update path logs response
status and JSON payloads for faster triage while keeping existing assertions
unchanged.
- Around line 157-174: The pytest.mark.parametrize call that passes
"chunk_method" currently repeats the same list in both the values and the ids
which risks desync; update the decorator (the parametrize for "chunk_method") to
remove the explicit ids argument and instead let pytest auto-generate IDs or
generate them programmatically from the values list (e.g., map str over the
chunk_method list) so there's a single source of truth; apply the same change to
the other parametrized matrices in this file that duplicate ids (the other
parametrize blocks around lines 193–303).
🪄 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: 34ed86fd-82e7-4d33-a951-15fb8ea88b74
📒 Files selected for processing (1)
test/testcases/restful_api/test_datasets.py
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #15223 +/- ##
=======================================
Coverage 93.12% 93.12%
=======================================
Files 10 10
Lines 713 713
Branches 116 116
=======================================
Hits 664 664
Misses 29 29
Partials 20 20 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
What problem does this PR solve?
extend restful api suite
Type of change