15106 add tests

This commit is contained in:
Arthur 2024-06-12 12:58:00 -07:00
parent 75e6b4467e
commit 1165fe4560
3 changed files with 20 additions and 0 deletions

View File

@ -113,6 +113,8 @@ class WirelessLinkTest(APIViewTestCases.APIViewTestCase):
brief_fields = ['description', 'display', 'id', 'ssid', 'url'] brief_fields = ['description', 'display', 'id', 'ssid', 'url']
bulk_update_data = { bulk_update_data = {
'status': 'planned', 'status': 'planned',
'length': 100,
'length_unit': 'm',
} }
@classmethod @classmethod

View File

@ -260,6 +260,8 @@ class WirelessLinkTestCase(TestCase, ChangeLoggedFilterSetTests):
auth_cipher=WirelessAuthCipherChoices.CIPHER_AUTO, auth_cipher=WirelessAuthCipherChoices.CIPHER_AUTO,
auth_psk='PSK1', auth_psk='PSK1',
tenant=tenants[0], tenant=tenants[0],
length=10,
length_unit=WirelessLinkLengthUnitChoices.UNIT_FOOT,
description='foobar1' description='foobar1'
).save() ).save()
WirelessLink( WirelessLink(
@ -271,6 +273,8 @@ class WirelessLinkTestCase(TestCase, ChangeLoggedFilterSetTests):
auth_cipher=WirelessAuthCipherChoices.CIPHER_TKIP, auth_cipher=WirelessAuthCipherChoices.CIPHER_TKIP,
auth_psk='PSK2', auth_psk='PSK2',
tenant=tenants[1], tenant=tenants[1],
length=20,
length_unit=WirelessLinkLengthUnitChoices.UNIT_METER,
description='foobar2' description='foobar2'
).save() ).save()
WirelessLink( WirelessLink(
@ -281,6 +285,8 @@ class WirelessLinkTestCase(TestCase, ChangeLoggedFilterSetTests):
auth_type=WirelessAuthTypeChoices.TYPE_WPA_PERSONAL, auth_type=WirelessAuthTypeChoices.TYPE_WPA_PERSONAL,
auth_cipher=WirelessAuthCipherChoices.CIPHER_AES, auth_cipher=WirelessAuthCipherChoices.CIPHER_AES,
auth_psk='PSK3', auth_psk='PSK3',
length=30,
length_unit=WirelessLinkLengthUnitChoices.UNIT_METER,
tenant=tenants[2], tenant=tenants[2],
).save() ).save()
WirelessLink( WirelessLink(
@ -313,6 +319,14 @@ class WirelessLinkTestCase(TestCase, ChangeLoggedFilterSetTests):
params = {'auth_psk': ['PSK1', 'PSK2']} params = {'auth_psk': ['PSK1', 'PSK2']}
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
def test_length(self):
params = {'length': [10, 20]}
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
def test_length_unit(self):
params = {'length_unit': WirelessLinkLengthUnitChoices.UNIT_FOOT}
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)
def test_description(self): def test_description(self):
params = {'description': ['foobar1', 'foobar2']} params = {'description': ['foobar1', 'foobar2']}
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)

View File

@ -160,6 +160,8 @@ class WirelessLinkTestCase(ViewTestCases.PrimaryObjectViewTestCase):
'interface_a': interfaces[6].pk, 'interface_a': interfaces[6].pk,
'interface_b': interfaces[7].pk, 'interface_b': interfaces[7].pk,
'status': LinkStatusChoices.STATUS_PLANNED, 'status': LinkStatusChoices.STATUS_PLANNED,
'length': 100,
'length_unit': WirelessLinkLengthUnitChoices.UNIT_FOOT,
'tenant': tenants[1].pk, 'tenant': tenants[1].pk,
'tags': [t.pk for t in tags], 'tags': [t.pk for t in tags],
} }
@ -180,4 +182,6 @@ class WirelessLinkTestCase(ViewTestCases.PrimaryObjectViewTestCase):
cls.bulk_edit_data = { cls.bulk_edit_data = {
'status': LinkStatusChoices.STATUS_PLANNED, 'status': LinkStatusChoices.STATUS_PLANNED,
'length': 50,
'length_unit': WirelessLinkLengthUnitChoices.UNIT_METER,
} }