Преглед на файлове

Closes #23046: Address tests that are skipped by default (#23162)

Jason Novinger преди 1 месец
родител
ревизия
5a9a9d2a25

+ 1 - 1
.github/workflows/ci.yml

@@ -121,7 +121,7 @@ jobs:
         run: |
         run: |
           python -m pip install --upgrade pip
           python -m pip install --upgrade pip
           pip install -r requirements.txt
           pip install -r requirements.txt
-          pip install coverage tblib
+          pip install -r requirements_testing.txt
 
 
       - name: Check for missing migrations
       - name: Check for missing migrations
         run: python netbox/manage.py makemigrations --check
         run: python netbox/manage.py makemigrations --check

+ 33 - 0
netbox/circuits/tests/test_api.py

@@ -23,6 +23,9 @@ class ProviderTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'comments': 'New comments',
         'comments': 'New comments',
     }
     }
+    bulk_update_invalid_data = {
+        'owner': 99999,
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -79,6 +82,9 @@ class CircuitTypeTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'color': 'not-a-color',
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -97,6 +103,9 @@ class CircuitTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'status': 'planned',
         'status': 'planned',
     }
     }
+    bulk_update_invalid_data = {
+        'status': 'not-a-valid-status',
+    }
     user_permissions = ('circuits.view_provider', 'circuits.view_circuittype')
     user_permissions = ('circuits.view_provider', 'circuits.view_circuittype')
 
 
     @classmethod
     @classmethod
@@ -215,6 +224,9 @@ class CircuitTerminationTestCase(APIViewTestCases.APIViewTestCase):
         cls.bulk_update_data = {
         cls.bulk_update_data = {
             'port_speed': 123456
             'port_speed': 123456
         }
         }
+        cls.bulk_update_invalid_data = {
+            'term_side': 'not-a-valid-term-side',
+        }
 
 
 
 
 class CircuitGroupTestCase(APIViewTestCases.APIViewTestCase):
 class CircuitGroupTestCase(APIViewTestCases.APIViewTestCase):
@@ -223,6 +235,9 @@ class CircuitGroupTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'tenant': 99999,
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -291,6 +306,9 @@ class ProviderAccountTestCase(APIViewTestCases.APIViewTestCase):
             'provider': providers[1].pk,
             'provider': providers[1].pk,
             'description': 'New description',
             'description': 'New description',
         }
         }
+        cls.bulk_update_invalid_data = {
+            'provider': 99999,
+        }
 
 
 
 
 class CircuitGroupAssignmentTestCase(APIViewTestCases.APIViewTestCase):
 class CircuitGroupAssignmentTestCase(APIViewTestCases.APIViewTestCase):
@@ -299,6 +317,9 @@ class CircuitGroupAssignmentTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'priority': CircuitPriorityChoices.PRIORITY_INACTIVE,
         'priority': CircuitPriorityChoices.PRIORITY_INACTIVE,
     }
     }
+    bulk_update_invalid_data = {
+        'priority': 'not-a-valid-priority',
+    }
     user_permissions = ('circuits.view_circuit', 'circuits.view_circuitgroup')
     user_permissions = ('circuits.view_circuit', 'circuits.view_circuitgroup')
 
 
     @classmethod
     @classmethod
@@ -407,6 +428,9 @@ class ProviderNetworkTestCase(APIViewTestCases.APIViewTestCase):
             'provider': providers[1].pk,
             'provider': providers[1].pk,
             'description': 'New description',
             'description': 'New description',
         }
         }
+        cls.bulk_update_invalid_data = {
+            'provider': 99999,
+        }
 
 
 
 
 class VirtualCircuitTypeTestCase(APIViewTestCases.APIViewTestCase):
 class VirtualCircuitTypeTestCase(APIViewTestCases.APIViewTestCase):
@@ -429,6 +453,9 @@ class VirtualCircuitTypeTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'color': 'not-a-color',
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -447,6 +474,9 @@ class VirtualCircuitTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'status': 'planned',
         'status': 'planned',
     }
     }
+    bulk_update_invalid_data = {
+        'status': 'not-a-valid-status',
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -511,6 +541,9 @@ class VirtualCircuitTerminationTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'role': 'not-a-valid-role',
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):

+ 3 - 0
netbox/core/tests/test_api.py

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

+ 153 - 0
netbox/dcim/tests/test_api.py

@@ -106,6 +106,9 @@ class RegionTestCase(APIViewTestCases.APIViewTestCase):
         'description': 'New description',
         'description': 'New description',
         'comments': 'New comments',
         'comments': 'New comments',
     }
     }
+    bulk_update_invalid_data = {
+        'owner': 99999,
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -139,6 +142,9 @@ class SiteGroupTestCase(APIViewTestCases.APIViewTestCase):
         'description': 'New description',
         'description': 'New description',
         'comments': 'I do exist!',
         'comments': 'I do exist!',
     }
     }
+    bulk_update_invalid_data = {
+        'owner': 99999,
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -973,6 +979,9 @@ class LocationTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'status': 'not-a-valid-status',
+    }
     user_permissions = ('dcim.view_site',)
     user_permissions = ('dcim.view_site',)
     graphql_filter_tests = (
     graphql_filter_tests = (
         GraphQLFilterTest(
         GraphQLFilterTest(
@@ -1095,6 +1104,9 @@ class RackGroupTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'owner': 99999,
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -1130,6 +1142,9 @@ class RackRoleTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'color': 'not-a-color',
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -1150,6 +1165,9 @@ class RackTypeTestCase(APIViewTestCases.APIViewTestCase):
         'cooling_capability': RackCoolingCapabilityChoices.CAPABILITY_HYBRID,
         'cooling_capability': RackCoolingCapabilityChoices.CAPABILITY_HYBRID,
         'cooling_capacity': 50,
         'cooling_capacity': 50,
     }
     }
+    bulk_update_invalid_data = {
+        'form_factor': 'not-a-valid-form-factor',
+    }
     user_permissions = ('dcim.view_manufacturer',)
     user_permissions = ('dcim.view_manufacturer',)
 
 
     @classmethod
     @classmethod
@@ -1235,6 +1253,9 @@ class RackTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'status': 'planned',
         'status': 'planned',
     }
     }
+    bulk_update_invalid_data = {
+        'status': 'not-a-valid-status',
+    }
     user_permissions = ('dcim.view_site', )
     user_permissions = ('dcim.view_site', )
 
 
     @classmethod
     @classmethod
@@ -1361,6 +1382,9 @@ class RackReservationTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'status': 'not-a-valid-status',
+    }
     user_permissions = ('dcim.view_rack', 'users.view_user')
     user_permissions = ('dcim.view_rack', 'users.view_user')
 
 
     @classmethod
     @classmethod
@@ -1450,6 +1474,9 @@ class ManufacturerTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'owner': 99999,
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -1469,6 +1496,9 @@ class DeviceTypeTestCase(APIViewTestCases.APIViewTestCase):
         'part_number': 'ABC123',
         'part_number': 'ABC123',
         'end_of_life': '2030-01-01',
         'end_of_life': '2030-01-01',
     }
     }
+    bulk_update_invalid_data = {
+        'airflow': 'not-a-valid-airflow',
+    }
     user_permissions = ('dcim.view_manufacturer', )
     user_permissions = ('dcim.view_manufacturer', )
 
 
     @classmethod
     @classmethod
@@ -1517,6 +1547,9 @@ class ModuleTypeTestCase(APIViewTestCases.APIViewTestCase):
         'part_number': 'ABC123',
         'part_number': 'ABC123',
         'end_of_life': '2030-01-01',
         'end_of_life': '2030-01-01',
     }
     }
+    bulk_update_invalid_data = {
+        'airflow': 'not-a-valid-airflow',
+    }
     user_permissions = ('dcim.view_manufacturer', )
     user_permissions = ('dcim.view_manufacturer', )
 
 
     @classmethod
     @classmethod
@@ -1606,6 +1639,9 @@ class ModuleTypeProfileTestCase(APIViewTestCases.APIViewTestCase):
         'description': 'New description',
         'description': 'New description',
         'comments': 'New comments',
         'comments': 'New comments',
     }
     }
+    bulk_update_invalid_data = {
+        'owner': 99999,
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -1632,6 +1668,9 @@ class ModuleBayTypeTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'color': 'not-a-color',
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -1673,6 +1712,9 @@ class ConsolePortTemplateTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'type': 'not-a-valid-type',
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -1717,6 +1759,9 @@ class ConsoleServerPortTemplateTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'type': 'not-a-valid-type',
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -1761,6 +1806,9 @@ class PowerPortTemplateTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'type': 'not-a-valid-type',
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -1805,6 +1853,9 @@ class PowerOutletTemplateTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'type': 'not-a-valid-type',
+    }
     user_permissions = ('dcim.view_devicetype', )
     user_permissions = ('dcim.view_devicetype', )
 
 
     @classmethod
     @classmethod
@@ -1863,6 +1914,9 @@ class InterfaceTemplateTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'poe_mode': 'not-a-valid-poe-mode',
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -1928,6 +1982,9 @@ class FrontPortTemplateTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'color': 'not-a-color',
+    }
     user_permissions = ('dcim.view_rearporttemplate', )
     user_permissions = ('dcim.view_rearporttemplate', )
 
 
     @classmethod
     @classmethod
@@ -2045,6 +2102,9 @@ class RearPortTemplateTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'color': 'not-a-color',
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -2161,6 +2221,9 @@ class ModuleBayTemplateTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'device_type': 99999,
+    }
     user_permissions = ('dcim.view_devicetype', )
     user_permissions = ('dcim.view_devicetype', )
 
 
     @classmethod
     @classmethod
@@ -2213,6 +2276,9 @@ class DeviceBayTemplateTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'device_type': 99999,
+    }
     user_permissions = ('dcim.view_devicetype', )
     user_permissions = ('dcim.view_devicetype', )
 
 
     @classmethod
     @classmethod
@@ -2255,6 +2321,9 @@ class InventoryItemTemplateTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'role': 99999,
+    }
     user_permissions = ('dcim.view_devicetype', 'dcim.view_manufacturer',)
     user_permissions = ('dcim.view_devicetype', 'dcim.view_manufacturer',)
 
 
     @classmethod
     @classmethod
@@ -2334,6 +2403,9 @@ class DeviceRoleTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'color': 'not-a-color',
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -2365,6 +2437,9 @@ class PlatformTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'owner': 99999,
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -2384,6 +2459,9 @@ class DeviceTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'status': 'failed',
         'status': 'failed',
     }
     }
+    bulk_update_invalid_data = {
+        'status': 'not-a-valid-status',
+    }
     user_permissions = (
     user_permissions = (
         'dcim.view_site', 'dcim.view_rack', 'dcim.view_location', 'dcim.view_devicerole', 'dcim.view_devicetype',
         'dcim.view_site', 'dcim.view_rack', 'dcim.view_location', 'dcim.view_devicerole', 'dcim.view_devicetype',
     )
     )
@@ -2843,6 +2921,9 @@ class ModuleTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'serial': '1234ABCD',
         'serial': '1234ABCD',
     }
     }
+    bulk_update_invalid_data = {
+        'status': 'not-a-valid-status',
+    }
     user_permissions = (
     user_permissions = (
         'dcim.view_modulebay', 'dcim.view_moduletype', 'dcim.view_moduletypeprofile', 'dcim.view_device'
         'dcim.view_modulebay', 'dcim.view_moduletype', 'dcim.view_moduletypeprofile', 'dcim.view_device'
     )
     )
@@ -3339,6 +3420,9 @@ class ConsolePortTestCase(Mixins.ComponentTraceMixin, APIViewTestCases.APIViewTe
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'type': 'not-a-valid-type',
+    }
     peer_termination_type = ConsoleServerPort
     peer_termination_type = ConsoleServerPort
     user_permissions = ('dcim.view_device', )
     user_permissions = ('dcim.view_device', )
 
 
@@ -3382,6 +3466,9 @@ class ConsoleServerPortTestCase(Mixins.ComponentTraceMixin, APIViewTestCases.API
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'type': 'not-a-valid-type',
+    }
     peer_termination_type = ConsolePort
     peer_termination_type = ConsolePort
     user_permissions = ('dcim.view_device', )
     user_permissions = ('dcim.view_device', )
 
 
@@ -3425,6 +3512,9 @@ class PowerPortTestCase(Mixins.ComponentTraceMixin, APIViewTestCases.APIViewTest
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'type': 'not-a-valid-type',
+    }
     peer_termination_type = PowerOutlet
     peer_termination_type = PowerOutlet
     user_permissions = ('dcim.view_device', )
     user_permissions = ('dcim.view_device', )
 
 
@@ -3465,6 +3555,9 @@ class PowerOutletTestCase(Mixins.ComponentTraceMixin, APIViewTestCases.APIViewTe
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'status': 'not-a-valid-status',
+    }
     peer_termination_type = PowerPort
     peer_termination_type = PowerPort
     user_permissions = ('dcim.view_device', )
     user_permissions = ('dcim.view_device', )
 
 
@@ -3514,6 +3607,9 @@ class InterfaceTestCase(Mixins.ComponentTraceMixin, APIViewTestCases.APIViewTest
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'poe_mode': 'not-a-valid-poe-mode',
+    }
     peer_termination_type = Interface
     peer_termination_type = Interface
     user_permissions = ('dcim.view_device', )
     user_permissions = ('dcim.view_device', )
 
 
@@ -4073,6 +4169,9 @@ class FrontPortTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'color': 'not-a-color',
+    }
     peer_termination_type = Interface
     peer_termination_type = Interface
     user_permissions = ('dcim.view_device', 'dcim.view_rearport')
     user_permissions = ('dcim.view_device', 'dcim.view_rearport')
 
 
@@ -4192,6 +4291,9 @@ class RearPortTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'color': 'not-a-color',
+    }
     peer_termination_type = Interface
     peer_termination_type = Interface
     user_permissions = ('dcim.view_device', )
     user_permissions = ('dcim.view_device', )
 
 
@@ -4308,6 +4410,9 @@ class ModuleBayTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'owner': 99999,
+    }
     user_permissions = ('dcim.view_device', )
     user_permissions = ('dcim.view_device', )
 
 
     @classmethod
     @classmethod
@@ -4439,6 +4544,9 @@ class DeviceBayTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'owner': 99999,
+    }
     user_permissions = ('dcim.view_device', )
     user_permissions = ('dcim.view_device', )
 
 
     @classmethod
     @classmethod
@@ -4503,6 +4611,9 @@ class InventoryItemTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'status': 'not-a-valid-status',
+    }
     user_permissions = ('dcim.view_device', 'dcim.view_manufacturer')
     user_permissions = ('dcim.view_device', 'dcim.view_manufacturer')
 
 
     @classmethod
     @classmethod
@@ -4587,6 +4698,9 @@ class InventoryItemRoleTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'color': 'not-a-color',
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -4610,6 +4724,9 @@ class CableBundleTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'owner': 99999,
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -4660,6 +4777,9 @@ class CableTestCase(APIViewTestCases.APIViewTestCase):
         'length': 100,
         'length': 100,
         'length_unit': 'm',
         'length_unit': 'm',
     }
     }
+    bulk_update_invalid_data = {
+        'status': 'not-a-valid-status',
+    }
 
 
     # TODO: Allow updating cable terminations
     # TODO: Allow updating cable terminations
     test_update_object = None
     test_update_object = None
@@ -5116,6 +5236,9 @@ class VirtualChassisTestCase(APIViewTestCases.APIViewTestCase):
             'domain': 'newdomain',
             'domain': 'newdomain',
             'master': None
             'master': None
         }
         }
+        cls.bulk_update_invalid_data = {
+            'owner': 99999,
+        }
 
 
 
 
 class PowerPanelTestCase(APIViewTestCases.APIViewTestCase):
 class PowerPanelTestCase(APIViewTestCases.APIViewTestCase):
@@ -5166,6 +5289,9 @@ class PowerPanelTestCase(APIViewTestCases.APIViewTestCase):
             'site': sites[1].pk,
             'site': sites[1].pk,
             'location': locations[3].pk
             'location': locations[3].pk
         }
         }
+        cls.bulk_update_invalid_data = {
+            'owner': 99999,
+        }
 
 
 
 
 class PowerFeedTestCase(APIViewTestCases.APIViewTestCase):
 class PowerFeedTestCase(APIViewTestCases.APIViewTestCase):
@@ -5174,6 +5300,9 @@ class PowerFeedTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'status': 'planned',
         'status': 'planned',
     }
     }
+    bulk_update_invalid_data = {
+        'status': 'not-a-valid-status',
+    }
     user_permissions = ('dcim.view_powerpanel', )
     user_permissions = ('dcim.view_powerpanel', )
 
 
     @classmethod
     @classmethod
@@ -5230,6 +5359,9 @@ class CoolingIntakeTemplateTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'type': 'not-a-valid-type',
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -5275,6 +5407,9 @@ class CoolingOutflowTemplateTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'type': 'not-a-valid-type',
+    }
     user_permissions = ('dcim.view_devicetype', )
     user_permissions = ('dcim.view_devicetype', )
 
 
     @classmethod
     @classmethod
@@ -5334,6 +5469,9 @@ class CoolingIntakeTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'type': 'not-a-valid-type',
+    }
     user_permissions = ('dcim.view_device', )
     user_permissions = ('dcim.view_device', )
 
 
     @classmethod
     @classmethod
@@ -5378,6 +5516,9 @@ class CoolingOutflowTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'type': 'not-a-valid-type',
+    }
     user_permissions = ('dcim.view_device', )
     user_permissions = ('dcim.view_device', )
 
 
     @classmethod
     @classmethod
@@ -5481,6 +5622,9 @@ class CoolingSourceTestCase(APIViewTestCases.APIViewTestCase):
             'site': sites[1].pk,
             'site': sites[1].pk,
             'location': locations[3].pk
             'location': locations[3].pk
         }
         }
+        cls.bulk_update_invalid_data = {
+            'status': 'not-a-valid-status',
+        }
 
 
 
 
 class CoolingFeedTestCase(APIViewTestCases.APIViewTestCase):
 class CoolingFeedTestCase(APIViewTestCases.APIViewTestCase):
@@ -5489,6 +5633,9 @@ class CoolingFeedTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'status': 'planned',
         'status': 'planned',
     }
     }
+    bulk_update_invalid_data = {
+        'status': 'not-a-valid-status',
+    }
     user_permissions = ('dcim.view_coolingsource', )
     user_permissions = ('dcim.view_coolingsource', )
 
 
     @classmethod
     @classmethod
@@ -5550,6 +5697,9 @@ class VirtualDeviceContextTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'status': 'planned',
         'status': 'planned',
     }
     }
+    bulk_update_invalid_data = {
+        'status': 'not-a-valid-status',
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -5673,6 +5823,9 @@ class MACAddressTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'owner': 99999,
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):

+ 48 - 0
netbox/extras/tests/test_api.py

@@ -62,6 +62,9 @@ class WebhookTestCase(APIViewTestCases.APIViewTestCase):
         'description': 'New description',
         'description': 'New description',
         'ssl_verification': False,
         'ssl_verification': False,
     }
     }
+    bulk_update_invalid_data = {
+        'http_method': 'not-a-valid-http-method',
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -90,6 +93,9 @@ class EventRuleTestCase(APIViewTestCases.APIViewTestCase):
         'enabled': False,
         'enabled': False,
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'action_type': 'not-a-valid-action-type',
+    }
     update_data = {
     update_data = {
         'name': 'Event Rule X',
         'name': 'Event Rule X',
         'enabled': False,
         'enabled': False,
@@ -308,6 +314,9 @@ class CustomFieldTestCase(APIViewTestCases.APIViewTestCase):
         'description': 'New description',
         'description': 'New description',
         'nulls_first': False,
         'nulls_first': False,
     }
     }
+    bulk_update_invalid_data = {
+        'filter_logic': 'not-a-valid-filter-logic',
+    }
     update_data = {
     update_data = {
         'object_types': ['dcim.device'],
         'object_types': ['dcim.device'],
         'name': 'New_Name',
         'name': 'New_Name',
@@ -377,6 +386,9 @@ class CustomFieldChoiceSetTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'base_choices': 'not-a-valid-base-choices',
+    }
     update_data = {
     update_data = {
         'name': 'Choice Set X',
         'name': 'Choice Set X',
         'extra_choices': [
         'extra_choices': [
@@ -577,6 +589,9 @@ class CustomLinkTestCase(APIViewTestCases.APIViewTestCase):
         'new_window': True,
         'new_window': True,
         'enabled': False,
         'enabled': False,
     }
     }
+    bulk_update_invalid_data = {
+        'button_class': 'not-a-valid-button-class',
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -661,6 +676,9 @@ class SavedFilterTestCase(SharedObjectAPITestMixin, APIViewTestCases.APIViewTest
         'enabled': False,
         'enabled': False,
         'shared': False,
         'shared': False,
     }
     }
+    bulk_update_invalid_data = {
+        'object_types': ['dcim.notamodel'],
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -753,6 +771,9 @@ class TableConfigTestCase(SharedObjectAPITestMixin, APIViewTestCases.APIViewTest
         'enabled': False,
         'enabled': False,
         'shared': False,
         'shared': False,
     }
     }
+    bulk_update_invalid_data = {
+        'object_type': 'dcim.notamodel',
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -942,6 +963,9 @@ class ExportTemplateTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'object_types': ['dcim.notamodel'],
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -1255,6 +1279,9 @@ class TagTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'color': 'not-a-color',
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -1349,6 +1376,9 @@ class JournalEntryTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'comments': 'Overwritten',
         'comments': 'Overwritten',
     }
     }
+    bulk_update_invalid_data = {
+        'kind': 'not-a-valid-kind',
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -1435,6 +1465,9 @@ class ConfigContextProfileTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'data_source': 99999,
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -1612,6 +1645,9 @@ class ConfigContextTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'data_source': 99999,
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -1863,6 +1899,9 @@ class ConfigTemplateTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'data_source': 99999,
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -2714,6 +2753,9 @@ class SubscriptionTestCase(APIViewTestCases.APIViewTestCase):
         cls.bulk_update_data = {
         cls.bulk_update_data = {
             'user': users[3].pk,
             'user': users[3].pk,
         }
         }
+        cls.bulk_update_invalid_data = {
+            'object_type': 'dcim.notamodel',
+        }
 
 
 
 
 class NotificationGroupTestCase(APIViewTestCases.APIViewTestCase):
 class NotificationGroupTestCase(APIViewTestCases.APIViewTestCase):
@@ -2745,6 +2787,9 @@ class NotificationGroupTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'users': [99999],
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -2799,6 +2844,9 @@ class NotificationTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'read': now(),
         'read': now(),
     }
     }
+    bulk_update_invalid_data = {
+        'event_type': 'not-a-valid-event-type',
+    }
     graphql_filter = {
     graphql_filter = {
         'event_type': {'lookup': 'exact', 'value': OBJECT_CREATED},
         'event_type': {'lookup': 'exact', 'value': OBJECT_CREATED},
     }
     }

+ 54 - 0
netbox/ipam/tests/test_api.py

@@ -30,6 +30,9 @@ class ASNRangeTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'owner': 99999,
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -142,6 +145,9 @@ class ASNTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'owner': 99999,
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -220,6 +226,9 @@ class VRFTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'owner': 99999,
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -263,6 +272,9 @@ class RouteTargetTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'owner': 99999,
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -295,6 +307,9 @@ class RIRTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'owner': 99999,
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -313,6 +328,9 @@ class AggregateTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'rir': 99999,
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -415,6 +433,9 @@ class RoleTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'owner': 99999,
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -455,6 +476,9 @@ class PrefixTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'status': 'not-a-valid-status',
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -754,6 +778,9 @@ class IPRangeTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'status': 'not-a-valid-status',
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -909,6 +936,9 @@ class IPAddressTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'status': 'not-a-valid-status',
+    }
     graphql_filter = {
     graphql_filter = {
         'address': {'lookup': 'i_exact', 'value': '192.168.0.1/24'},
         'address': {'lookup': 'i_exact', 'value': '192.168.0.1/24'},
     }
     }
@@ -1071,6 +1101,9 @@ class FHRPGroupTestCase(APIViewTestCases.APIViewTestCase):
         'name': 'foobar-999',
         'name': 'foobar-999',
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'protocol': 'not-a-valid-protocol',
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -1117,6 +1150,9 @@ class FHRPGroupAssignmentTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'priority': 100,
         'priority': 100,
     }
     }
+    bulk_update_invalid_data = {
+        'group': 99999,
+    }
     user_permissions = ('ipam.view_fhrpgroup', )
     user_permissions = ('ipam.view_fhrpgroup', )
 
 
     @classmethod
     @classmethod
@@ -1214,6 +1250,9 @@ class VLANGroupTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'owner': 99999,
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -1320,6 +1359,9 @@ class VLANTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'status': 'not-a-valid-status',
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -1387,6 +1429,9 @@ class VLANTranslationPolicyTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'owner': 99999,
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -1523,6 +1568,9 @@ class VLANTranslationRuleTestCase(APIViewTestCases.APIViewTestCase):
             'policy': vlan_translation_policies[2].pk,
             'policy': vlan_translation_policies[2].pk,
             'description': 'New description',
             'description': 'New description',
         }
         }
+        cls.bulk_update_invalid_data = {
+            'policy': 99999,
+        }
 
 
     def test_standard_fields_in_representation(self):
     def test_standard_fields_in_representation(self):
         """The standard URL, tag, custom-field and change-tracking names appear in the representation."""
         """The standard URL, tag, custom-field and change-tracking names appear in the representation."""
@@ -1554,6 +1602,9 @@ class ServiceTemplateTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'owner': 99999,
+    }
     graphql_base_name = 'service_template'
     graphql_base_name = 'service_template'
 
 
     @classmethod
     @classmethod
@@ -1838,6 +1889,9 @@ class ServiceTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'owner': 99999,
+    }
     graphql_base_name = 'service'
     graphql_base_name = 'service'
 
 
     @classmethod
     @classmethod

+ 18 - 0
netbox/tenancy/tests/test_api.py

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

+ 18 - 0
netbox/users/tests/test_api.py

@@ -29,6 +29,9 @@ class UserTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'email': 'test@example.com',
         'email': 'test@example.com',
     }
     }
+    bulk_update_invalid_data = {
+        'email': 'not-an-email',
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -207,6 +210,9 @@ class TokenTestCase(
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'expires': 'not-a-date',
+    }
 
 
     def setUp(self):
     def setUp(self):
         super().setUp()
         super().setUp()
@@ -739,6 +745,9 @@ class ObjectPermissionTestCase(
         cls.bulk_update_data = {
         cls.bulk_update_data = {
             'description': 'New description',
             'description': 'New description',
         }
         }
+        cls.bulk_update_invalid_data = {
+            'users': [99999],
+        }
 
 
 
 
 class UserConfigTestCase(APITestCase):
 class UserConfigTestCase(APITestCase):
@@ -800,6 +809,11 @@ class OwnerGroupTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         '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
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -901,3 +915,7 @@ class OwnerTestCase(APIViewTestCases.APIViewTestCase):
             'users': [users[3].pk],
             'users': [users[3].pk],
             'description': 'New description',
             'description': 'New description',
         }
         }
+
+        cls.bulk_update_invalid_data = {
+            'group': 99999,
+        }

+ 21 - 0
netbox/virtualization/tests/test_api.py

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

+ 32 - 0
netbox/vpn/tests/test_api.py

@@ -38,6 +38,9 @@ class TunnelGroupTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'owner': 99999,
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -58,6 +61,9 @@ class TunnelTestCase(APIViewTestCases.APIViewTestCase):
         'encapsulation': TunnelEncapsulationChoices.ENCAP_GRE,
         'encapsulation': TunnelEncapsulationChoices.ENCAP_GRE,
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'status': 'not-a-valid-status',
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -117,6 +123,9 @@ class TunnelTerminationTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'role': TunnelTerminationRoleChoices.ROLE_PEER,
         'role': TunnelTerminationRoleChoices.ROLE_PEER,
     }
     }
+    bulk_update_invalid_data = {
+        'role': 'not-a-valid-role',
+    }
     user_permissions = ('vpn.view_tunnel', )
     user_permissions = ('vpn.view_tunnel', )
 
 
     @classmethod
     @classmethod
@@ -189,6 +198,9 @@ class IKEProposalTestCase(APIViewTestCases.APIViewTestCase):
         'group': DHGroupChoices.GROUP_19,
         'group': DHGroupChoices.GROUP_19,
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'authentication_algorithm': 'not-a-valid-authentication-algorithm',
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -252,6 +264,9 @@ class IKEPolicyTestCase(APIViewTestCases.APIViewTestCase):
         'description': 'New description',
         'description': 'New description',
         'preshared_key': 'New key',
         'preshared_key': 'New key',
     }
     }
+    bulk_update_invalid_data = {
+        'version': 'not-a-valid-version',
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -325,6 +340,9 @@ class IPSecProposalTestCase(APIViewTestCases.APIViewTestCase):
         'authentication_algorithm': AuthenticationAlgorithmChoices.AUTH_HMAC_MD5,
         'authentication_algorithm': AuthenticationAlgorithmChoices.AUTH_HMAC_MD5,
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'encryption_algorithm': 'not-a-valid-encryption-algorithm',
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -374,6 +392,9 @@ class IPSecPolicyTestCase(APIViewTestCases.APIViewTestCase):
         'pfs_group': DHGroupChoices.GROUP_5,
         'pfs_group': DHGroupChoices.GROUP_5,
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'pfs_group': 'not-a-valid-pfs-group',
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -519,6 +540,10 @@ class IPSecProfileTestCase(APIViewTestCases.APIViewTestCase):
             'description': 'New description',
             'description': 'New description',
         }
         }
 
 
+        cls.bulk_update_invalid_data = {
+            'mode': 'not-a-valid-mode',
+        }
+
 
 
 class L2VPNTestCase(APIViewTestCases.APIViewTestCase):
 class L2VPNTestCase(APIViewTestCases.APIViewTestCase):
     model = L2VPN
     model = L2VPN
@@ -549,6 +574,9 @@ class L2VPNTestCase(APIViewTestCases.APIViewTestCase):
     bulk_update_data = {
     bulk_update_data = {
         'description': 'New description',
         'description': 'New description',
     }
     }
+    bulk_update_invalid_data = {
+        'status': 'not-a-valid-status',
+    }
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -676,3 +704,7 @@ class L2VPNTerminationTestCase(APIViewTestCases.APIViewTestCase):
         cls.bulk_update_data = {
         cls.bulk_update_data = {
             'l2vpn': l2vpns[2].pk
             'l2vpn': l2vpns[2].pk
         }
         }
+
+        cls.bulk_update_invalid_data = {
+            'l2vpn': 99999,
+        }

+ 10 - 0
netbox/wireless/tests/test_api.py

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

+ 5 - 0
requirements_testing.txt

@@ -0,0 +1,5 @@
+# Packages needed to run the test suite, but not to run NetBox itself.
+# dulwich is the optional 'git' extra, so it is absent from requirements.txt.
+coverage==7.16.0
+dulwich==1.2.14
+tblib==3.2.2