# Path: netdevice/models.py
# class router(models.Model):
#     """
#     Router - A network device that moves packets around.
#     routing_id:         An IP address the router will use as identification and routing decisions.    [203.0.113.1]
#     hostname:           The (DNS) hostname of the router, domain included.                            [Router1.isp]
#     ibgp:               Boolean value to build an iBGP mesh with every router in the database.        [True]
#     network_os:         The network operating system and subsequent template this router is tied too.
#     service_ssh:        Boolean value to enable SSHv2 on the router.                                  [True]
#     service_netconf:    Boolean value to enable NETCONF on the router.                                [True]
#     local_aut_num:      Local autonomous system number for the router.
#     Example string: Router1
#     """
# 
#     routing_id         = models.GenericIPAddressField(unpack_ipv4=True)
#     hostname           = models.CharField(max_length=255)
#     ibgp               = models.BooleanField()
#     network_os         = models.ForeignKey('network_os', on_delete=models.CASCADE)
#     service_ssh        = models.BooleanField(default=True)
#     service_netconf    = models.BooleanField(default=True)
#     local_aut_num      = models.ForeignKey('bgp.aut_num', on_delete=models.CASCADE)
# 
#     def ldp_exists(self):
#         return self.interface_set.filter(logical_interface__ldp=True).exists()
# 
#     def __str__(self):
#         return self.hostname
# 
# class network_os(models.Model):
#     """
#     Network Operating Systems - The software platform which runs networking focused hardware.
#     name:                  The name of the NOS, and the template file to build the configuration with.    [junos]
#     mgmt_interface_name:   Name prefix for platform management interfaces.                                [fxp]
#     Example string: junos
#                     ios-12
#                     ios-xe
#     """
# 
#     name                = models.CharField(max_length=255)
#     mgmt_interface_name = models.CharField(max_length=255, null=True, blank=True)
# 
#     def __str__(self):
#         return self.name
# 
# Path: netdevice/tests.py
# def create_router(network_os_name):
#     nos               = network_os.objects.get(name=network_os_name)
#     local_aut_num     = aut_num.objects.create(asn=65000, name='Test ASN')
#     test_router       = router.objects.create(routing_id='1.1.1.1',
#                                               hostname='test-router',
#                                               ibgp=True,
#                                               network_os=nos,
#                                               local_aut_num=local_aut_num,
#                                              )
# 
#     return test_router
# 
# Path: bgp/models.py
# class aut_num(models.Model):
#     """
#     Autonomous System Number - Used in BGPv4 to represent an
#                                administrative domain where internet prefixes
#                                are exchanged.
# 
#     asn:        The actual autonomous system number of someone we neighbor.
#                 [65000]
#     name:       A specific company or personal name for the peer.
#                 [123 ISP Inc.]
#     contact:    An email address to go along with the name.
#                 [john.smith@example.com]
# 
#     Example string: 65000: 123 ISP Inc. (john.smith@example.com)
#     """
# 
#     asn        = models.BigIntegerField(unique=False)
#     name       = models.CharField(max_length=255)
#     contact    = models.EmailField(blank=True)
#     vrf        = models.ForeignKey(
#                                    'netdevice.vrf',
#                                    on_delete=models.CASCADE,
#                                    null=True,
#                                    blank=True
#                                   )
#     class Meta:
#         unique_together = ("asn", "vrf")
# 
#     def __str__(self):
#         return str(self.asn) + ": " + self.name + " (" + self.contact + ")"


from django.test import TestCase
from django.urls import reverse
from django.contrib.auth.models import User
from netdevice.models import router, network_os
from netdevice.tests import create_router
from bgp.models import aut_num
        )

    def test_index_view_with_many_routers(self):
        """
        Create a bunch of routers, then verify the view.
        """
        nos              = network_os.objects.create(name='many-test-os')
        local_aut_num    = aut_num.objects.create(asn=65000, name='test asn')
        new_router_list  = []

        for i in range(0, 5):
            router.objects.create(
                hostname   = 'test-router-' + str(i),
                routing_id = '1.1.1.' + str(i),
                ibgp       = True,
                network_os = nos,
                local_aut_num=local_aut_num,
            )
            new_router_list.append('<router: test-router-' + str(i) + '>')

        response = self.client.get(reverse('op_webgui:router_list'))

        self.assertQuerysetEqual(
            response.context['router_list'], new_router_list
        )

    def test_router_with_no_intefaces(self):
        """
        Show no results if there are no interfaces.
        """

# Path: netdevice/models.py
# class router(models.Model):
#     """
#     Router - A network device that moves packets around.
#     routing_id:         An IP address the router will use as identification and routing decisions.    [203.0.113.1]
#     hostname:           The (DNS) hostname of the router, domain included.                            [Router1.isp]
#     ibgp:               Boolean value to build an iBGP mesh with every router in the database.        [True]
#     network_os:         The network operating system and subsequent template this router is tied too.
#     service_ssh:        Boolean value to enable SSHv2 on the router.                                  [True]
#     service_netconf:    Boolean value to enable NETCONF on the router.                                [True]
#     local_aut_num:      Local autonomous system number for the router.
#     Example string: Router1
#     """
# 
#     routing_id         = models.GenericIPAddressField(unpack_ipv4=True)
#     hostname           = models.CharField(max_length=255)
#     ibgp               = models.BooleanField()
#     network_os         = models.ForeignKey('network_os', on_delete=models.CASCADE)
#     service_ssh        = models.BooleanField(default=True)
#     service_netconf    = models.BooleanField(default=True)
#     local_aut_num      = models.ForeignKey('bgp.aut_num', on_delete=models.CASCADE)
# 
#     def ldp_exists(self):
#         return self.interface_set.filter(logical_interface__ldp=True).exists()
# 
#     def __str__(self):
#         return self.hostname
# 
# class network_os(models.Model):
#     """
#     Network Operating Systems - The software platform which runs networking focused hardware.
#     name:                  The name of the NOS, and the template file to build the configuration with.    [junos]
#     mgmt_interface_name:   Name prefix for platform management interfaces.                                [fxp]
#     Example string: junos
#                     ios-12
#                     ios-xe
#     """
# 
#     name                = models.CharField(max_length=255)
#     mgmt_interface_name = models.CharField(max_length=255, null=True, blank=True)
# 
#     def __str__(self):
#         return self.name
# 
# Path: netdevice/tests.py
# def create_router(network_os_name):
#     nos               = network_os.objects.get(name=network_os_name)
#     local_aut_num     = aut_num.objects.create(asn=65000, name='Test ASN')
#     test_router       = router.objects.create(routing_id='1.1.1.1',
#                                               hostname='test-router',
#                                               ibgp=True,
#                                               network_os=nos,
#                                               local_aut_num=local_aut_num,
#                                              )
# 
#     return test_router
# 
# Path: bgp/models.py
# class aut_num(models.Model):
#     """
#     Autonomous System Number - Used in BGPv4 to represent an
#                                administrative domain where internet prefixes
#                                are exchanged.
# 
#     asn:        The actual autonomous system number of someone we neighbor.
#                 [65000]
#     name:       A specific company or personal name for the peer.
#                 [123 ISP Inc.]
#     contact:    An email address to go along with the name.
#                 [john.smith@example.com]
# 
#     Example string: 65000: 123 ISP Inc. (john.smith@example.com)
#     """
# 
#     asn        = models.BigIntegerField(unique=False)
#     name       = models.CharField(max_length=255)
#     contact    = models.EmailField(blank=True)
#     vrf        = models.ForeignKey(
#                                    'netdevice.vrf',
#                                    on_delete=models.CASCADE,
#                                    null=True,
#                                    blank=True
#                                   )
#     class Meta:
#         unique_together = ("asn", "vrf")
# 
#     def __str__(self):
#         return str(self.asn) + ": " + self.name + " (" + self.contact + ")"


# Path: op_webgui/tests.py
from django.test import TestCase
from django.urls import reverse
from django.contrib.auth.models import User
from netdevice.models import router, network_os
from netdevice.tests import create_router
from bgp.models import aut_num

        )

    def test_index_view_with_many_routers(self):
        """
        Create a bunch of routers, then verify the view.
        """
        nos              = network_os.objects.create(name='many-test-os')
        local_aut_num    = aut_num.objects.create(asn=65000, name='test asn')
        new_router_list  = []

        for i in range(0, 5):
            router.objects.create(
                hostname   = 'test-router-' + str(i),
                routing_id = '1.1.1.' + str(i),
                ibgp       = True,
                network_os = nos,
                local_aut_num=local_aut_num,
            )
            new_router_list.append('<router: test-router-' + str(i) + '>')

        response = self.client.get(reverse('op_webgui:router_list'))

        self.assertQuerysetEqual(
            response.context['router_list'], new_router_list
        )

    def test_router_with_no_intefaces(self):
        """
        Show no results if there are no interfaces.
        """

        one_router       = create_router('junos')