mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-31 12:56:24 -06:00
11279 fix tests
This commit is contained in:
parent
39438a239a
commit
23a22e7f1c
@ -76,10 +76,6 @@ class ChangeLogViewTest(ModelViewTestCase):
|
|||||||
self.assertEqual(oc.postchange_data['custom_fields']['cf2'], form_data['cf_cf2'])
|
self.assertEqual(oc.postchange_data['custom_fields']['cf2'], form_data['cf_cf2'])
|
||||||
self.assertEqual(oc.postchange_data['tags'], ['Tag 1', 'Tag 2'])
|
self.assertEqual(oc.postchange_data['tags'], ['Tag 1', 'Tag 2'])
|
||||||
|
|
||||||
# Check that private attributes were included in raw data but not display data
|
|
||||||
self.assertIn('_name', oc.postchange_data)
|
|
||||||
self.assertNotIn('_name', oc.postchange_data_clean)
|
|
||||||
|
|
||||||
def test_update_object(self):
|
def test_update_object(self):
|
||||||
site = Site(name='Site 1', slug='site-1')
|
site = Site(name='Site 1', slug='site-1')
|
||||||
site.save()
|
site.save()
|
||||||
@ -117,12 +113,6 @@ class ChangeLogViewTest(ModelViewTestCase):
|
|||||||
self.assertEqual(oc.postchange_data['custom_fields']['cf2'], form_data['cf_cf2'])
|
self.assertEqual(oc.postchange_data['custom_fields']['cf2'], form_data['cf_cf2'])
|
||||||
self.assertEqual(oc.postchange_data['tags'], ['Tag 3'])
|
self.assertEqual(oc.postchange_data['tags'], ['Tag 3'])
|
||||||
|
|
||||||
# Check that private attributes were included in raw data but not display data
|
|
||||||
self.assertIn('_name', oc.prechange_data)
|
|
||||||
self.assertNotIn('_name', oc.prechange_data_clean)
|
|
||||||
self.assertIn('_name', oc.postchange_data)
|
|
||||||
self.assertNotIn('_name', oc.postchange_data_clean)
|
|
||||||
|
|
||||||
def test_delete_object(self):
|
def test_delete_object(self):
|
||||||
site = Site(
|
site = Site(
|
||||||
name='Site 1',
|
name='Site 1',
|
||||||
@ -153,10 +143,6 @@ class ChangeLogViewTest(ModelViewTestCase):
|
|||||||
self.assertEqual(oc.prechange_data['tags'], ['Tag 1', 'Tag 2'])
|
self.assertEqual(oc.prechange_data['tags'], ['Tag 1', 'Tag 2'])
|
||||||
self.assertEqual(oc.postchange_data, None)
|
self.assertEqual(oc.postchange_data, None)
|
||||||
|
|
||||||
# Check that private attributes were included in raw data but not display data
|
|
||||||
self.assertIn('_name', oc.prechange_data)
|
|
||||||
self.assertNotIn('_name', oc.prechange_data_clean)
|
|
||||||
|
|
||||||
def test_bulk_update_objects(self):
|
def test_bulk_update_objects(self):
|
||||||
sites = (
|
sites = (
|
||||||
Site(name='Site 1', slug='site-1', status=SiteStatusChoices.STATUS_ACTIVE),
|
Site(name='Site 1', slug='site-1', status=SiteStatusChoices.STATUS_ACTIVE),
|
||||||
@ -353,10 +339,6 @@ class ChangeLogAPITest(APITestCase):
|
|||||||
self.assertEqual(oc.postchange_data['custom_fields'], data['custom_fields'])
|
self.assertEqual(oc.postchange_data['custom_fields'], data['custom_fields'])
|
||||||
self.assertEqual(oc.postchange_data['tags'], ['Tag 1', 'Tag 2'])
|
self.assertEqual(oc.postchange_data['tags'], ['Tag 1', 'Tag 2'])
|
||||||
|
|
||||||
# Check that private attributes were included in raw data but not display data
|
|
||||||
self.assertIn('_name', oc.postchange_data)
|
|
||||||
self.assertNotIn('_name', oc.postchange_data_clean)
|
|
||||||
|
|
||||||
def test_update_object(self):
|
def test_update_object(self):
|
||||||
site = Site(name='Site 1', slug='site-1')
|
site = Site(name='Site 1', slug='site-1')
|
||||||
site.save()
|
site.save()
|
||||||
@ -389,12 +371,6 @@ class ChangeLogAPITest(APITestCase):
|
|||||||
self.assertEqual(oc.postchange_data['custom_fields'], data['custom_fields'])
|
self.assertEqual(oc.postchange_data['custom_fields'], data['custom_fields'])
|
||||||
self.assertEqual(oc.postchange_data['tags'], ['Tag 3'])
|
self.assertEqual(oc.postchange_data['tags'], ['Tag 3'])
|
||||||
|
|
||||||
# Check that private attributes were included in raw data but not display data
|
|
||||||
self.assertIn('_name', oc.prechange_data)
|
|
||||||
self.assertNotIn('_name', oc.prechange_data_clean)
|
|
||||||
self.assertIn('_name', oc.postchange_data)
|
|
||||||
self.assertNotIn('_name', oc.postchange_data_clean)
|
|
||||||
|
|
||||||
def test_delete_object(self):
|
def test_delete_object(self):
|
||||||
site = Site(
|
site = Site(
|
||||||
name='Site 1',
|
name='Site 1',
|
||||||
@ -423,10 +399,6 @@ class ChangeLogAPITest(APITestCase):
|
|||||||
self.assertEqual(oc.prechange_data['tags'], ['Tag 1', 'Tag 2'])
|
self.assertEqual(oc.prechange_data['tags'], ['Tag 1', 'Tag 2'])
|
||||||
self.assertEqual(oc.postchange_data, None)
|
self.assertEqual(oc.postchange_data, None)
|
||||||
|
|
||||||
# Check that private attributes were included in raw data but not display data
|
|
||||||
self.assertIn('_name', oc.prechange_data)
|
|
||||||
self.assertNotIn('_name', oc.prechange_data_clean)
|
|
||||||
|
|
||||||
def test_bulk_create_objects(self):
|
def test_bulk_create_objects(self):
|
||||||
data = (
|
data = (
|
||||||
{
|
{
|
||||||
|
@ -76,7 +76,6 @@ class ComponentType(
|
|||||||
"""
|
"""
|
||||||
Base type for device/VM components
|
Base type for device/VM components
|
||||||
"""
|
"""
|
||||||
_name: str
|
|
||||||
device: Annotated["DeviceType", strawberry.lazy('dcim.graphql.types')]
|
device: Annotated["DeviceType", strawberry.lazy('dcim.graphql.types')]
|
||||||
|
|
||||||
|
|
||||||
@ -93,7 +92,6 @@ class ComponentTemplateType(
|
|||||||
"""
|
"""
|
||||||
Base type for device/VM components
|
Base type for device/VM components
|
||||||
"""
|
"""
|
||||||
_name: str
|
|
||||||
device_type: Annotated["DeviceTypeType", strawberry.lazy('dcim.graphql.types')]
|
device_type: Annotated["DeviceTypeType", strawberry.lazy('dcim.graphql.types')]
|
||||||
|
|
||||||
|
|
||||||
@ -181,7 +179,7 @@ class ConsolePortType(ModularComponentType, CabledObjectMixin, PathEndpointMixin
|
|||||||
filters=ConsolePortTemplateFilter
|
filters=ConsolePortTemplateFilter
|
||||||
)
|
)
|
||||||
class ConsolePortTemplateType(ModularComponentTemplateType):
|
class ConsolePortTemplateType(ModularComponentTemplateType):
|
||||||
_name: str
|
pass
|
||||||
|
|
||||||
|
|
||||||
@strawberry_django.type(
|
@strawberry_django.type(
|
||||||
@ -199,7 +197,7 @@ class ConsoleServerPortType(ModularComponentType, CabledObjectMixin, PathEndpoin
|
|||||||
filters=ConsoleServerPortTemplateFilter
|
filters=ConsoleServerPortTemplateFilter
|
||||||
)
|
)
|
||||||
class ConsoleServerPortTemplateType(ModularComponentTemplateType):
|
class ConsoleServerPortTemplateType(ModularComponentTemplateType):
|
||||||
_name: str
|
pass
|
||||||
|
|
||||||
|
|
||||||
@strawberry_django.type(
|
@strawberry_django.type(
|
||||||
@ -208,7 +206,6 @@ class ConsoleServerPortTemplateType(ModularComponentTemplateType):
|
|||||||
filters=DeviceFilter
|
filters=DeviceFilter
|
||||||
)
|
)
|
||||||
class DeviceType(ConfigContextMixin, ImageAttachmentsMixin, ContactsMixin, NetBoxObjectType):
|
class DeviceType(ConfigContextMixin, ImageAttachmentsMixin, ContactsMixin, NetBoxObjectType):
|
||||||
_name: str
|
|
||||||
console_port_count: BigInt
|
console_port_count: BigInt
|
||||||
console_server_port_count: BigInt
|
console_server_port_count: BigInt
|
||||||
power_port_count: BigInt
|
power_port_count: BigInt
|
||||||
@ -273,7 +270,7 @@ class DeviceBayType(ComponentType):
|
|||||||
filters=DeviceBayTemplateFilter
|
filters=DeviceBayTemplateFilter
|
||||||
)
|
)
|
||||||
class DeviceBayTemplateType(ComponentTemplateType):
|
class DeviceBayTemplateType(ComponentTemplateType):
|
||||||
_name: str
|
pass
|
||||||
|
|
||||||
|
|
||||||
@strawberry_django.type(
|
@strawberry_django.type(
|
||||||
@ -282,7 +279,6 @@ class DeviceBayTemplateType(ComponentTemplateType):
|
|||||||
filters=InventoryItemTemplateFilter
|
filters=InventoryItemTemplateFilter
|
||||||
)
|
)
|
||||||
class InventoryItemTemplateType(ComponentTemplateType):
|
class InventoryItemTemplateType(ComponentTemplateType):
|
||||||
_name: str
|
|
||||||
role: Annotated["InventoryItemRoleType", strawberry.lazy('dcim.graphql.types')] | None
|
role: Annotated["InventoryItemRoleType", strawberry.lazy('dcim.graphql.types')] | None
|
||||||
manufacturer: Annotated["ManufacturerType", strawberry.lazy('dcim.graphql.types')]
|
manufacturer: Annotated["ManufacturerType", strawberry.lazy('dcim.graphql.types')]
|
||||||
|
|
||||||
@ -366,7 +362,6 @@ class FrontPortType(ModularComponentType, CabledObjectMixin):
|
|||||||
filters=FrontPortTemplateFilter
|
filters=FrontPortTemplateFilter
|
||||||
)
|
)
|
||||||
class FrontPortTemplateType(ModularComponentTemplateType):
|
class FrontPortTemplateType(ModularComponentTemplateType):
|
||||||
_name: str
|
|
||||||
color: str
|
color: str
|
||||||
rear_port: Annotated["RearPortTemplateType", strawberry.lazy('dcim.graphql.types')]
|
rear_port: Annotated["RearPortTemplateType", strawberry.lazy('dcim.graphql.types')]
|
||||||
|
|
||||||
@ -377,6 +372,7 @@ class FrontPortTemplateType(ModularComponentTemplateType):
|
|||||||
filters=InterfaceFilter
|
filters=InterfaceFilter
|
||||||
)
|
)
|
||||||
class InterfaceType(IPAddressesMixin, ModularComponentType, CabledObjectMixin, PathEndpointMixin):
|
class InterfaceType(IPAddressesMixin, ModularComponentType, CabledObjectMixin, PathEndpointMixin):
|
||||||
|
_name: str
|
||||||
mac_address: str | None
|
mac_address: str | None
|
||||||
wwn: str | None
|
wwn: str | None
|
||||||
parent: Annotated["InterfaceType", strawberry.lazy('dcim.graphql.types')] | None
|
parent: Annotated["InterfaceType", strawberry.lazy('dcim.graphql.types')] | None
|
||||||
@ -527,7 +523,7 @@ class ModuleBayType(ModularComponentType):
|
|||||||
filters=ModuleBayTemplateFilter
|
filters=ModuleBayTemplateFilter
|
||||||
)
|
)
|
||||||
class ModuleBayTemplateType(ModularComponentTemplateType):
|
class ModuleBayTemplateType(ModularComponentTemplateType):
|
||||||
_name: str
|
pass
|
||||||
|
|
||||||
|
|
||||||
@strawberry_django.type(
|
@strawberry_django.type(
|
||||||
@ -588,7 +584,6 @@ class PowerOutletType(ModularComponentType, CabledObjectMixin, PathEndpointMixin
|
|||||||
filters=PowerOutletTemplateFilter
|
filters=PowerOutletTemplateFilter
|
||||||
)
|
)
|
||||||
class PowerOutletTemplateType(ModularComponentTemplateType):
|
class PowerOutletTemplateType(ModularComponentTemplateType):
|
||||||
_name: str
|
|
||||||
power_port: Annotated["PowerPortTemplateType", strawberry.lazy('dcim.graphql.types')] | None
|
power_port: Annotated["PowerPortTemplateType", strawberry.lazy('dcim.graphql.types')] | None
|
||||||
|
|
||||||
|
|
||||||
@ -620,8 +615,6 @@ class PowerPortType(ModularComponentType, CabledObjectMixin, PathEndpointMixin):
|
|||||||
filters=PowerPortTemplateFilter
|
filters=PowerPortTemplateFilter
|
||||||
)
|
)
|
||||||
class PowerPortTemplateType(ModularComponentTemplateType):
|
class PowerPortTemplateType(ModularComponentTemplateType):
|
||||||
_name: str
|
|
||||||
|
|
||||||
poweroutlet_templates: List[Annotated["PowerOutletTemplateType", strawberry.lazy('dcim.graphql.types')]]
|
poweroutlet_templates: List[Annotated["PowerOutletTemplateType", strawberry.lazy('dcim.graphql.types')]]
|
||||||
|
|
||||||
|
|
||||||
@ -640,7 +633,6 @@ class RackTypeType(NetBoxObjectType):
|
|||||||
filters=RackFilter
|
filters=RackFilter
|
||||||
)
|
)
|
||||||
class RackType(VLANGroupsMixin, ImageAttachmentsMixin, ContactsMixin, NetBoxObjectType):
|
class RackType(VLANGroupsMixin, ImageAttachmentsMixin, ContactsMixin, NetBoxObjectType):
|
||||||
_name: str
|
|
||||||
site: Annotated["SiteType", strawberry.lazy('dcim.graphql.types')]
|
site: Annotated["SiteType", strawberry.lazy('dcim.graphql.types')]
|
||||||
location: Annotated["LocationType", strawberry.lazy('dcim.graphql.types')] | None
|
location: Annotated["LocationType", strawberry.lazy('dcim.graphql.types')] | None
|
||||||
tenant: Annotated["TenantType", strawberry.lazy('tenancy.graphql.types')] | None
|
tenant: Annotated["TenantType", strawberry.lazy('tenancy.graphql.types')] | None
|
||||||
@ -693,7 +685,6 @@ class RearPortType(ModularComponentType, CabledObjectMixin):
|
|||||||
filters=RearPortTemplateFilter
|
filters=RearPortTemplateFilter
|
||||||
)
|
)
|
||||||
class RearPortTemplateType(ModularComponentTemplateType):
|
class RearPortTemplateType(ModularComponentTemplateType):
|
||||||
_name: str
|
|
||||||
color: str
|
color: str
|
||||||
|
|
||||||
frontport_templates: List[Annotated["FrontPortTemplateType", strawberry.lazy('dcim.graphql.types')]]
|
frontport_templates: List[Annotated["FrontPortTemplateType", strawberry.lazy('dcim.graphql.types')]]
|
||||||
@ -729,7 +720,6 @@ class RegionType(VLANGroupsMixin, ContactsMixin, OrganizationalObjectType):
|
|||||||
filters=SiteFilter
|
filters=SiteFilter
|
||||||
)
|
)
|
||||||
class SiteType(VLANGroupsMixin, ImageAttachmentsMixin, ContactsMixin, NetBoxObjectType):
|
class SiteType(VLANGroupsMixin, ImageAttachmentsMixin, ContactsMixin, NetBoxObjectType):
|
||||||
_name: str
|
|
||||||
time_zone: str | None
|
time_zone: str | None
|
||||||
region: Annotated["RegionType", strawberry.lazy('dcim.graphql.types')] | None
|
region: Annotated["RegionType", strawberry.lazy('dcim.graphql.types')] | None
|
||||||
group: Annotated["SiteGroupType", strawberry.lazy('dcim.graphql.types')] | None
|
group: Annotated["SiteGroupType", strawberry.lazy('dcim.graphql.types')] | None
|
||||||
|
@ -688,7 +688,7 @@ class RackElevationListView(generic.ObjectListView):
|
|||||||
sort = request.GET.get('sort', 'name')
|
sort = request.GET.get('sort', 'name')
|
||||||
if sort not in ORDERING_CHOICES:
|
if sort not in ORDERING_CHOICES:
|
||||||
sort = 'name'
|
sort = 'name'
|
||||||
sort_field = sort.replace("name", "_name") # Use natural ordering
|
sort_field = sort # Use natural ordering
|
||||||
racks = racks.order_by(sort_field)
|
racks = racks.order_by(sort_field)
|
||||||
|
|
||||||
# Pagination
|
# Pagination
|
||||||
@ -731,8 +731,8 @@ class RackView(GetRelatedModelsMixin, generic.ObjectView):
|
|||||||
peer_racks = peer_racks.filter(location=instance.location)
|
peer_racks = peer_racks.filter(location=instance.location)
|
||||||
else:
|
else:
|
||||||
peer_racks = peer_racks.filter(location__isnull=True)
|
peer_racks = peer_racks.filter(location__isnull=True)
|
||||||
next_rack = peer_racks.filter(_name__gt=instance._name).first()
|
next_rack = peer_racks.filter(name__gt=instance.name).first()
|
||||||
prev_rack = peer_racks.filter(_name__lt=instance._name).reverse().first()
|
prev_rack = peer_racks.filter(name__lt=instance.name).reverse().first()
|
||||||
|
|
||||||
# Determine any additional parameters to pass when embedding the rack elevations
|
# Determine any additional parameters to pass when embedding the rack elevations
|
||||||
svg_extra = '&'.join([
|
svg_extra = '&'.join([
|
||||||
|
@ -77,7 +77,6 @@ class ClusterTypeType(OrganizationalObjectType):
|
|||||||
filters=VirtualMachineFilter
|
filters=VirtualMachineFilter
|
||||||
)
|
)
|
||||||
class VirtualMachineType(ConfigContextMixin, ContactsMixin, NetBoxObjectType):
|
class VirtualMachineType(ConfigContextMixin, ContactsMixin, NetBoxObjectType):
|
||||||
_name: str
|
|
||||||
interface_count: BigInt
|
interface_count: BigInt
|
||||||
virtual_disk_count: BigInt
|
virtual_disk_count: BigInt
|
||||||
interface_count: BigInt
|
interface_count: BigInt
|
||||||
|
Loading…
Reference in New Issue
Block a user