Repository navigation
Feat: add new tests and tescases for restful api suite - #15230
Conversation
📝 WalkthroughWalkthroughThis PR extends the dataset REST API test suite with comprehensive contract tests covering update, delete, list, get, and metadata operations. The additions include authorization validation, HTTP payload validation, field-specific validation matrices, concurrent operation coverage, and edge-case handling across 20 new test functions. ChangesDataset 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 inconclusive)
✅ 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.
🧹 Nitpick comments (2)
test/testcases/restful_api/test_datasets.py (2)
1874-1913: 💤 Low valueConsider making bulk test sizes configurable.
The test creates 1,000 datasets for bulk delete and 100 for concurrent delete (1,100 total). While this provides good stress coverage, it may slow down CI/CD pipelines. Consider parameterizing these counts via environment variables or pytest configuration to allow faster runs in development environments while maintaining full coverage in nightly/release testing.
🤖 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 1874 - 1913, The hardcoded loop sizes in test_dataset_delete_bulk_and_concurrent_contract (range(1000) and range(100)) should be made configurable; replace the literal counts by reading values from environment or pytest config (e.g., os.getenv("DATASET_BULK_COUNT") / os.getenv("DATASET_CONCURRENT_COUNT") or pytest config/getoption) and fall back to the current defaults (1000 and 100) if not set so bulk_ids and concurrent_ids generation uses these variables; update any test parametrization or fixture as needed so CI/nightly can set larger values while local/dev runs use smaller defaults.
602-646: 💤 Low valueContract tests rely on exact error message strings.
The validation contract tests assert specific error message substrings (e.g., "String should have at most 65535 characters", "Invalid UUID1 format"). While this provides precise validation, it couples tests tightly to error message format. If the API changes error text, many tests will fail even though the contract (error code + general meaning) may still be correct.
This is an acceptable trade-off for contract testing, but be aware that error message refactoring will require coordinated test updates.
Also applies to: 671-716, 916-993, 1927-2146
🤖 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 602 - 646, The test test_dataset_update_content_type_and_payload_contract (and other contract blocks at the noted ranges) is brittle because it asserts exact error message substrings; change these assertions to rely primarily on the numeric error codes (e.g., code == 101/102) and, if needed, assert only a stable, small substring or use regex matching for the high-level meaning (e.g., "Unsupported content type", "Malformed JSON", "Invalid request payload") instead of full exact phrases like "String should have at most 65535 characters" or "Invalid UUID1 format"; update the specific assertions in this test (and the similar checks at 671-716, 916-993, 1927-2146) to assert error code equality and replace exact message equality checks with contains/regex checks for the minimal stable text.
🤖 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.
Nitpick comments:
In `@test/testcases/restful_api/test_datasets.py`:
- Around line 1874-1913: The hardcoded loop sizes in
test_dataset_delete_bulk_and_concurrent_contract (range(1000) and range(100))
should be made configurable; replace the literal counts by reading values from
environment or pytest config (e.g., os.getenv("DATASET_BULK_COUNT") /
os.getenv("DATASET_CONCURRENT_COUNT") or pytest config/getoption) and fall back
to the current defaults (1000 and 100) if not set so bulk_ids and concurrent_ids
generation uses these variables; update any test parametrization or fixture as
needed so CI/nightly can set larger values while local/dev runs use smaller
defaults.
- Around line 602-646: The test
test_dataset_update_content_type_and_payload_contract (and other contract blocks
at the noted ranges) is brittle because it asserts exact error message
substrings; change these assertions to rely primarily on the numeric error codes
(e.g., code == 101/102) and, if needed, assert only a stable, small substring or
use regex matching for the high-level meaning (e.g., "Unsupported content type",
"Malformed JSON", "Invalid request payload") instead of full exact phrases like
"String should have at most 65535 characters" or "Invalid UUID1 format"; update
the specific assertions in this test (and the similar checks at 671-716,
916-993, 1927-2146) to assert error code equality and replace exact message
equality checks with contains/regex checks for the minimal stable text.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b1e9adb7-83c5-4599-b891-86a9fc256884
📒 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 #15230 +/- ##
=======================================
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