Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweak tests #46

Merged
merged 2 commits into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
30 changes: 30 additions & 0 deletions netbox_routing/tests/eigrp/test_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from django.urls import reverse
from netaddr.ip import IPAddress
from rest_framework import status

from dcim.models import Interface
from ipam.models import VRF
from utilities.testing import APIViewTestCases, APITestCase, create_test_device

from netbox_routing.models import EIGRPRouter, EIGRPAddressFamily, EIGRPNetwork, EIGRPInterface
from netbox_routing.tests.base import IPAddressFieldMixin

__all__ = (
'EIGRPRouterTestCase',
'EIGRPAddressFamilyTestCase',
'EIGRPNetworkTestCase',
'EIGRPInterfaceTestCase',
)

class EIGRPRouterTestCase(APIViewTestCases):
pass

class EIGRPAddressFamilyTestCase(APIViewTestCases):
pass

class EIGRPNetworkTestCase(APIViewTestCases):
pass

class EIGRPInterfaceTestCase(APIViewTestCases):
pass

32 changes: 32 additions & 0 deletions netbox_routing/tests/eigrp/test_filtersets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import netaddr
from django.test import TestCase

from dcim.models import Device, Interface
from ipam.models import VRF
from utilities.testing import create_test_device

from netbox_routing.filtersets import *
from netbox_routing.models import *

__all__ = (
'EIGRPRouterTestCase',
'EIGRPAddressFamilyTestCase',
'EIGRPNetworkTestCase',
'EIGRPInterfaceTestCase',
)


class EIGRPRouterTestCase(TestCase):
pass


class EIGRPAddressFamilyTestCase(TestCase):
pass


class EIGRPNetworkTestCase(TestCase):
pass


class EIGRPInterfaceTestCase(TestCase):
pass
30 changes: 30 additions & 0 deletions netbox_routing/tests/eigrp/test_forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from django.test import TestCase

from dcim.models import Device, Interface
from utilities.testing import create_test_device

from netbox_routing.forms import *
from netbox_routing.models import *

__all__ = (
'EIGRPRouterTestCase',
'EIGRPAddressFamilyTestCase',
'EIGRPNetworkTestCase',
'EIGRPInterfaceTestCase',
)


class EIGRPRouterTestCase(TestCase):
pass


class EIGRPAddressFamilyTestCase(TestCase):
pass


class EIGRPNetworkTestCase(TestCase):
pass


class EIGRPInterfaceTestCase(TestCase):
pass
29 changes: 29 additions & 0 deletions netbox_routing/tests/eigrp/test_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from django.core.exceptions import ValidationError
from django.test import TestCase

from utilities.testing import create_test_device

from netbox_routing.models import *

__all__ = (
'EIGRPRouterTestCase',
'EIGRPAddressFamilyTestCase',
'EIGRPNetworkTestCase',
'EIGRPInterfaceTestCase',
)


class EIGRPRouterTestCase(TestCase):
pass


class EIGRPAddressFamilyTestCase(TestCase):
pass


class EIGRPNetworkTestCase(TestCase):
pass


class EIGRPInterfaceTestCase(TestCase):
pass
Empty file.
Empty file.
119 changes: 119 additions & 0 deletions netbox_routing/tests/ospf/test_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
from dcim.models import Interface
from utilities.testing import APIViewTestCases, create_test_device

from netbox_routing.models import OSPFInstance, OSPFArea, OSPFInterface
from netbox_routing.tests.base import IPAddressFieldMixin

__all__ = (
'OSPFInstanceTestCase',
'OSPFAreaTestCase',
'OSPFInterfaceTestCase',
)


class OSPFInstanceTestCase(IPAddressFieldMixin, APIViewTestCases.APIViewTestCase):
model = OSPFInstance
view_namespace = 'plugins-api:netbox_routing'
brief_fields = ['device', 'display', 'id', 'name', 'process_id', 'router_id', 'url', ]

user_permissions = ('dcim.view_device', )

bulk_update_data = {
'description': "A test description"
}

@classmethod
def setUpTestData(cls):

device = create_test_device(name='Test Device')

data = (
cls.model(name='Instance 1', device=device, router_id='1.1.1.1', process_id=1),
cls.model(name='Instance 2', device=device, router_id='2.2.2.2', process_id=2),
cls.model(name='Instance 3', device=device, router_id='3.3.3.3', process_id=3),
)
cls.model.objects.bulk_create(data)

cls.create_data = [
{
'name': 'Instance X',
'device': device.pk,
'router_id': '4.4.4.4',
'process_id': 4
},
]


class OSPFAreaTestCase(IPAddressFieldMixin , APIViewTestCases.APIViewTestCase):
model = OSPFArea
view_namespace = 'plugins-api:netbox_routing'
brief_fields = ['area_id', 'display', 'id', 'url', ]

bulk_update_data = {
'description': "A test description"
}

@classmethod
def setUpTestData(cls):

data = (
cls.model(area_id='1'),
cls.model(area_id='2'),
cls.model(area_id='3'),
)
cls.model.objects.bulk_create(data)

cls.create_data = [
{
'area_id': '4',
},
]


class OSPFInterfaceTestCase(IPAddressFieldMixin, APIViewTestCases.APIViewTestCase):
model = OSPFInterface
view_namespace = 'plugins-api:netbox_routing'
brief_fields = ['area', 'display', 'id', 'instance', 'interface', 'passive', 'url', ]

user_permissions = (
'netbox_routing.view_ospfinstance', 'netbox_routing.view_ospfarea', 'dcim.view_device', 'dcim.view_interface',
)

bulk_update_data = {
'description': "A test description"
}

@classmethod
def setUpTestData(cls):

device = create_test_device(name='Test Device')
instance = OSPFInstance.objects.create(name='Instance 1', device=device, router_id='1.1.1.1', process_id=1)
area = OSPFArea.objects.create(area_id='0')

interfaces = (
Interface(device=device, name='Interface 1', type='virtual'),
Interface(device=device, name='Interface 2', type='virtual'),
Interface(device=device, name='Interface 3', type='virtual'),
Interface(device=device, name='Interface 4', type='virtual'),
)
Interface.objects.bulk_create(interfaces)

data = (
cls.model(instance=instance, area=area, interface=interfaces[0], passive=True),
cls.model(instance=instance, area=area, interface=interfaces[1], passive=False),
cls.model(instance=instance, area=area, interface=interfaces[2], ),
)
cls.model.objects.bulk_create(data)

cls.create_data = [
{
'instance': instance.pk,
'area': area.pk,
'interface': interfaces[3].pk,
'passive': True,
'priority': 2,
'authentication': 'message-digest',
'passphrase': 'test-password',
'bfd': True,
},
]
Loading
Loading