Expand unit tests for ObjectChange and testing asserts #415

Open
opened 2026-04-05 16:30:52 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @arthanson on 2/5/2026

NetBox version

v4.5.2

Feature type

Other

Proposed functionality

Currently there are some basic tests for ObjectChange records in netbox/utilities/testing/views.py these are run for all models, however they only test that an ObjectChange was created (or deleted) and don't test several critical pieces of functionality like prechange and postchange data.

This FR is to look at adding tests to these for checking prechange and postchange data where possible, or expanding the tests so that tests can be done that a single ObjectChange is created and that the prechange and postchange data match what was expected.

It would also probably be beneficial to add specific assert functions specific to ObjectChange something like assert_prechange_data_equals or such that can be used in tests.

Use case

ObjectChange handling is central to NetBox and netbox-branching is completely driven off of it, so it is critical that it works correctly and it thoroughly tested. There have also been several very serious bugs in netbox-branching due to errors in incorrectly created ObjectChange records. There are some basic tests for all models in netbox/utilities/testing/views.py and these could be fairly easily expanded.

Database changes

N/A

External dependencies

N/A

*Originally created by @arthanson on 2/5/2026* ### NetBox version v4.5.2 ### Feature type Other ### Proposed functionality Currently there are some basic tests for ObjectChange records in `netbox/utilities/testing/views.py` these are run for all models, however they only test that an ObjectChange was created (or deleted) and don't test several critical pieces of functionality like prechange and postchange data. This FR is to look at adding tests to these for checking prechange and postchange data where possible, or expanding the tests so that tests can be done that a single ObjectChange is created and that the prechange and postchange data match what was expected. It would also probably be beneficial to add specific assert functions specific to ObjectChange something like assert_prechange_data_equals or such that can be used in tests. ### Use case ObjectChange handling is central to NetBox and netbox-branching is completely driven off of it, so it is critical that it works correctly and it thoroughly tested. There have also been several very serious bugs in netbox-branching due to errors in incorrectly created ObjectChange records. There are some basic tests for all models in `netbox/utilities/testing/views.py` and these could be fairly easily expanded. ### Database changes N/A ### External dependencies N/A
MrUnknownDE added the type: featuretopic: testingtype: featurenetboxstatus: backlogtype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featuretype: featurenetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxnetboxstatus: backlogstatus: backlogstatus: backlogstatus: backlogstatus: backlogstatus: backlogstatus: backlogstatus: backlogstatus: backlogstatus: backlogstatus: backlog labels 2026-04-05 16:30:58 +02:00
Sign in to join this conversation.
No Label netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox status: backlog status: backlog status: backlog status: backlog status: backlog status: backlog status: backlog status: backlog status: backlog status: backlog status: backlog status: backlog topic: testing type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/netbox#415