Skip to content

Conversation

@pheus
Copy link
Contributor

@pheus pheus commented Dec 10, 2025

Fixes: #20491

This PR updates the API testing utilities so that numeric range array fields are represented consistently with the API serializers.

Specifically:

  • In utilities.testing.base.model_to_dict(), when api=True and the field is an ArrayField of a RangeField (e.g. ArrayField(IntegerRangeField)), the values are converted from psycopg's canonical half‑open ranges [low, high) into inclusive [low, high] pairs before comparison.
  • This matches the behavior of IntegerRangeSerializer(many=True, required=False), which exposes ranges as inclusive [low, high] pairs at the API boundary (for example, VLANGroup.vid_ranges).
  • The change is limited to the test harness and does not affect runtime behavior or the public API; it only ensures that APIViewTestCase compares data using the same representation as the serializers.

As a small regression check, the VLAN group API test (VLANGroupTest in ipam.tests.test_api) is updated to include a vid_ranges value in create_data so that this path is exercised automatically going forward.

Adds logic to handle numeric range fields in API responses by
converting them into inclusive `[low, high]` pairs for consistent
behavior. Updates test cases with `vid_ranges` fields to reflect the
changes.

Closes netbox-community#20491
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generic API test harness miscompares ArrayField(IntegerRangeField) values (NumericRange vs inclusive pairs)

1 participant