Ejemplo n.º 1
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])
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])
Ejemplo n.º 3
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_fixed_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_fixed_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_fixed_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_fixed_ip(dict(address='2.2.2.2'))])
        self.assertEqual(subnet['routes'],
                         [fake_network_cache_model.new_route()])
        self.assertEqual(subnet['version'], 4)
Ejemplo n.º 5
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'], '10.10.0.0/24')
        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'], '10.10.0.1')
        self.assertEqual(subnet['ips'], [
            fake_network_cache_model.new_fixed_ip(dict(address='10.10.0.2')),
            fake_network_cache_model.new_fixed_ip(dict(address='10.10.0.3'))
        ])
        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'], '10.10.0.0/24')
        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'], '10.10.0.1')
        self.assertEqual(subnet['ips'],
                [fake_network_cache_model.new_fixed_ip(
                        dict(address='10.10.0.2')),
                 fake_network_cache_model.new_fixed_ip(
                            dict(address='10.10.0.3'))])
        self.assertEqual(subnet['routes'], [route1])
        self.assertEqual(subnet['version'], 4)
Ejemplo n.º 7
0
 def test_create_route_with_attrs(self):
     route = fake_network_cache_model.new_route()
     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.º 8
0
 def test_create_route_with_attrs(self):
     route = fake_network_cache_model.new_route()
     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')