Răsfoiți Sursa

Populate bulk_update_invalid_data for ipam API tests

Give each ipam test class an invalid payload so
test_bulk_update_objects_validation_error runs instead of skipping,
following the same preference order used for dcim.

Three classes needed something other than the obvious choice: Aggregate's
family is read-only on the serializer, and FHRPGroupAssignment and
VLANTranslationRule do not mix in OwnerMixin, so all three use a required
FK instead.

All 18 ipam API test classes now run the test.
Jason Novinger 16 ore în urmă
părinte
comite
17ebddd0f2
1 a modificat fișierele cu 54 adăugiri și 0 ștergeri
  1. 54 0
      netbox/ipam/tests/test_api.py

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

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