From de595f6a985a6522a39ba8f949132d11f00a691b Mon Sep 17 00:00:00 2001 From: Jason Novinger Date: Fri, 11 Sep 2026 02:54:42 -0500 Subject: [PATCH] Populate bulk_update_invalid_data for extras API tests Give each extras test class an invalid payload so test_bulk_update_objects_validation_error runs instead of skipping. extras serializers are more varied than dcim's, so fewer classes had a plain choice field to work with: the config context and template classes use a nonexistent data_source pk, and the saved filter, table config, export template and subscription classes use an invalid content type. Two fields were deliberately avoided. CustomField uses filter_logic rather than type, because validate_type rejects any type change on an existing instance and would fail for the wrong reason. EventRule uses action_type rather than event_types, whose ArrayField choices do not map to a reliable serializer error. All 16 extras API test classes now run the test. --- netbox/extras/tests/test_api.py | 48 +++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/netbox/extras/tests/test_api.py b/netbox/extras/tests/test_api.py index 6123dcc36..72454126e 100644 --- a/netbox/extras/tests/test_api.py +++ b/netbox/extras/tests/test_api.py @@ -62,6 +62,9 @@ class WebhookTestCase(APIViewTestCases.APIViewTestCase): 'description': 'New description', 'ssl_verification': False, } + bulk_update_invalid_data = { + 'http_method': 'not-a-valid-http-method', + } @classmethod def setUpTestData(cls): @@ -90,6 +93,9 @@ class EventRuleTestCase(APIViewTestCases.APIViewTestCase): 'enabled': False, 'description': 'New description', } + bulk_update_invalid_data = { + 'action_type': 'not-a-valid-action-type', + } update_data = { 'name': 'Event Rule X', 'enabled': False, @@ -308,6 +314,9 @@ class CustomFieldTestCase(APIViewTestCases.APIViewTestCase): 'description': 'New description', 'nulls_first': False, } + bulk_update_invalid_data = { + 'filter_logic': 'not-a-valid-filter-logic', + } update_data = { 'object_types': ['dcim.device'], 'name': 'New_Name', @@ -377,6 +386,9 @@ class CustomFieldChoiceSetTestCase(APIViewTestCases.APIViewTestCase): bulk_update_data = { 'description': 'New description', } + bulk_update_invalid_data = { + 'base_choices': 'not-a-valid-base-choices', + } update_data = { 'name': 'Choice Set X', 'extra_choices': [ @@ -577,6 +589,9 @@ class CustomLinkTestCase(APIViewTestCases.APIViewTestCase): 'new_window': True, 'enabled': False, } + bulk_update_invalid_data = { + 'button_class': 'not-a-valid-button-class', + } @classmethod def setUpTestData(cls): @@ -661,6 +676,9 @@ class SavedFilterTestCase(SharedObjectAPITestMixin, APIViewTestCases.APIViewTest 'enabled': False, 'shared': False, } + bulk_update_invalid_data = { + 'object_types': ['dcim.notamodel'], + } @classmethod def setUpTestData(cls): @@ -753,6 +771,9 @@ class TableConfigTestCase(SharedObjectAPITestMixin, APIViewTestCases.APIViewTest 'enabled': False, 'shared': False, } + bulk_update_invalid_data = { + 'object_type': 'dcim.notamodel', + } @classmethod def setUpTestData(cls): @@ -942,6 +963,9 @@ class ExportTemplateTestCase(APIViewTestCases.APIViewTestCase): bulk_update_data = { 'description': 'New description', } + bulk_update_invalid_data = { + 'object_types': ['dcim.notamodel'], + } @classmethod def setUpTestData(cls): @@ -989,6 +1013,9 @@ class TagTestCase(APIViewTestCases.APIViewTestCase): bulk_update_data = { 'description': 'New description', } + bulk_update_invalid_data = { + 'color': 'not-a-color', + } @classmethod def setUpTestData(cls): @@ -1083,6 +1110,9 @@ class JournalEntryTestCase(APIViewTestCases.APIViewTestCase): bulk_update_data = { 'comments': 'Overwritten', } + bulk_update_invalid_data = { + 'kind': 'not-a-valid-kind', + } @classmethod def setUpTestData(cls): @@ -1169,6 +1199,9 @@ class ConfigContextProfileTestCase(APIViewTestCases.APIViewTestCase): bulk_update_data = { 'description': 'New description', } + bulk_update_invalid_data = { + 'data_source': 99999, + } @classmethod def setUpTestData(cls): @@ -1281,6 +1314,9 @@ class ConfigContextTestCase(APIViewTestCases.APIViewTestCase): bulk_update_data = { 'description': 'New description', } + bulk_update_invalid_data = { + 'data_source': 99999, + } @classmethod def setUpTestData(cls): @@ -1411,6 +1447,9 @@ class ConfigTemplateTestCase(APIViewTestCases.APIViewTestCase): bulk_update_data = { 'description': 'New description', } + bulk_update_invalid_data = { + 'data_source': 99999, + } @classmethod def setUpTestData(cls): @@ -2226,6 +2265,9 @@ class SubscriptionTestCase(APIViewTestCases.APIViewTestCase): cls.bulk_update_data = { 'user': users[3].pk, } + cls.bulk_update_invalid_data = { + 'object_type': 'dcim.notamodel', + } class NotificationGroupTestCase(APIViewTestCases.APIViewTestCase): @@ -2257,6 +2299,9 @@ class NotificationGroupTestCase(APIViewTestCases.APIViewTestCase): bulk_update_data = { 'description': 'New description', } + bulk_update_invalid_data = { + 'users': [99999], + } @classmethod def setUpTestData(cls): @@ -2311,6 +2356,9 @@ class NotificationTestCase(APIViewTestCases.APIViewTestCase): bulk_update_data = { 'read': now(), } + bulk_update_invalid_data = { + 'event_type': 'not-a-valid-event-type', + } graphql_filter = { 'event_type': {'lookup': 'exact', 'value': OBJECT_CREATED}, }