def test_add_route_a_lot(self):
     subnet = fake_network_cache_model.new_subnet()
     route1 = fake_network_cache_model.new_route()
     route2 = fake_network_cache_model.new_route({'cidr': '1.1.1.1/24'})
     for i in xrange(10):
         subnet.add_route(route2)
     self.assertEqual(subnet['routes'], [route1, route2])
Ejemplo n.º 2
0
 def test_add_route_a_lot(self):
     subnet = fake_network_cache_model.new_subnet()
     route1 = fake_network_cache_model.new_route()
     route2 = fake_network_cache_model.new_route({'cidr': '1.1.1.1/24'})
     for i in xrange(10):
         subnet.add_route(route2)
     self.assertEqual(subnet['routes'], [route1, route2])
    def test_hydrate(self):
        subnet_dict = {
            'cidr': '255.255.255.0',
            'dns': [fake_network_cache_model.new_ip(dict(address='1.1.1.1'))],
            'ips': [fake_network_cache_model.new_ip(dict(address='2.2.2.2'))],
            'routes': [fake_network_cache_model.new_route()],
            'version': 4,
            'gateway': fake_network_cache_model.new_ip(
                            dict(address='3.3.3.3'))}
        subnet = model.Subnet.hydrate(subnet_dict)

        self.assertEqual(subnet['cidr'], '255.255.255.0')
        self.assertEqual(subnet['dns'], [fake_network_cache_model.new_ip(
                                         dict(address='1.1.1.1'))])
        self.assertEqual(subnet['gateway']['address'], '3.3.3.3')
        self.assertEqual(subnet['ips'], [fake_network_cache_model.new_ip(
                                         dict(address='2.2.2.2'))])
        self.assertEqual(subnet['routes'], [
                    fake_network_cache_model.new_route()])
        self.assertEqual(subnet['version'], 4)
Ejemplo n.º 4
0
    def test_hydrate(self):
        subnet_dict = {
            'cidr': '255.255.255.0',
            'dns': [fake_network_cache_model.new_ip(dict(address='1.1.1.1'))],
            'ips': [fake_network_cache_model.new_ip(dict(address='2.2.2.2'))],
            'routes': [fake_network_cache_model.new_route()],
            'version': 4,
            'gateway': fake_network_cache_model.new_ip(dict(address='3.3.3.3'))
        }
        subnet = model.Subnet.hydrate(subnet_dict)

        self.assertEqual(subnet['cidr'], '255.255.255.0')
        self.assertEqual(
            subnet['dns'],
            [fake_network_cache_model.new_ip(dict(address='1.1.1.1'))])
        self.assertEqual(subnet['gateway']['address'], '3.3.3.3')
        self.assertEqual(
            subnet['ips'],
            [fake_network_cache_model.new_ip(dict(address='2.2.2.2'))])
        self.assertEqual(subnet['routes'],
                         [fake_network_cache_model.new_route()])
        self.assertEqual(subnet['version'], 4)
    def test_create_subnet_with_attrs(self):
        subnet = fake_network_cache_model.new_subnet()

        route1 = fake_network_cache_model.new_route()

        self.assertEqual(subnet['cidr'], '255.255.255.0')
        self.assertEqual(subnet['dns'],
                [fake_network_cache_model.new_ip(dict(address='1.2.3.4')),
                 fake_network_cache_model.new_ip(dict(address='2.3.4.5'))])
        self.assertEqual(subnet['gateway']['address'], '192.168.1.1')
        self.assertEqual(subnet['ips'],
                [fake_network_cache_model.new_ip(
                        dict(address='192.168.1.100')),
                 fake_network_cache_model.new_ip(
                            dict(address='192.168.1.101'))])
        self.assertEqual(subnet['routes'], [route1])
        self.assertEqual(subnet['version'], 4)
Ejemplo n.º 6
0
    def test_create_subnet_with_attrs(self):
        subnet = fake_network_cache_model.new_subnet()

        route1 = fake_network_cache_model.new_route()

        self.assertEqual(subnet['cidr'], '255.255.255.0')
        self.assertEqual(subnet['dns'], [
            fake_network_cache_model.new_ip(dict(address='1.2.3.4')),
            fake_network_cache_model.new_ip(dict(address='2.3.4.5'))
        ])
        self.assertEqual(subnet['gateway']['address'], '192.168.1.1')
        self.assertEqual(subnet['ips'], [
            fake_network_cache_model.new_ip(dict(address='192.168.1.100')),
            fake_network_cache_model.new_ip(dict(address='192.168.1.101'))
        ])
        self.assertEqual(subnet['routes'], [route1])
        self.assertEqual(subnet['version'], 4)
 def test_routes_not_equal(self):
     route1 = fake_network_cache_model.new_route()
     route2 = fake_network_cache_model.new_route(dict(cidr='1.1.1.1/24'))
     self.assertNotEqual(route1, route2)
 def test_routes_equal(self):
     route1 = fake_network_cache_model.new_route()
     route2 = fake_network_cache_model.new_route()
     self.assertEqual(route1, route2)
 def test_create_route_with_attrs(self):
     route = fake_network_cache_model.new_route()
     ip = fake_network_cache_model.new_ip(dict(address='192.168.1.1'))
     self.assertEqual(route['cidr'], '0.0.0.0/24')
     self.assertEqual(route['gateway']['address'], '192.168.1.1')
     self.assertEqual(route['interface'], 'eth0')
Ejemplo n.º 10
0
 def test_routes_not_equal(self):
     route1 = fake_network_cache_model.new_route()
     route2 = fake_network_cache_model.new_route(dict(cidr='1.1.1.1/24'))
     self.assertNotEqual(route1, route2)
Ejemplo n.º 11
0
 def test_routes_equal(self):
     route1 = fake_network_cache_model.new_route()
     route2 = fake_network_cache_model.new_route()
     self.assertEqual(route1, route2)
Ejemplo n.º 12
0
 def test_create_route_with_attrs(self):
     route = fake_network_cache_model.new_route()
     ip = fake_network_cache_model.new_ip(dict(address='192.168.1.1'))
     self.assertEqual(route['cidr'], '0.0.0.0/24')
     self.assertEqual(route['gateway']['address'], '192.168.1.1')
     self.assertEqual(route['interface'], 'eth0')