Add validate tests#639
Conversation
|
🤖 Auto-triaged by documentdb-triage-tool. Applied: Reasoningcomponent from path globs (test-coverage, test-framework); effort from diff stats (2087+1 LOC, 12 files); LLM: Adds new validate command tests and extends DiagnosticTestCase with a setup field, expanding test coverage for a specific MongoDB command. If a label is wrong, remove it manually and ping |
| from documentdb_tests.framework.property_checks import Eq | ||
|
|
||
| # Property [Type Coercion]: validate accepts all BSON types for the full parameter via coercion. | ||
| ACCEPTED_TYPE_TESTS: list[DiagnosticTestCase] = [ |
There was a problem hiding this comment.
🟠 [Major] The per-parameter coercion files are enormous and partly redundant against §20's canonical matrix. Five files (full, metadata, checkBSONConformance, repair, fixMultikey) each test the same ~21-type coercion matrix (~105 near-identical cases). Per TEST_COVERAGE.md §20, boolean-param coercion should mirror the canonical matrix (bypassDocumentValidation), but it
doesn't require re-testing all 21 BSON types five times for one command — the coercion logic is shared across these boolean params. Consider collapsing to one representative coercion matrix plus per-param confirmation that each is wired to it (a few cases each). As written this is a lot of duplicated surface for one behavior; TEST_FORMAT.md "don't ask for exhaustive
BSON matrix on simple shared params" cuts toward trimming.
There was a problem hiding this comment.
removed the exhaustive tests
| def test_validate_response_details(collection, test): | ||
| """Test validate response values, sub-structure, and option-specific shapes.""" | ||
| for cmd in test.setup: | ||
| execute_command(collection, {**cmd, next(iter(cmd)): collection.name}) |
There was a problem hiding this comment.
[Question] setup runner uses next(iter(cmd)) to rewrite the collection name. The pattern {**cmd, next(iter(cmd)): collection.name} assumes the command name is the first key in each setup dict. That holds for the literal dicts here ({"insert": "", ...}), but it's a slightly fragile idiom — if a dict were ever written with another key first, it'd rewrite the wrong
field silently. A small explicit helper or a command_name field would be more robust. Minor.
There was a problem hiding this comment.
Switched to use helper bind_collection
Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
alinaliBQ
left a comment
There was a problem hiding this comment.
Addressed comments. also added validate_repair capability to skip on validate tests that only work on standalone instances
| from documentdb_tests.framework.property_checks import Eq | ||
|
|
||
| # Property [Type Coercion]: validate accepts all BSON types for the full parameter via coercion. | ||
| ACCEPTED_TYPE_TESTS: list[DiagnosticTestCase] = [ |
There was a problem hiding this comment.
removed the exhaustive tests
| def test_validate_response_details(collection, test): | ||
| """Test validate response values, sub-structure, and option-specific shapes.""" | ||
| for cmd in test.setup: | ||
| execute_command(collection, {**cmd, next(iter(cmd)): collection.name}) |
There was a problem hiding this comment.
Switched to use helper bind_collection
Add command operator tests for validate. Tests database validate behavior, output collection, syntax, and errors.
Adds
setupfield inDiagnosticTestCase.