Fix E501 errors

This commit is contained in:
Jeremy Stretch 2024-11-21 14:20:31 -05:00
parent 4bc2bf6f2e
commit d39dc6d45c
20 changed files with 251 additions and 68 deletions

View File

@ -239,9 +239,24 @@ class ContactAssignmentTest(APIViewTestCases.APIViewTestCase):
ContactRole.objects.bulk_create(contact_roles) ContactRole.objects.bulk_create(contact_roles)
contact_assignments = ( contact_assignments = (
ContactAssignment(object=sites[0], contact=contacts[0], role=contact_roles[0], priority=ContactPriorityChoices.PRIORITY_PRIMARY), ContactAssignment(
ContactAssignment(object=sites[0], contact=contacts[1], role=contact_roles[1], priority=ContactPriorityChoices.PRIORITY_SECONDARY), object=sites[0],
ContactAssignment(object=sites[0], contact=contacts[2], role=contact_roles[2], priority=ContactPriorityChoices.PRIORITY_TERTIARY), contact=contacts[0],
role=contact_roles[0],
priority=ContactPriorityChoices.PRIORITY_PRIMARY,
),
ContactAssignment(
object=sites[0],
contact=contacts[1],
role=contact_roles[1],
priority=ContactPriorityChoices.PRIORITY_SECONDARY,
),
ContactAssignment(
object=sites[0],
contact=contacts[2],
role=contact_roles[2],
priority=ContactPriorityChoices.PRIORITY_TERTIARY,
),
) )
ContactAssignment.objects.bulk_create(contact_assignments) ContactAssignment.objects.bulk_create(contact_assignments)

View File

@ -286,9 +286,15 @@ class TokenTestCase(TestCase, BaseFilterSetTests):
future_date = make_aware(datetime.datetime(3000, 1, 1)) future_date = make_aware(datetime.datetime(3000, 1, 1))
past_date = make_aware(datetime.datetime(2000, 1, 1)) past_date = make_aware(datetime.datetime(2000, 1, 1))
tokens = ( tokens = (
Token(user=users[0], key=Token.generate_key(), expires=future_date, write_enabled=True, description='foobar1'), Token(
Token(user=users[1], key=Token.generate_key(), expires=future_date, write_enabled=True, description='foobar2'), user=users[0], key=Token.generate_key(), expires=future_date, write_enabled=True, description='foobar1'
Token(user=users[2], key=Token.generate_key(), expires=past_date, write_enabled=False), ),
Token(
user=users[1], key=Token.generate_key(), expires=future_date, write_enabled=True, description='foobar2'
),
Token(
user=users[2], key=Token.generate_key(), expires=past_date, write_enabled=False
),
) )
Token.objects.bulk_create(tokens) Token.objects.bulk_create(tokens)

View File

@ -23,11 +23,16 @@ class UserTestCase(
@classmethod @classmethod
def setUpTestData(cls): def setUpTestData(cls):
users = ( users = (
User(username='username1', first_name='first1', last_name='last1', email='user1@foo.com', password='pass1xxx'), User(
User(username='username2', first_name='first2', last_name='last2', email='user2@foo.com', password='pass2xxx'), username='username1', first_name='first1', last_name='last1', email='user1@foo.com', password='pass1xxx'
User(username='username3', first_name='first3', last_name='last3', email='user3@foo.com', password='pass3xxx'), ),
User(
username='username2', first_name='first2', last_name='last2', email='user2@foo.com', password='pass2xxx'
),
User(
username='username3', first_name='first3', last_name='last3', email='user3@foo.com', password='pass3xxx'
),
) )
User.objects.bulk_create(users) User.objects.bulk_create(users)

View File

@ -26,7 +26,10 @@ class ProxyHTTPConnection(HTTPConnection):
try: try:
from python_socks.sync import Proxy from python_socks.sync import Proxy
except ModuleNotFoundError as e: except ModuleNotFoundError as e:
logger.info("Configuring an HTTP proxy using SOCKS requires the python_socks library. Check that it has been installed.") logger.info(
"Configuring an HTTP proxy using SOCKS requires the python_socks library. Check that it has been "
"installed."
)
raise e raise e
proxy = Proxy.from_url(self._proxy_url, rdns=self.use_rdns) proxy = Proxy.from_url(self._proxy_url, rdns=self.use_rdns)

View File

@ -443,7 +443,10 @@ class APIViewTestCases:
# Compile list of fields to include # Compile list of fields to include
fields_string = '' fields_string = ''
file_fields = (strawberry_django.fields.types.DjangoFileType, strawberry_django.fields.types.DjangoImageType) file_fields = (
strawberry_django.fields.types.DjangoFileType,
strawberry_django.fields.types.DjangoImageType,
)
for field in type_class.__strawberry_definition__.fields: for field in type_class.__strawberry_definition__.fields:
if ( if (
field.type in file_fields or ( field.type in file_fields or (

View File

@ -427,9 +427,46 @@ class DynamicFilterLookupExpressionTest(TestCase):
Rack.objects.bulk_create(racks) Rack.objects.bulk_create(racks)
devices = ( devices = (
Device(name='Device 1', device_type=device_types[0], role=roles[0], platform=platforms[0], serial='ABC', asset_tag='1001', site=sites[0], rack=racks[0], position=1, face=DeviceFaceChoices.FACE_FRONT, status=DeviceStatusChoices.STATUS_ACTIVE, local_context_data={"foo": 123}), Device(
Device(name='Device 2', device_type=device_types[1], role=roles[1], platform=platforms[1], serial='DEF', asset_tag='1002', site=sites[1], rack=racks[1], position=2, face=DeviceFaceChoices.FACE_FRONT, status=DeviceStatusChoices.STATUS_STAGED), name='Device 1',
Device(name='Device 3', device_type=device_types[2], role=roles[2], platform=platforms[2], serial='GHI', asset_tag='1003', site=sites[2], rack=racks[2], position=3, face=DeviceFaceChoices.FACE_REAR, status=DeviceStatusChoices.STATUS_FAILED), device_type=device_types[0],
role=roles[0],
platform=platforms[0],
serial='ABC',
asset_tag='1001',
site=sites[0],
rack=racks[0],
position=1,
face=DeviceFaceChoices.FACE_FRONT,
status=DeviceStatusChoices.STATUS_ACTIVE,
local_context_data={'foo': 123},
),
Device(
name='Device 2',
device_type=device_types[1],
role=roles[1],
platform=platforms[1],
serial='DEF',
asset_tag='1002',
site=sites[1],
rack=racks[1],
position=2,
face=DeviceFaceChoices.FACE_FRONT,
status=DeviceStatusChoices.STATUS_STAGED,
),
Device(
name='Device 3',
device_type=device_types[2],
role=roles[2],
platform=platforms[2],
serial='GHI',
asset_tag='1003',
site=sites[2],
rack=racks[2],
position=3,
face=DeviceFaceChoices.FACE_REAR,
status=DeviceStatusChoices.STATUS_FAILED,
),
) )
Device.objects.bulk_create(devices) Device.objects.bulk_create(devices)

View File

@ -75,9 +75,9 @@ class ClusterSerializer(NetBoxModelSerializer):
class Meta: class Meta:
model = Cluster model = Cluster
fields = [ fields = [
'id', 'url', 'display_url', 'display', 'name', 'type', 'group', 'status', 'tenant', 'scope_type', 'scope_id', 'scope', 'id', 'url', 'display_url', 'display', 'name', 'type', 'group', 'status', 'tenant', 'scope_type',
'description', 'comments', 'tags', 'custom_fields', 'created', 'last_updated', 'device_count', 'scope_id', 'scope', 'description', 'comments', 'tags', 'custom_fields', 'created', 'last_updated',
'virtualmachine_count', 'allocated_vcpus', 'allocated_memory', 'allocated_disk' 'device_count', 'virtualmachine_count', 'allocated_vcpus', 'allocated_memory', 'allocated_disk'
] ]
brief_fields = ('id', 'url', 'display', 'name', 'description', 'virtualmachine_count') brief_fields = ('id', 'url', 'display', 'name', 'description', 'virtualmachine_count')

View File

@ -49,8 +49,8 @@ class VirtualMachineSerializer(NetBoxModelSerializer):
class Meta: class Meta:
model = VirtualMachine model = VirtualMachine
fields = [ fields = [
'id', 'url', 'display_url', 'display', 'name', 'status', 'site', 'cluster', 'device', 'serial', 'role', 'tenant', 'id', 'url', 'display_url', 'display', 'name', 'status', 'site', 'cluster', 'device', 'serial', 'role',
'platform', 'primary_ip', 'primary_ip4', 'primary_ip6', 'vcpus', 'memory', 'disk', 'description', 'tenant', 'platform', 'primary_ip', 'primary_ip4', 'primary_ip6', 'vcpus', 'memory', 'disk', 'description',
'comments', 'config_template', 'local_context_data', 'tags', 'custom_fields', 'created', 'last_updated', 'comments', 'config_template', 'local_context_data', 'tags', 'custom_fields', 'created', 'last_updated',
'interface_count', 'virtual_disk_count', 'interface_count', 'virtual_disk_count',
] ]
@ -62,8 +62,8 @@ class VirtualMachineWithConfigContextSerializer(VirtualMachineSerializer):
class Meta(VirtualMachineSerializer.Meta): class Meta(VirtualMachineSerializer.Meta):
fields = [ fields = [
'id', 'url', 'display_url', 'display', 'name', 'status', 'site', 'cluster', 'device', 'serial', 'role', 'tenant', 'id', 'url', 'display_url', 'display', 'name', 'status', 'site', 'cluster', 'device', 'serial', 'role',
'platform', 'primary_ip', 'primary_ip4', 'primary_ip6', 'vcpus', 'memory', 'disk', 'description', 'tenant', 'platform', 'primary_ip', 'primary_ip4', 'primary_ip6', 'vcpus', 'memory', 'disk', 'description',
'comments', 'config_template', 'local_context_data', 'tags', 'custom_fields', 'config_context', 'created', 'comments', 'config_template', 'local_context_data', 'tags', 'custom_fields', 'config_context', 'created',
'last_updated', 'interface_count', 'virtual_disk_count', 'last_updated', 'interface_count', 'virtual_disk_count',
] ]

View File

@ -73,7 +73,9 @@ class ClusterImportForm(ScopedImportForm, NetBoxModelImportForm):
class Meta: class Meta:
model = Cluster model = Cluster
fields = ('name', 'type', 'group', 'status', 'scope_type', 'scope_id', 'tenant', 'description', 'comments', 'tags') fields = (
'name', 'type', 'group', 'status', 'scope_type', 'scope_id', 'tenant', 'description', 'comments', 'tags',
)
labels = { labels = {
'scope_id': _('Scope ID'), 'scope_id': _('Scope ID'),
} }

View File

@ -100,7 +100,7 @@ class ClusterTable(TenancyColumnsMixin, ContactsColumnMixin, NetBoxTable):
class Meta(NetBoxTable.Meta): class Meta(NetBoxTable.Meta):
model = Cluster model = Cluster
fields = ( fields = (
'pk', 'id', 'name', 'type', 'group', 'status', 'tenant', 'tenant_group', 'scope', 'scope_type', 'description', 'pk', 'id', 'name', 'type', 'group', 'status', 'tenant', 'tenant_group', 'scope', 'scope_type',
'comments', 'device_count', 'vm_count', 'contacts', 'tags', 'created', 'last_updated', 'description', 'comments', 'device_count', 'vm_count', 'contacts', 'tags', 'created', 'last_updated',
) )
default_columns = ('pk', 'name', 'type', 'group', 'status', 'tenant', 'site', 'device_count', 'vm_count') default_columns = ('pk', 'name', 'type', 'group', 'status', 'tenant', 'site', 'device_count', 'vm_count')

View File

@ -109,9 +109,24 @@ class ClusterTest(APIViewTestCases.APIViewTestCase):
ClusterGroup.objects.bulk_create(cluster_groups) ClusterGroup.objects.bulk_create(cluster_groups)
clusters = ( clusters = (
Cluster(name='Cluster 1', type=cluster_types[0], group=cluster_groups[0], status=ClusterStatusChoices.STATUS_PLANNED), Cluster(
Cluster(name='Cluster 2', type=cluster_types[0], group=cluster_groups[0], status=ClusterStatusChoices.STATUS_PLANNED), name='Cluster 1',
Cluster(name='Cluster 3', type=cluster_types[0], group=cluster_groups[0], status=ClusterStatusChoices.STATUS_PLANNED), type=cluster_types[0],
group=cluster_groups[0],
status=ClusterStatusChoices.STATUS_PLANNED,
),
Cluster(
name='Cluster 2',
type=cluster_types[0],
group=cluster_groups[0],
status=ClusterStatusChoices.STATUS_PLANNED,
),
Cluster(
name='Cluster 3',
type=cluster_types[0],
group=cluster_groups[0],
status=ClusterStatusChoices.STATUS_PLANNED,
),
) )
for cluster in clusters: for cluster in clusters:
cluster.save() cluster.save()
@ -169,9 +184,25 @@ class VirtualMachineTest(APIViewTestCases.APIViewTestCase):
device2 = create_test_device('device2', site=sites[1], cluster=clusters[1]) device2 = create_test_device('device2', site=sites[1], cluster=clusters[1])
virtual_machines = ( virtual_machines = (
VirtualMachine(name='Virtual Machine 1', site=sites[0], cluster=clusters[0], device=device1, local_context_data={'A': 1}), VirtualMachine(
VirtualMachine(name='Virtual Machine 2', site=sites[0], cluster=clusters[0], local_context_data={'B': 2}), name='Virtual Machine 1',
VirtualMachine(name='Virtual Machine 3', site=sites[0], cluster=clusters[0], local_context_data={'C': 3}), site=sites[0],
cluster=clusters[0],
device=device1,
local_context_data={'A': 1},
),
VirtualMachine(
name='Virtual Machine 2',
site=sites[0],
cluster=clusters[0],
local_context_data={'B': 2
}),
VirtualMachine(
name='Virtual Machine 3',
site=sites[0],
cluster=clusters[0],
local_context_data={'C': 3}
),
) )
VirtualMachine.objects.bulk_create(virtual_machines) VirtualMachine.objects.bulk_create(virtual_machines)

View File

@ -117,9 +117,27 @@ class ClusterTestCase(ViewTestCases.PrimaryObjectViewTestCase):
ClusterType.objects.bulk_create(clustertypes) ClusterType.objects.bulk_create(clustertypes)
clusters = ( clusters = (
Cluster(name='Cluster 1', group=clustergroups[0], type=clustertypes[0], status=ClusterStatusChoices.STATUS_ACTIVE, scope=sites[0]), Cluster(
Cluster(name='Cluster 2', group=clustergroups[0], type=clustertypes[0], status=ClusterStatusChoices.STATUS_ACTIVE, scope=sites[0]), name='Cluster 1',
Cluster(name='Cluster 3', group=clustergroups[0], type=clustertypes[0], status=ClusterStatusChoices.STATUS_ACTIVE, scope=sites[0]), group=clustergroups[0],
type=clustertypes[0],
status=ClusterStatusChoices.STATUS_ACTIVE,
scope=sites[0],
),
Cluster(
name='Cluster 2',
group=clustergroups[0],
type=clustertypes[0],
status=ClusterStatusChoices.STATUS_ACTIVE,
scope=sites[0],
),
Cluster(
name='Cluster 3',
group=clustergroups[0],
type=clustertypes[0],
status=ClusterStatusChoices.STATUS_ACTIVE,
scope=sites[0],
),
) )
for cluster in clusters: for cluster in clusters:
cluster.save() cluster.save()
@ -214,9 +232,30 @@ class VirtualMachineTestCase(ViewTestCases.PrimaryObjectViewTestCase):
) )
virtual_machines = ( virtual_machines = (
VirtualMachine(name='Virtual Machine 1', site=sites[0], cluster=clusters[0], device=devices[0], role=roles[0], platform=platforms[0]), VirtualMachine(
VirtualMachine(name='Virtual Machine 2', site=sites[0], cluster=clusters[0], device=devices[0], role=roles[0], platform=platforms[0]), name='Virtual Machine 1',
VirtualMachine(name='Virtual Machine 3', site=sites[0], cluster=clusters[0], device=devices[0], role=roles[0], platform=platforms[0]), site=sites[0],
cluster=clusters[0],
device=devices[0],
role=roles[0],
platform=platforms[0],
),
VirtualMachine(
name='Virtual Machine 2',
site=sites[0],
cluster=clusters[0],
device=devices[0],
role=roles[0],
platform=platforms[0],
),
VirtualMachine(
name='Virtual Machine 3',
site=sites[0],
cluster=clusters[0],
device=devices[0],
role=roles[0],
platform=platforms[0],
),
) )
VirtualMachine.objects.bulk_create(virtual_machines) VirtualMachine.objects.bulk_create(virtual_machines)

View File

@ -177,7 +177,11 @@ class ClusterView(generic.ObjectView):
queryset = Cluster.objects.all() queryset = Cluster.objects.all()
def get_extra_context(self, request, instance): def get_extra_context(self, request, instance):
return instance.virtual_machines.aggregate(vcpus_sum=Sum('vcpus'), memory_sum=Sum('memory'), disk_sum=Sum('disk')) return instance.virtual_machines.aggregate(
vcpus_sum=Sum('vcpus'),
memory_sum=Sum('memory'),
disk_sum=Sum('disk')
)
@register_model_view(Cluster, 'virtualmachines', path='virtual-machines') @register_model_view(Cluster, 'virtualmachines', path='virtual-machines')

View File

@ -74,7 +74,8 @@ class IPSecProposalSerializer(NetBoxModelSerializer):
model = IPSecProposal model = IPSecProposal
fields = ( fields = (
'id', 'url', 'display_url', 'display', 'name', 'description', 'encryption_algorithm', 'id', 'url', 'display_url', 'display', 'name', 'description', 'encryption_algorithm',
'authentication_algorithm', 'sa_lifetime_seconds', 'sa_lifetime_data', 'comments', 'tags', 'custom_fields', 'created', 'last_updated', 'authentication_algorithm', 'sa_lifetime_seconds', 'sa_lifetime_data', 'comments', 'tags', 'custom_fields',
'created', 'last_updated',
) )
brief_fields = ('id', 'url', 'display', 'name', 'description') brief_fields = ('id', 'url', 'display', 'name', 'description')

View File

@ -8,9 +8,11 @@ class Migration(migrations.Migration):
operations = [ operations = [
# Rename vpn_l2vpn constraints # Rename vpn_l2vpn constraints
migrations.RunSQL( migrations.RunSQL((
'ALTER TABLE vpn_l2vpn RENAME CONSTRAINT ipam_l2vpn_tenant_id_bb2564a6_fk_tenancy_tenant_id TO vpn_l2vpn_tenant_id_57ec8f92_fk_tenancy_tenant_id' 'ALTER TABLE vpn_l2vpn '
), 'RENAME CONSTRAINT ipam_l2vpn_tenant_id_bb2564a6_fk_tenancy_tenant_id '
'TO vpn_l2vpn_tenant_id_57ec8f92_fk_tenancy_tenant_id'
)),
# Rename ipam_l2vpn_* sequences # Rename ipam_l2vpn_* sequences
migrations.RunSQL('ALTER TABLE ipam_l2vpn_export_targets_id_seq RENAME TO vpn_l2vpn_export_targets_id_seq'), migrations.RunSQL('ALTER TABLE ipam_l2vpn_export_targets_id_seq RENAME TO vpn_l2vpn_export_targets_id_seq'),
migrations.RunSQL('ALTER TABLE ipam_l2vpn_id_seq RENAME TO vpn_l2vpn_id_seq'), migrations.RunSQL('ALTER TABLE ipam_l2vpn_id_seq RENAME TO vpn_l2vpn_id_seq'),
@ -26,22 +28,29 @@ class Migration(migrations.Migration):
migrations.RunSQL('ALTER INDEX IF EXISTS ipam_l2vpn_slug_24008406_uniq RENAME TO vpn_l2vpn_slug_76b5a174_uniq'), migrations.RunSQL('ALTER INDEX IF EXISTS ipam_l2vpn_slug_24008406_uniq RENAME TO vpn_l2vpn_slug_76b5a174_uniq'),
migrations.RunSQL('ALTER INDEX IF EXISTS ipam_l2vpn_slug_key RENAME TO vpn_l2vpn_slug_key'), migrations.RunSQL('ALTER INDEX IF EXISTS ipam_l2vpn_slug_key RENAME TO vpn_l2vpn_slug_key'),
# Rename vpn_l2vpntermination constraints # Rename vpn_l2vpntermination constraints
migrations.RunSQL( migrations.RunSQL((
'ALTER TABLE vpn_l2vpntermination RENAME CONSTRAINT ipam_l2vpntermination_assigned_object_id_check TO vpn_l2vpntermination_assigned_object_id_check' 'ALTER TABLE vpn_l2vpntermination '
), 'RENAME CONSTRAINT ipam_l2vpntermination_assigned_object_id_check '
migrations.RunSQL( 'TO vpn_l2vpntermination_assigned_object_id_check'
'ALTER TABLE vpn_l2vpntermination RENAME CONSTRAINT ipam_l2vpnterminatio_assigned_object_type_3923c124_fk_django_co TO vpn_l2vpntermination_assigned_object_type_id_f063b865_fk_django_co' )),
), migrations.RunSQL((
migrations.RunSQL( 'ALTER TABLE vpn_l2vpntermination '
'ALTER TABLE vpn_l2vpntermination RENAME CONSTRAINT ipam_l2vpntermination_l2vpn_id_9e570aa1_fk_ipam_l2vpn_id TO vpn_l2vpntermination_l2vpn_id_f5367bbe_fk_vpn_l2vpn_id' 'RENAME CONSTRAINT ipam_l2vpnterminatio_assigned_object_type_3923c124_fk_django_co '
), 'TO vpn_l2vpntermination_assigned_object_type_id_f063b865_fk_django_co'
)),
migrations.RunSQL((
'ALTER TABLE vpn_l2vpntermination '
'RENAME CONSTRAINT ipam_l2vpntermination_l2vpn_id_9e570aa1_fk_ipam_l2vpn_id '
'TO vpn_l2vpntermination_l2vpn_id_f5367bbe_fk_vpn_l2vpn_id'
)),
# Rename ipam_l2vpn_termination_* sequences # Rename ipam_l2vpn_termination_* sequences
migrations.RunSQL('ALTER TABLE ipam_l2vpntermination_id_seq RENAME TO vpn_l2vpntermination_id_seq'), migrations.RunSQL('ALTER TABLE ipam_l2vpntermination_id_seq RENAME TO vpn_l2vpntermination_id_seq'),
# Rename ipam_l2vpn_* indexes # Rename ipam_l2vpn_* indexes
migrations.RunSQL('ALTER INDEX ipam_l2vpntermination_pkey RENAME TO vpn_l2vpntermination_pkey'), migrations.RunSQL('ALTER INDEX ipam_l2vpntermination_pkey RENAME TO vpn_l2vpntermination_pkey'),
migrations.RunSQL( migrations.RunSQL((
'ALTER INDEX ipam_l2vpntermination_assigned_object_type_id_3923c124 RENAME TO vpn_l2vpntermination_assigned_object_type_id_f063b865' 'ALTER INDEX ipam_l2vpntermination_assigned_object_type_id_3923c124 '
), 'RENAME TO vpn_l2vpntermination_assigned_object_type_id_f063b865'
)),
migrations.RunSQL( migrations.RunSQL(
'ALTER INDEX ipam_l2vpntermination_l2vpn_id_9e570aa1 RENAME TO vpn_l2vpntermination_l2vpn_id_f5367bbe' 'ALTER INDEX ipam_l2vpntermination_l2vpn_id_9e570aa1 RENAME TO vpn_l2vpntermination_l2vpn_id_f5367bbe'
), ),

View File

@ -52,9 +52,9 @@ class WirelessLANSerializer(NetBoxModelSerializer):
class Meta: class Meta:
model = WirelessLAN model = WirelessLAN
fields = [ fields = [
'id', 'url', 'display_url', 'display', 'ssid', 'description', 'group', 'status', 'vlan', 'scope_type', 'scope_id', 'scope', 'id', 'url', 'display_url', 'display', 'ssid', 'description', 'group', 'status', 'vlan', 'scope_type',
'tenant', 'auth_type', 'auth_cipher', 'auth_psk', 'description', 'comments', 'tags', 'custom_fields', 'scope_id', 'scope', 'tenant', 'auth_type', 'auth_cipher', 'auth_psk', 'description', 'comments', 'tags',
'created', 'last_updated', 'custom_fields', 'created', 'last_updated',
] ]
brief_fields = ('id', 'url', 'display', 'ssid', 'description') brief_fields = ('id', 'url', 'display', 'ssid', 'description')

View File

@ -76,8 +76,8 @@ class WirelessLANImportForm(ScopedImportForm, NetBoxModelImportForm):
class Meta: class Meta:
model = WirelessLAN model = WirelessLAN
fields = ( fields = (
'ssid', 'group', 'status', 'vlan', 'tenant', 'auth_type', 'auth_cipher', 'auth_psk', 'scope_type', 'scope_id', 'ssid', 'group', 'status', 'vlan', 'tenant', 'auth_type', 'auth_cipher', 'auth_psk', 'scope_type',
'description', 'comments', 'tags', 'scope_id', 'description', 'comments', 'tags',
) )
labels = { labels = {
'scope_id': _('Scope ID'), 'scope_id': _('Scope ID'),

View File

@ -72,7 +72,8 @@ class WirelessLANTable(TenancyColumnsMixin, NetBoxTable):
model = WirelessLAN model = WirelessLAN
fields = ( fields = (
'pk', 'ssid', 'group', 'status', 'tenant', 'tenant_group', 'vlan', 'interface_count', 'auth_type', 'pk', 'ssid', 'group', 'status', 'tenant', 'tenant_group', 'vlan', 'interface_count', 'auth_type',
'auth_cipher', 'auth_psk', 'scope', 'scope_type', 'description', 'comments', 'tags', 'created', 'last_updated', 'auth_cipher', 'auth_psk', 'scope', 'scope_type', 'description', 'comments', 'tags', 'created',
'last_updated',
) )
default_columns = ('pk', 'ssid', 'group', 'status', 'description', 'vlan', 'auth_type', 'interface_count') default_columns = ('pk', 'ssid', 'group', 'status', 'description', 'vlan', 'auth_type', 'interface_count')

View File

@ -27,8 +27,18 @@ class WirelessLANGroupTestCase(TestCase, ChangeLoggedFilterSetTests):
group.save() group.save()
groups = ( groups = (
WirelessLANGroup(name='Wireless LAN Group 1A', slug='wireless-lan-group-1a', parent=parent_groups[0], description='foobar1'), WirelessLANGroup(
WirelessLANGroup(name='Wireless LAN Group 1B', slug='wireless-lan-group-1b', parent=parent_groups[0], description='foobar2'), name='Wireless LAN Group 1A',
slug='wireless-lan-group-1a',
parent=parent_groups[0],
description='foobar1',
),
WirelessLANGroup(
name='Wireless LAN Group 1B',
slug='wireless-lan-group-1b',
parent=parent_groups[0],
description='foobar2',
),
WirelessLANGroup(name='Wireless LAN Group 2A', slug='wireless-lan-group-2a', parent=parent_groups[1]), WirelessLANGroup(name='Wireless LAN Group 2A', slug='wireless-lan-group-2a', parent=parent_groups[1]),
WirelessLANGroup(name='Wireless LAN Group 2B', slug='wireless-lan-group-2b', parent=parent_groups[1]), WirelessLANGroup(name='Wireless LAN Group 2B', slug='wireless-lan-group-2b', parent=parent_groups[1]),
WirelessLANGroup(name='Wireless LAN Group 3A', slug='wireless-lan-group-3a', parent=parent_groups[2]), WirelessLANGroup(name='Wireless LAN Group 3A', slug='wireless-lan-group-3a', parent=parent_groups[2]),

View File

@ -113,9 +113,20 @@ class WirelessLANTestCase(ViewTestCases.PrimaryObjectViewTestCase):
cls.csv_data = ( cls.csv_data = (
"group,ssid,status,tenant,scope_type,scope_id", "group,ssid,status,tenant,scope_type,scope_id",
f"Wireless LAN Group 2,WLAN4,{WirelessLANStatusChoices.STATUS_ACTIVE},{tenants[0].name},,", "Wireless LAN Group 2,WLAN4,{status},{tenant},,".format(
f"Wireless LAN Group 2,WLAN5,{WirelessLANStatusChoices.STATUS_DISABLED},{tenants[1].name},dcim.site,{sites[0].pk}", status=WirelessLANStatusChoices.STATUS_ACTIVE,
f"Wireless LAN Group 2,WLAN6,{WirelessLANStatusChoices.STATUS_RESERVED},{tenants[2].name},dcim.site,{sites[1].pk}", tenant=tenants[0].name
),
"Wireless LAN Group 2,WLAN5,{status},{tenant},dcim.site,{site}".format(
status=WirelessLANStatusChoices.STATUS_DISABLED,
tenant=tenants[1].name,
site=sites[0].pk
),
"Wireless LAN Group 2,WLAN6,{status},{tenant},dcim.site,{site}".format(
status=WirelessLANStatusChoices.STATUS_RESERVED,
tenant=tenants[2].name,
site=sites[1].pk
),
) )
cls.csv_update_data = ( cls.csv_update_data = (
@ -157,11 +168,17 @@ class WirelessLinkTestCase(ViewTestCases.PrimaryObjectViewTestCase):
] ]
Interface.objects.bulk_create(interfaces) Interface.objects.bulk_create(interfaces)
wirelesslink1 = WirelessLink(interface_a=interfaces[0], interface_b=interfaces[1], ssid='LINK1', tenant=tenants[0]) wirelesslink1 = WirelessLink(
interface_a=interfaces[0], interface_b=interfaces[1], ssid='LINK1', tenant=tenants[0]
)
wirelesslink1.save() wirelesslink1.save()
wirelesslink2 = WirelessLink(interface_a=interfaces[2], interface_b=interfaces[3], ssid='LINK2', tenant=tenants[0]) wirelesslink2 = WirelessLink(
interface_a=interfaces[2], interface_b=interfaces[3], ssid='LINK2', tenant=tenants[0]
)
wirelesslink2.save() wirelesslink2.save()
wirelesslink3 = WirelessLink(interface_a=interfaces[4], interface_b=interfaces[5], ssid='LINK3', tenant=tenants[0]) wirelesslink3 = WirelessLink(
interface_a=interfaces[4], interface_b=interfaces[5], ssid='LINK3', tenant=tenants[0]
)
wirelesslink3.save() wirelesslink3.save()
tags = create_tags('Alpha', 'Bravo', 'Charlie') tags = create_tags('Alpha', 'Bravo', 'Charlie')