Fixes #20491: Normalize numeric range array fields for API test comparisons #20963
+10
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: #20491
This PR updates the API testing utilities so that numeric range array fields are represented consistently with the API serializers.
Specifically:
utilities.testing.base.model_to_dict(), whenapi=Trueand the field is anArrayFieldof aRangeField(e.g.ArrayField(IntegerRangeField)), the values are converted from psycopg's canonical half‑open ranges[low, high)into inclusive[low, high]pairs before comparison.IntegerRangeSerializer(many=True, required=False), which exposes ranges as inclusive[low, high]pairs at the API boundary (for example,VLANGroup.vid_ranges).APIViewTestCasecompares data using the same representation as the serializers.As a small regression check, the VLAN group API test (
VLANGroupTestinipam.tests.test_api) is updated to include avid_rangesvalue increate_dataso that this path is exercised automatically going forward.