You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Testing: parametrize phantom-kwarg behavioral test across all Request models #219
test_request_bodies_use_extra_forbid is parametrized over every Request model and asserts model_config['extra'] == 'forbid' — but that's a config-level assertion, not behavioral. The actual behavioral assertion (constructing the model with a phantom kwarg raises ValidationError) is only spot-checked for CreateOrderRequest (test_forbid_extra_rejects_unknown_kwarg).
For all other request models (AmendOrderRequest, DecreaseOrderRequest, BatchCreate*, CreateOrderGroupRequest, UpdateOrderGroupLimitRequest, CreateRFQRequest, CreateQuoteRequest, AcceptQuoteRequest, ApplySubaccountTransferRequest, UpdateSubaccountNettingRequest, CreateApiKeyRequest, GenerateApiKeyRequest, all V2 order request models, etc.), there is no test that constructs the model with a phantom field and asserts ValidationError.
A model that accidentally sets extra='allow' AND has a typo in a field name would slip both gates: the config test catches the first miss, but if a contributor changes the config they may also re-add the field name with a typo elsewhere, and the per-model phantom test would catch only the second miss.
Location
tests/test_model_extra_policy.py:60-69 — config-level only
Add a single parametrized behavioral test that iterates the existing _REQUEST_MODELS collection, instantiates each model with minimal valid required kwargs plus ghost_field='x', and asserts pydantic.ValidationError:
minimal_kwargs(model_cls) can use model_cls.model_fields to compute required kwargs from defaults / annotations, or maintain a small fixture map for the ones that can't be auto-derived.
This pairs with the existing config check and pins behavior in addition to configuration.
Activity
test(models): parametrize phantom-kwarg behavioral test across all Re…
test(models): parametrize phantom-kwarg behavioral test across all Re…