mirror of
https://github.com/netbox-community/netbox.git
synced 2026-04-25 18:29:20 +02:00
#8272: Cleanup & add filter for bridge_id
This commit is contained in:
@@ -1142,11 +1142,36 @@ class InterfaceTemplateTestCase(TestCase, ChangeLoggedFilterSetTests):
|
||||
)
|
||||
DeviceType.objects.bulk_create(device_types)
|
||||
|
||||
InterfaceTemplate.objects.bulk_create((
|
||||
InterfaceTemplate(device_type=device_types[0], name='Interface 1', type=InterfaceTypeChoices.TYPE_1GE_FIXED, enabled=True, mgmt_only=True, poe_mode=InterfacePoEModeChoices.MODE_PD, poe_type=InterfacePoETypeChoices.TYPE_1_8023AF),
|
||||
InterfaceTemplate(device_type=device_types[1], name='Interface 2', type=InterfaceTypeChoices.TYPE_1GE_GBIC, enabled=False, mgmt_only=False, poe_mode=InterfacePoEModeChoices.MODE_PSE, poe_type=InterfacePoETypeChoices.TYPE_2_8023AT),
|
||||
InterfaceTemplate(device_type=device_types[2], name='Interface 3', type=InterfaceTypeChoices.TYPE_1GE_SFP, mgmt_only=False),
|
||||
))
|
||||
interface_templates = (
|
||||
InterfaceTemplate(
|
||||
device_type=device_types[0],
|
||||
name='Interface 1',
|
||||
type=InterfaceTypeChoices.TYPE_1GE_FIXED,
|
||||
enabled=True,
|
||||
mgmt_only=True,
|
||||
poe_mode=InterfacePoEModeChoices.MODE_PD,
|
||||
poe_type=InterfacePoETypeChoices.TYPE_1_8023AF
|
||||
),
|
||||
InterfaceTemplate(
|
||||
device_type=device_types[1],
|
||||
name='Interface 2',
|
||||
type=InterfaceTypeChoices.TYPE_1GE_GBIC,
|
||||
enabled=False,
|
||||
mgmt_only=False,
|
||||
poe_mode=InterfacePoEModeChoices.MODE_PSE,
|
||||
poe_type=InterfacePoETypeChoices.TYPE_2_8023AT
|
||||
),
|
||||
InterfaceTemplate(
|
||||
device_type=device_types[2],
|
||||
name='Interface 3',
|
||||
type=InterfaceTypeChoices.TYPE_1GE_SFP,
|
||||
mgmt_only=False
|
||||
),
|
||||
)
|
||||
InterfaceTemplate.objects.bulk_create(interface_templates)
|
||||
interface_templates[0].bridge = interface_templates[1]
|
||||
interface_templates[1].bridge = interface_templates[0]
|
||||
InterfaceTemplate.objects.bulk_update(interface_templates, ['bridge'])
|
||||
|
||||
def test_name(self):
|
||||
params = {'name': ['Interface 1', 'Interface 2']}
|
||||
@@ -1173,6 +1198,10 @@ class InterfaceTemplateTestCase(TestCase, ChangeLoggedFilterSetTests):
|
||||
params = {'mgmt_only': 'false'}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||
|
||||
def test_bridge(self):
|
||||
params = {'bridge_id': [InterfaceTemplate.objects.filter(bridge__isnull=False).first().bridge_id]}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)
|
||||
|
||||
def test_poe_mode(self):
|
||||
params = {'poe_mode': [InterfacePoEModeChoices.MODE_PD, InterfacePoEModeChoices.MODE_PSE]}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||
|
||||
Reference in New Issue
Block a user