From e6091ee0c99c2ac2f86328ad074863bfac5fe543 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Wed, 30 Jun 2021 10:07:33 -0400 Subject: [PATCH] Consolidate GraphQLTestCase into APIViewTestCase --- netbox/circuits/tests/test_api.py | 10 +-- netbox/dcim/tests/test_api.py | 86 ++++++++++--------------- netbox/extras/tests/test_api.py | 14 ++-- netbox/ipam/tests/test_api.py | 20 +++--- netbox/tenancy/tests/test_api.py | 4 +- netbox/users/tests/test_api.py | 22 +++++-- netbox/utilities/testing/api.py | 3 +- netbox/virtualization/tests/test_api.py | 10 +-- 8 files changed, 82 insertions(+), 87 deletions(-) diff --git a/netbox/circuits/tests/test_api.py b/netbox/circuits/tests/test_api.py index fd9e87412..424b13d40 100644 --- a/netbox/circuits/tests/test_api.py +++ b/netbox/circuits/tests/test_api.py @@ -15,7 +15,7 @@ class AppTest(APITestCase): self.assertEqual(response.status_code, 200) -class ProviderTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class ProviderTest(APIViewTestCases.APIViewTestCase): model = Provider brief_fields = ['circuit_count', 'display', 'id', 'name', 'slug', 'url'] create_data = [ @@ -47,7 +47,7 @@ class ProviderTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTes Provider.objects.bulk_create(providers) -class CircuitTypeTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class CircuitTypeTest(APIViewTestCases.APIViewTestCase): model = CircuitType brief_fields = ['circuit_count', 'display', 'id', 'name', 'slug', 'url'] create_data = ( @@ -79,7 +79,7 @@ class CircuitTypeTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIView CircuitType.objects.bulk_create(circuit_types) -class CircuitTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class CircuitTest(APIViewTestCases.APIViewTestCase): model = Circuit brief_fields = ['cid', 'display', 'id', 'url'] bulk_update_data = { @@ -127,7 +127,7 @@ class CircuitTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTest ] -class CircuitTerminationTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class CircuitTerminationTest(APIViewTestCases.APIViewTestCase): model = CircuitTermination brief_fields = ['_occupied', 'cable', 'circuit', 'display', 'id', 'term_side', 'url'] @@ -180,7 +180,7 @@ class CircuitTerminationTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases. } -class ProviderNetworkTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class ProviderNetworkTest(APIViewTestCases.APIViewTestCase): model = ProviderNetwork brief_fields = ['display', 'id', 'name', 'url'] diff --git a/netbox/dcim/tests/test_api.py b/netbox/dcim/tests/test_api.py index 5402405c5..2c64ad294 100644 --- a/netbox/dcim/tests/test_api.py +++ b/netbox/dcim/tests/test_api.py @@ -57,7 +57,7 @@ class Mixins: self.assertEqual(segment1[2]['name'], peer_obj.name) -class RegionTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class RegionTest(APIViewTestCases.APIViewTestCase): model = Region brief_fields = ['_depth', 'display', 'id', 'name', 'site_count', 'slug', 'url'] create_data = [ @@ -86,7 +86,7 @@ class RegionTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestC Region.objects.create(name='Region 3', slug='region-3') -class SiteGroupTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class SiteGroupTest(APIViewTestCases.APIViewTestCase): model = SiteGroup brief_fields = ['_depth', 'display', 'id', 'name', 'site_count', 'slug', 'url'] create_data = [ @@ -115,7 +115,7 @@ class SiteGroupTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTe SiteGroup.objects.create(name='Site Group 3', slug='site-group-3') -class SiteTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class SiteTest(APIViewTestCases.APIViewTestCase): model = Site brief_fields = ['display', 'id', 'name', 'slug', 'url'] bulk_update_data = { @@ -167,7 +167,7 @@ class SiteTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCas ] -class LocationTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class LocationTest(APIViewTestCases.APIViewTestCase): model = Location brief_fields = ['_depth', 'display', 'id', 'name', 'rack_count', 'slug', 'url'] bulk_update_data = { @@ -214,7 +214,7 @@ class LocationTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTes ] -class RackRoleTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class RackRoleTest(APIViewTestCases.APIViewTestCase): model = RackRole brief_fields = ['display', 'id', 'name', 'rack_count', 'slug', 'url'] create_data = [ @@ -249,7 +249,7 @@ class RackRoleTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTes RackRole.objects.bulk_create(rack_roles) -class RackTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class RackTest(APIViewTestCases.APIViewTestCase): model = Rack brief_fields = ['device_count', 'display', 'id', 'name', 'url'] bulk_update_data = { @@ -337,7 +337,7 @@ class RackTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCas self.assertEqual(response.get('Content-Type'), 'image/svg+xml') -class RackReservationTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class RackReservationTest(APIViewTestCases.APIViewTestCase): model = RackReservation brief_fields = ['display', 'id', 'units', 'url', 'user'] bulk_update_data = { @@ -384,7 +384,7 @@ class RackReservationTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.API ] -class ManufacturerTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class ManufacturerTest(APIViewTestCases.APIViewTestCase): model = Manufacturer brief_fields = ['devicetype_count', 'display', 'id', 'name', 'slug', 'url'] create_data = [ @@ -416,7 +416,7 @@ class ManufacturerTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIVie Manufacturer.objects.bulk_create(manufacturers) -class DeviceTypeTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class DeviceTypeTest(APIViewTestCases.APIViewTestCase): model = DeviceType brief_fields = ['device_count', 'display', 'id', 'manufacturer', 'model', 'slug', 'url'] bulk_update_data = { @@ -458,7 +458,7 @@ class DeviceTypeTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewT ] -class ConsolePortTemplateTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class ConsolePortTemplateTest(APIViewTestCases.APIViewTestCase): model = ConsolePortTemplate brief_fields = ['display', 'id', 'name', 'url'] bulk_update_data = { @@ -495,7 +495,7 @@ class ConsolePortTemplateTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases ] -class ConsoleServerPortTemplateTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class ConsoleServerPortTemplateTest(APIViewTestCases.APIViewTestCase): model = ConsoleServerPortTemplate brief_fields = ['display', 'id', 'name', 'url'] bulk_update_data = { @@ -532,7 +532,7 @@ class ConsoleServerPortTemplateTest(APIViewTestCases.GraphQLTestCase, APIViewTes ] -class PowerPortTemplateTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class PowerPortTemplateTest(APIViewTestCases.APIViewTestCase): model = PowerPortTemplate brief_fields = ['display', 'id', 'name', 'url'] bulk_update_data = { @@ -569,7 +569,7 @@ class PowerPortTemplateTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.A ] -class PowerOutletTemplateTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class PowerOutletTemplateTest(APIViewTestCases.APIViewTestCase): model = PowerOutletTemplate brief_fields = ['display', 'id', 'name', 'url'] bulk_update_data = { @@ -606,7 +606,7 @@ class PowerOutletTemplateTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases ] -class InterfaceTemplateTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class InterfaceTemplateTest(APIViewTestCases.APIViewTestCase): model = InterfaceTemplate brief_fields = ['display', 'id', 'name', 'url'] bulk_update_data = { @@ -646,7 +646,7 @@ class InterfaceTemplateTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.A ] -class FrontPortTemplateTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class FrontPortTemplateTest(APIViewTestCases.APIViewTestCase): model = FrontPortTemplate brief_fields = ['display', 'id', 'name', 'url'] bulk_update_data = { @@ -717,7 +717,7 @@ class FrontPortTemplateTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.A ] -class RearPortTemplateTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class RearPortTemplateTest(APIViewTestCases.APIViewTestCase): model = RearPortTemplate brief_fields = ['display', 'id', 'name', 'url'] bulk_update_data = { @@ -757,7 +757,7 @@ class RearPortTemplateTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.AP ] -class DeviceBayTemplateTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class DeviceBayTemplateTest(APIViewTestCases.APIViewTestCase): model = DeviceBayTemplate brief_fields = ['display', 'id', 'name', 'url'] bulk_update_data = { @@ -797,7 +797,7 @@ class DeviceBayTemplateTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.A ] -class DeviceRoleTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class DeviceRoleTest(APIViewTestCases.APIViewTestCase): model = DeviceRole brief_fields = ['device_count', 'display', 'id', 'name', 'slug', 'url', 'virtualmachine_count'] create_data = [ @@ -832,7 +832,7 @@ class DeviceRoleTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewT DeviceRole.objects.bulk_create(device_roles) -class PlatformTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class PlatformTest(APIViewTestCases.APIViewTestCase): model = Platform brief_fields = ['device_count', 'display', 'id', 'name', 'slug', 'url', 'virtualmachine_count'] create_data = [ @@ -864,7 +864,7 @@ class PlatformTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTes Platform.objects.bulk_create(platforms) -class DeviceTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class DeviceTest(APIViewTestCases.APIViewTestCase): model = Device brief_fields = ['display', 'id', 'name', 'url'] bulk_update_data = { @@ -1005,11 +1005,7 @@ class DeviceTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestC self.assertHttpStatus(response, status.HTTP_400_BAD_REQUEST) -class ConsolePortTest( - Mixins.ComponentTraceMixin, - APIViewTestCases.GraphQLTestCase, - APIViewTestCases.APIViewTestCase -): +class ConsolePortTest(Mixins.ComponentTraceMixin, APIViewTestCases.APIViewTestCase): model = ConsolePort brief_fields = ['_occupied', 'cable', 'device', 'display', 'id', 'name', 'url'] bulk_update_data = { @@ -1048,11 +1044,7 @@ class ConsolePortTest( ] -class ConsoleServerPortTest( - Mixins.ComponentTraceMixin, - APIViewTestCases.GraphQLTestCase, - APIViewTestCases.APIViewTestCase -): +class ConsoleServerPortTest(Mixins.ComponentTraceMixin, APIViewTestCases.APIViewTestCase): model = ConsoleServerPort brief_fields = ['_occupied', 'cable', 'device', 'display', 'id', 'name', 'url'] bulk_update_data = { @@ -1091,11 +1083,7 @@ class ConsoleServerPortTest( ] -class PowerPortTest( - Mixins.ComponentTraceMixin, - APIViewTestCases.GraphQLTestCase, - APIViewTestCases.APIViewTestCase -): +class PowerPortTest(Mixins.ComponentTraceMixin, APIViewTestCases.APIViewTestCase): model = PowerPort brief_fields = ['_occupied', 'cable', 'device', 'display', 'id', 'name', 'url'] bulk_update_data = { @@ -1134,11 +1122,7 @@ class PowerPortTest( ] -class PowerOutletTest( - Mixins.ComponentTraceMixin, - APIViewTestCases.GraphQLTestCase, - APIViewTestCases.APIViewTestCase -): +class PowerOutletTest(Mixins.ComponentTraceMixin, APIViewTestCases.APIViewTestCase): model = PowerOutlet brief_fields = ['_occupied', 'cable', 'device', 'display', 'id', 'name', 'url'] bulk_update_data = { @@ -1177,11 +1161,7 @@ class PowerOutletTest( ] -class InterfaceTest( - Mixins.ComponentTraceMixin, - APIViewTestCases.GraphQLTestCase, - APIViewTestCases.APIViewTestCase -): +class InterfaceTest(Mixins.ComponentTraceMixin, APIViewTestCases.APIViewTestCase): model = Interface brief_fields = ['_occupied', 'cable', 'device', 'display', 'id', 'name', 'url'] bulk_update_data = { @@ -1239,7 +1219,7 @@ class InterfaceTest( ] -class FrontPortTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class FrontPortTest(APIViewTestCases.APIViewTestCase): model = FrontPort brief_fields = ['_occupied', 'cable', 'device', 'display', 'id', 'name', 'url'] bulk_update_data = { @@ -1297,7 +1277,7 @@ class FrontPortTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTe ] -class RearPortTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class RearPortTest(APIViewTestCases.APIViewTestCase): model = RearPort brief_fields = ['_occupied', 'cable', 'device', 'display', 'id', 'name', 'url'] bulk_update_data = { @@ -1339,7 +1319,7 @@ class RearPortTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTes ] -class DeviceBayTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class DeviceBayTest(APIViewTestCases.APIViewTestCase): model = DeviceBay brief_fields = ['device', 'display', 'id', 'name', 'url'] bulk_update_data = { @@ -1402,7 +1382,7 @@ class DeviceBayTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTe ] -class InventoryItemTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class InventoryItemTest(APIViewTestCases.APIViewTestCase): model = InventoryItem brief_fields = ['_depth', 'device', 'display', 'id', 'name', 'url'] bulk_update_data = { @@ -1440,7 +1420,7 @@ class InventoryItemTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIVi ] -class CableTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class CableTest(APIViewTestCases.APIViewTestCase): model = Cable brief_fields = ['display', 'id', 'label', 'url'] bulk_update_data = { @@ -1545,7 +1525,7 @@ class ConnectedDeviceTest(APITestCase): self.assertEqual(response.data['name'], self.device1.name) -class VirtualChassisTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class VirtualChassisTest(APIViewTestCases.APIViewTestCase): model = VirtualChassis brief_fields = ['id', 'master', 'member_count', 'name', 'url'] @@ -1625,7 +1605,7 @@ class VirtualChassisTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIV } -class PowerPanelTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class PowerPanelTest(APIViewTestCases.APIViewTestCase): model = PowerPanel brief_fields = ['display', 'id', 'name', 'powerfeed_count', 'url'] @@ -1674,7 +1654,7 @@ class PowerPanelTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewT } -class PowerFeedTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class PowerFeedTest(APIViewTestCases.APIViewTestCase): model = PowerFeed brief_fields = ['_occupied', 'cable', 'display', 'id', 'name', 'url'] bulk_update_data = { diff --git a/netbox/extras/tests/test_api.py b/netbox/extras/tests/test_api.py index 76f8bfea3..d15b57e43 100644 --- a/netbox/extras/tests/test_api.py +++ b/netbox/extras/tests/test_api.py @@ -31,7 +31,7 @@ class AppTest(APITestCase): self.assertEqual(response.status_code, 200) -class WebhookTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class WebhookTest(APIViewTestCases.APIViewTestCase): model = Webhook brief_fields = ['display', 'id', 'name', 'url'] create_data = [ @@ -85,7 +85,7 @@ class WebhookTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTest webhook.content_types.add(site_ct, rack_ct) -class CustomFieldTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class CustomFieldTest(APIViewTestCases.APIViewTestCase): model = CustomField brief_fields = ['display', 'id', 'name', 'url'] create_data = [ @@ -132,7 +132,7 @@ class CustomFieldTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIView cf.content_types.add(site_ct) -class CustomLinkTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class CustomLinkTest(APIViewTestCases.APIViewTestCase): model = CustomLink brief_fields = ['display', 'id', 'name', 'url'] create_data = [ @@ -186,7 +186,7 @@ class CustomLinkTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewT CustomLink.objects.bulk_create(custom_links) -class ExportTemplateTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class ExportTemplateTest(APIViewTestCases.APIViewTestCase): model = ExportTemplate brief_fields = ['display', 'id', 'name', 'url'] create_data = [ @@ -234,7 +234,7 @@ class ExportTemplateTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIV ExportTemplate.objects.bulk_create(export_templates) -class TagTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class TagTest(APIViewTestCases.APIViewTestCase): model = Tag brief_fields = ['color', 'display', 'id', 'name', 'slug', 'url'] create_data = [ @@ -311,7 +311,7 @@ class ImageAttachmentTest( ImageAttachment.objects.bulk_create(image_attachments) -class JournalEntryTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class JournalEntryTest(APIViewTestCases.APIViewTestCase): model = JournalEntry brief_fields = ['created', 'display', 'id', 'url'] bulk_update_data = { @@ -361,7 +361,7 @@ class JournalEntryTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIVie ] -class ConfigContextTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class ConfigContextTest(APIViewTestCases.APIViewTestCase): model = ConfigContext brief_fields = ['display', 'id', 'name', 'url'] create_data = [ diff --git a/netbox/ipam/tests/test_api.py b/netbox/ipam/tests/test_api.py index 6b86e2d26..38339fa14 100644 --- a/netbox/ipam/tests/test_api.py +++ b/netbox/ipam/tests/test_api.py @@ -20,7 +20,7 @@ class AppTest(APITestCase): self.assertEqual(response.status_code, 200) -class VRFTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class VRFTest(APIViewTestCases.APIViewTestCase): model = VRF brief_fields = ['display', 'id', 'name', 'prefix_count', 'rd', 'url'] create_data = [ @@ -52,7 +52,7 @@ class VRFTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase VRF.objects.bulk_create(vrfs) -class RouteTargetTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class RouteTargetTest(APIViewTestCases.APIViewTestCase): model = RouteTarget brief_fields = ['display', 'id', 'name', 'url'] create_data = [ @@ -81,7 +81,7 @@ class RouteTargetTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIView RouteTarget.objects.bulk_create(route_targets) -class RIRTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class RIRTest(APIViewTestCases.APIViewTestCase): model = RIR brief_fields = ['aggregate_count', 'display', 'id', 'name', 'slug', 'url'] create_data = [ @@ -113,7 +113,7 @@ class RIRTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase RIR.objects.bulk_create(rirs) -class AggregateTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class AggregateTest(APIViewTestCases.APIViewTestCase): model = Aggregate brief_fields = ['display', 'family', 'id', 'prefix', 'url'] bulk_update_data = { @@ -152,7 +152,7 @@ class AggregateTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTe ] -class RoleTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class RoleTest(APIViewTestCases.APIViewTestCase): model = Role brief_fields = ['display', 'id', 'name', 'prefix_count', 'slug', 'url', 'vlan_count'] create_data = [ @@ -184,7 +184,7 @@ class RoleTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCas Role.objects.bulk_create(roles) -class PrefixTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class PrefixTest(APIViewTestCases.APIViewTestCase): model = Prefix brief_fields = ['_depth', 'display', 'family', 'id', 'prefix', 'url'] create_data = [ @@ -358,7 +358,7 @@ class PrefixTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestC self.assertEqual(len(response.data), 8) -class IPAddressTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class IPAddressTest(APIViewTestCases.APIViewTestCase): model = IPAddress brief_fields = ['address', 'display', 'family', 'id', 'url'] create_data = [ @@ -387,7 +387,7 @@ class IPAddressTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTe IPAddress.objects.bulk_create(ip_addresses) -class VLANGroupTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class VLANGroupTest(APIViewTestCases.APIViewTestCase): model = VLANGroup brief_fields = ['display', 'id', 'name', 'slug', 'url', 'vlan_count'] create_data = [ @@ -419,7 +419,7 @@ class VLANGroupTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTe VLANGroup.objects.bulk_create(vlan_groups) -class VLANTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class VLANTest(APIViewTestCases.APIViewTestCase): model = VLAN brief_fields = ['display', 'id', 'name', 'url', 'vid'] bulk_update_data = { @@ -479,7 +479,7 @@ class VLANTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCas self.assertTrue(content['detail'].startswith('Unable to delete object.')) -class ServiceTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class ServiceTest(APIViewTestCases.APIViewTestCase): model = Service brief_fields = ['display', 'id', 'name', 'ports', 'protocol', 'url'] bulk_update_data = { diff --git a/netbox/tenancy/tests/test_api.py b/netbox/tenancy/tests/test_api.py index 1777f204a..5a3c2c1b0 100644 --- a/netbox/tenancy/tests/test_api.py +++ b/netbox/tenancy/tests/test_api.py @@ -14,7 +14,7 @@ class AppTest(APITestCase): self.assertEqual(response.status_code, 200) -class TenantGroupTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class TenantGroupTest(APIViewTestCases.APIViewTestCase): model = TenantGroup brief_fields = ['_depth', 'display', 'id', 'name', 'slug', 'tenant_count', 'url'] bulk_update_data = { @@ -52,7 +52,7 @@ class TenantGroupTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIView ] -class TenantTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class TenantTest(APIViewTestCases.APIViewTestCase): model = Tenant brief_fields = ['display', 'id', 'name', 'slug', 'url'] bulk_update_data = { diff --git a/netbox/users/tests/test_api.py b/netbox/users/tests/test_api.py index adaa3c337..bcfc9cf14 100644 --- a/netbox/users/tests/test_api.py +++ b/netbox/users/tests/test_api.py @@ -17,7 +17,7 @@ class AppTest(APITestCase): self.assertEqual(response.status_code, 200) -class UserTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class UserTest(APIViewTestCases.APIViewTestCase): model = User view_namespace = 'users' brief_fields = ['display', 'id', 'url', 'username'] @@ -48,7 +48,7 @@ class UserTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCas User.objects.bulk_create(users) -class GroupTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class GroupTest(APIViewTestCases.APIViewTestCase): model = Group view_namespace = 'users' brief_fields = ['display', 'id', 'name', 'url'] @@ -75,7 +75,14 @@ class GroupTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCa Group.objects.bulk_create(users) -class TokenTest(APIViewTestCases.APIViewTestCase): +class TokenTest( + # No GraphQL support for Token + APIViewTestCases.GetObjectViewTestCase, + APIViewTestCases.ListObjectsViewTestCase, + APIViewTestCases.CreateObjectViewTestCase, + APIViewTestCases.UpdateObjectViewTestCase, + APIViewTestCases.DeleteObjectViewTestCase +): model = Token brief_fields = ['display', 'id', 'key', 'url', 'write_enabled'] bulk_update_data = { @@ -138,7 +145,14 @@ class TokenTest(APIViewTestCases.APIViewTestCase): self.assertEqual(response.status_code, 403) -class ObjectPermissionTest(APIViewTestCases.APIViewTestCase): +class ObjectPermissionTest( + # No GraphQL support for ObjectPermission + APIViewTestCases.GetObjectViewTestCase, + APIViewTestCases.ListObjectsViewTestCase, + APIViewTestCases.CreateObjectViewTestCase, + APIViewTestCases.UpdateObjectViewTestCase, + APIViewTestCases.DeleteObjectViewTestCase +): model = ObjectPermission brief_fields = ['actions', 'display', 'enabled', 'groups', 'id', 'name', 'object_types', 'url', 'users'] diff --git a/netbox/utilities/testing/api.py b/netbox/utilities/testing/api.py index 89f463cdf..f0c1c92c8 100644 --- a/netbox/utilities/testing/api.py +++ b/netbox/utilities/testing/api.py @@ -520,6 +520,7 @@ class APIViewTestCases: ListObjectsViewTestCase, CreateObjectViewTestCase, UpdateObjectViewTestCase, - DeleteObjectViewTestCase + DeleteObjectViewTestCase, + GraphQLTestCase ): pass diff --git a/netbox/virtualization/tests/test_api.py b/netbox/virtualization/tests/test_api.py index 9157b8780..289ccf843 100644 --- a/netbox/virtualization/tests/test_api.py +++ b/netbox/virtualization/tests/test_api.py @@ -17,7 +17,7 @@ class AppTest(APITestCase): self.assertEqual(response.status_code, 200) -class ClusterTypeTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class ClusterTypeTest(APIViewTestCases.APIViewTestCase): model = ClusterType brief_fields = ['cluster_count', 'display', 'id', 'name', 'slug', 'url'] create_data = [ @@ -49,7 +49,7 @@ class ClusterTypeTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIView ClusterType.objects.bulk_create(cluster_types) -class ClusterGroupTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class ClusterGroupTest(APIViewTestCases.APIViewTestCase): model = ClusterGroup brief_fields = ['cluster_count', 'display', 'id', 'name', 'slug', 'url'] create_data = [ @@ -81,7 +81,7 @@ class ClusterGroupTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIVie ClusterGroup.objects.bulk_create(cluster_Groups) -class ClusterTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class ClusterTest(APIViewTestCases.APIViewTestCase): model = Cluster brief_fields = ['display', 'id', 'name', 'url', 'virtualmachine_count'] bulk_update_data = { @@ -129,7 +129,7 @@ class ClusterTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTest ] -class VirtualMachineTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class VirtualMachineTest(APIViewTestCases.APIViewTestCase): model = VirtualMachine brief_fields = ['display', 'id', 'name', 'url'] bulk_update_data = { @@ -205,7 +205,7 @@ class VirtualMachineTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIV self.assertHttpStatus(response, status.HTTP_400_BAD_REQUEST) -class VMInterfaceTest(APIViewTestCases.GraphQLTestCase, APIViewTestCases.APIViewTestCase): +class VMInterfaceTest(APIViewTestCases.APIViewTestCase): model = VMInterface brief_fields = ['display', 'id', 'name', 'url', 'virtual_machine'] bulk_update_data = {