# 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
# 
# def create_interface(test_router):
#     test_interface          = interface.objects.create(router=test_router,
#                                                        name='ge-0/0/0',
#                                                        description="A test description.",
#                                                        mtu=9000,
#                                                        dot1q=True,
#                                                       )
# 
#     test_logical_interface  = logical_interface.objects.create(interface=test_interface,
#                                                                name='10',
#                                                                description="A logical test description.",
#                                                                mtu=4170,
#                                                                vlan=10,
#                                                                physical_interface=False,
#                                                                ldp=True,
#                                                                inet_dhcp_client=False,
#                                                                inet6_dhcp_client=False,
#                                                               )
# 
#     return test_logical_interface
# 
# 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 + ")"
# 
# class neighbor(models.Model):
#     """
#     BGP Neighbor - Peering sesssions with our neighbors over BGP.
# 
#     router:          Router that the peer session is tied to.
#     aut_num:         ASN that the peer session is tied to.
#     peer_ip:         IP Address of BGP neighbor.
#                      [203.0.113.1]
#     soft_inbound:    Boolean value for if soft-reconfiguration inbound is
#                      enabled on the peer session.
#                      [True]
# 
#     Example string: PeeringBuddy - Router1 203.0.113.1
#     """
# 
#     router        = models.ForeignKey(
#                                       'netdevice.router',
#                                       on_delete=models.CASCADE
#                                      )
#     vrf           = models.ForeignKey(
#                                       'netdevice.vrf',
#                                       on_delete=models.CASCADE,
#                                       null=True,
#                                       blank=True
#                                      )
#     aut_num       = models.ForeignKey('aut_num', on_delete=models.CASCADE)
#     peer_ip       = models.GenericIPAddressField(unpack_ipv4=True)
#     soft_inbound  = models.BooleanField(default=True)
# 
#     def __str__(self):
#         asn_router = self.aut_num.name + " - " + self.router.hostname + " "
#         return asn_router + self.peer_ip


from django.test import TestCase
from django.urls import reverse
from django.contrib.auth.models import User
from netdevice.tests import create_router, create_interface
from bgp.models import aut_num, neighbor
        neighbor_count   = 100

        for i in range(1, neighbor_count):
            create_neighbor(test_router, test_asn, '1.1.' + str(i) + '.1')
            create_neighbor(
                            test_router,
                            test_asn,
                            '2001:db8:' +  str(i) + '::1'
                           )

        url = reverse(
                      'netdevice:router_config',
                      kwargs={'router_id': test_router.id},
                     )

        response = self.client.get(url)

        self.assertEqual(response.status_code, 200)

        for i in range(1, neighbor_count):
            v4_text = 'neighbor 1.1.' + str(i) + '.1 remote-as 65001'
            v6_text = 'neighbor 2001:db8:' +  str(i) + '::1 remote-as 65001'
            self.assertContains(response, v4_text)
            self.assertContains(response, v6_text)

    def test_config_view_with_multiple_junos_neighbor(self):
        """
        Create a test IOS router, with 100 ipv4 and ipv6 neighbors
        then check the config view.
        """

# 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
# 
# def create_interface(test_router):
#     test_interface          = interface.objects.create(router=test_router,
#                                                        name='ge-0/0/0',
#                                                        description="A test description.",
#                                                        mtu=9000,
#                                                        dot1q=True,
#                                                       )
# 
#     test_logical_interface  = logical_interface.objects.create(interface=test_interface,
#                                                                name='10',
#                                                                description="A logical test description.",
#                                                                mtu=4170,
#                                                                vlan=10,
#                                                                physical_interface=False,
#                                                                ldp=True,
#                                                                inet_dhcp_client=False,
#                                                                inet6_dhcp_client=False,
#                                                               )
# 
#     return test_logical_interface
# 
# 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 + ")"
# 
# class neighbor(models.Model):
#     """
#     BGP Neighbor - Peering sesssions with our neighbors over BGP.
# 
#     router:          Router that the peer session is tied to.
#     aut_num:         ASN that the peer session is tied to.
#     peer_ip:         IP Address of BGP neighbor.
#                      [203.0.113.1]
#     soft_inbound:    Boolean value for if soft-reconfiguration inbound is
#                      enabled on the peer session.
#                      [True]
# 
#     Example string: PeeringBuddy - Router1 203.0.113.1
#     """
# 
#     router        = models.ForeignKey(
#                                       'netdevice.router',
#                                       on_delete=models.CASCADE
#                                      )
#     vrf           = models.ForeignKey(
#                                       'netdevice.vrf',
#                                       on_delete=models.CASCADE,
#                                       null=True,
#                                       blank=True
#                                      )
#     aut_num       = models.ForeignKey('aut_num', on_delete=models.CASCADE)
#     peer_ip       = models.GenericIPAddressField(unpack_ipv4=True)
#     soft_inbound  = models.BooleanField(default=True)
# 
#     def __str__(self):
#         asn_router = self.aut_num.name + " - " + self.router.hostname + " "
#         return asn_router + self.peer_ip


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

        neighbor_count   = 100

        for i in range(1, neighbor_count):
            create_neighbor(test_router, test_asn, '1.1.' + str(i) + '.1')
            create_neighbor(
                            test_router,
                            test_asn,
                            '2001:db8:' +  str(i) + '::1'
                           )

        url = reverse(
                      'netdevice:router_config',
                      kwargs={'router_id': test_router.id},
                     )

        response = self.client.get(url)

        self.assertEqual(response.status_code, 200)

        for i in range(1, neighbor_count):
            v4_text = 'neighbor 1.1.' + str(i) + '.1 remote-as 65001'
            v6_text = 'neighbor 2001:db8:' +  str(i) + '::1 remote-as 65001'
            self.assertContains(response, v4_text)
            self.assertContains(response, v6_text)

    def test_config_view_with_multiple_junos_neighbor(self):
        """
        Create a test IOS router, with 100 ipv4 and ipv6 neighbors
        then check the config view.
        """

        test_router      = create_router('junos')