Populate bulk_update_invalid_data for the remaining API tests

Cover virtualization, tenancy, users, wireless and core so
test_bulk_update_objects_validation_error runs instead of skipping. Every
class in the suite that sets bulk_update_data now sets an invalid payload
alongside it.

Two cases needed care. DataSource's status is read-only on its serializer,
so a bogus status would have been ignored rather than rejected, and it
uses a nonexistent owner pk instead. OwnerGroup exposes only name,
description and a read-only member_count, so an over-length description is
the only value that can fail validation there. A comment records why.
This commit is contained in:
Jason Novinger 2026-09-11 03:00:39 -05:00
parent d23b8a2d07
commit 5816e25b81
5 changed files with 70 additions and 0 deletions

View File

@ -35,6 +35,9 @@ class DataSourceTestCase(APIViewTestCases.APIViewTestCase):
'enabled': False,
'description': 'foo bar baz',
}
bulk_update_invalid_data = {
'owner': 99999,
}
@classmethod
def setUpTestData(cls):

View File

@ -28,6 +28,9 @@ class TenantGroupTestCase(APIViewTestCases.APIViewTestCase):
'description': 'New description',
'comments': 'New Comment',
}
bulk_update_invalid_data = {
'owner': 99999,
}
@classmethod
def setUpTestData(cls):
@ -119,6 +122,9 @@ class TenantTestCase(APIViewTestCases.APIViewTestCase):
'group': None,
'description': 'New description',
}
bulk_update_invalid_data = {
'owner': 99999,
}
@classmethod
def setUpTestData(cls):
@ -160,6 +166,9 @@ class ContactGroupTestCase(APIViewTestCases.APIViewTestCase):
bulk_update_data = {
'description': 'New description',
}
bulk_update_invalid_data = {
'owner': 99999,
}
@classmethod
def setUpTestData(cls):
@ -219,6 +228,9 @@ class ContactRoleTestCase(APIViewTestCases.APIViewTestCase):
bulk_update_data = {
'description': 'New description',
}
bulk_update_invalid_data = {
'owner': 99999,
}
@classmethod
def setUpTestData(cls):
@ -238,6 +250,9 @@ class ContactTestCase(APIViewTestCases.APIViewTestCase):
'groups': [],
'comments': 'New comments',
}
bulk_update_invalid_data = {
'owner': 99999,
}
@classmethod
def setUpTestData(cls):
@ -277,6 +292,9 @@ class ContactAssignmentTestCase(APIViewTestCases.APIViewTestCase):
bulk_update_data = {
'priority': ContactPriorityChoices.PRIORITY_INACTIVE,
}
bulk_update_invalid_data = {
'priority': 'not-a-valid-priority',
}
user_permissions = ('tenancy.view_contact', )
@classmethod

View File

@ -24,6 +24,9 @@ class UserTestCase(APIViewTestCases.APIViewTestCase):
bulk_update_data = {
'email': 'test@example.com',
}
bulk_update_invalid_data = {
'email': 'not-an-email',
}
@classmethod
def setUpTestData(cls):
@ -202,6 +205,9 @@ class TokenTestCase(
bulk_update_data = {
'description': 'New description',
}
bulk_update_invalid_data = {
'expires': 'not-a-date',
}
def setUp(self):
super().setUp()
@ -588,6 +594,9 @@ class ObjectPermissionTestCase(
cls.bulk_update_data = {
'description': 'New description',
}
cls.bulk_update_invalid_data = {
'users': [99999],
}
class UserConfigTestCase(APITestCase):
@ -649,6 +658,11 @@ class OwnerGroupTestCase(APIViewTestCases.APIViewTestCase):
bulk_update_data = {
'description': 'New description',
}
# OwnerGroupSerializer exposes only name, description, and a read-only member_count, so an
# over-length description is the only value available to trigger a validation error.
bulk_update_invalid_data = {
'description': 'a' * 201,
}
@classmethod
def setUpTestData(cls):
@ -750,3 +764,7 @@ class OwnerTestCase(APIViewTestCases.APIViewTestCase):
'users': [users[3].pk],
'description': 'New description',
}
cls.bulk_update_invalid_data = {
'group': 99999,
}

View File

@ -56,6 +56,9 @@ class ClusterTypeTestCase(APIViewTestCases.APIViewTestCase):
bulk_update_data = {
'description': 'New description',
}
bulk_update_invalid_data = {
'owner': 99999,
}
@classmethod
def setUpTestData(cls):
@ -88,6 +91,9 @@ class ClusterGroupTestCase(APIViewTestCases.APIViewTestCase):
bulk_update_data = {
'description': 'New description',
}
bulk_update_invalid_data = {
'owner': 99999,
}
@classmethod
def setUpTestData(cls):
@ -107,6 +113,9 @@ class ClusterTestCase(APIViewTestCases.APIViewTestCase):
'status': 'offline',
'comments': 'New comment',
}
bulk_update_invalid_data = {
'status': 'not-a-valid-status',
}
@classmethod
def setUpTestData(cls):
@ -235,6 +244,9 @@ class VirtualMachineTypeTestCase(APIViewTestCases.APIViewTestCase):
'default_memory': 8192,
'description': 'New description',
}
cls.bulk_update_invalid_data = {
'owner': 99999,
}
class VirtualMachineTestCase(APIViewTestCases.APIViewTestCase):
@ -243,6 +255,9 @@ class VirtualMachineTestCase(APIViewTestCases.APIViewTestCase):
bulk_update_data = {
'status': 'staged',
}
bulk_update_invalid_data = {
'status': 'not-a-valid-status',
}
user_permissions = ('dcim.view_platform', 'virtualization.view_virtualmachinetype')
@classmethod
@ -624,6 +639,9 @@ class VMInterfaceTestCase(APIViewTestCases.APIViewTestCase):
bulk_update_data = {
'description': 'New description',
}
bulk_update_invalid_data = {
'mode': 'not-a-valid-mode',
}
graphql_base_name = 'vm_interface'
user_permissions = ('virtualization.view_virtualmachine', )
@ -915,6 +933,9 @@ class VirtualDiskTestCase(APIViewTestCases.APIViewTestCase):
bulk_update_data = {
'size': 888,
}
bulk_update_invalid_data = {
'virtual_machine': 99999,
}
graphql_base_name = 'virtual_disk'
user_permissions = ('virtualization.view_virtualmachine', )

View File

@ -40,6 +40,9 @@ class WirelessLANGroupTestCase(APIViewTestCases.APIViewTestCase):
'description': 'New description',
'comments': 'New comment',
}
bulk_update_invalid_data = {
'owner': 99999,
}
@classmethod
def setUpTestData(cls):
@ -118,6 +121,10 @@ class WirelessLANTestCase(APIViewTestCases.APIViewTestCase):
'auth_psk': 'abc123def456',
}
cls.bulk_update_invalid_data = {
'auth_type': 'not-a-valid-auth-type',
}
class WirelessLinkTestCase(APIViewTestCases.APIViewTestCase):
model = WirelessLink
@ -127,6 +134,9 @@ class WirelessLinkTestCase(APIViewTestCases.APIViewTestCase):
'distance': 100,
'distance_unit': 'm',
}
bulk_update_invalid_data = {
'status': 'not-a-valid-status',
}
user_permissions = ('dcim.view_interface', )
@classmethod