Commit 212ba99
committed
test(filter/utils): cover extracted filter type helpers + non-model field regression
Add ``graphene_django/filter/tests/test_utils.py`` with focused unit
tests for every helper extracted from
``get_filtering_args_from_filterset``:
* ``get_field_type_from_registry`` (registered model, NonNull
unwrapping, missing model, missing field).
* ``_is_foreign_key_form_field`` (parametrised over the four
FK-related form-field classes plus a non-FK negative case).
* ``_get_form_field`` (model_field.formfield wins, falls back to
filter_field.field when model_field is None or the factory yields
falsy).
* ``_get_field_type_from_model_field`` (FK -> related-model id,
non-FK -> owning model + field name).
* ``_get_field_type_and_form_field_for_implicit_filter`` (isnull
short-circuit, real model field, missing model field).
* ``_get_field_type_for_explicit_filter`` (uses passed form_field,
falls back to filter_field.field).
* ``_is_filter_list_or_range`` (ListFilter, RangeFilter, plain
CharFilter).
Plus an integration regression test that exercises
``get_filtering_args_from_filterset`` end-to-end for a method-backed
filter targeting a non-model field — pinning the subtle
behavioural-parity concern flagged in PR graphql-python#1457 review (the
implicit-filter path must still allow the explicit-filter fallback to
build the Argument when the filter has no underlying model field).
Each test follows the team docstring template (Name / Description /
Assumptions / Expectations); the file's module docstring spells out
the assumptions and scenarios that apply file-wide.
All 23 tests pass; existing 64 filter tests continue to pass.
Made-with: Cursor1 parent 48fc6ce commit 212ba99
1 file changed
+613
-0
lines changed
0 commit comments