def test_create_network(self): network = fake_network_cache_model.new_network() self.assertEqual(network['id'], 1) self.assertEqual(network['bridge'], 'br0') self.assertEqual(network['label'], 'public') self.assertEqual(network['subnets'], [fake_network_cache_model.new_subnet(), fake_network_cache_model.new_subnet( dict(cidr='255.255.255.255'))])
def test_add_subnet(self): network = fake_network_cache_model.new_network() network.add_subnet(fake_network_cache_model.new_subnet( dict(cidr='0.0.0.0'))) self.assertEqual(network['subnets'], [fake_network_cache_model.new_subnet(), fake_network_cache_model.new_subnet( dict(cidr='255.255.255.255')), fake_network_cache_model.new_subnet(dict(cidr='0.0.0.0'))])
def test_create_network(self): network = fake_network_cache_model.new_network() self.assertEqual(network['id'], 1) self.assertEqual(network['bridge'], 'br0') self.assertEqual(network['label'], 'public') self.assertEqual(network['subnets'], [ fake_network_cache_model.new_subnet(), fake_network_cache_model.new_subnet(dict(cidr='255.255.255.255')) ])
def test_add_subnet(self): network = fake_network_cache_model.new_network() network.add_subnet( fake_network_cache_model.new_subnet(dict(cidr='0.0.0.0'))) self.assertEqual(network['subnets'], [ fake_network_cache_model.new_subnet(), fake_network_cache_model.new_subnet(dict(cidr='255.255.255.255')), fake_network_cache_model.new_subnet(dict(cidr='0.0.0.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): new_network = dict( id=1, bridge='br0', label='public', subnets=[fake_network_cache_model.new_subnet(), fake_network_cache_model.new_subnet( dict(cidr='255.255.255.255'))]) network = model.Network.hydrate(fake_network_cache_model.new_network()) self.assertEqual(network['id'], 1) self.assertEqual(network['bridge'], 'br0') self.assertEqual(network['label'], 'public') self.assertEqual(network['subnets'], [fake_network_cache_model.new_subnet(), fake_network_cache_model.new_subnet( dict(cidr='255.255.255.255'))])
def test_add_dns(self): subnet = fake_network_cache_model.new_subnet() dns = fake_network_cache_model.new_ip(dict(address='9.9.9.9')) subnet.add_dns(dns) 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')), fake_network_cache_model.new_ip(dict(address='9.9.9.9'))])
def test_add_dns_a_lot(self): subnet = fake_network_cache_model.new_subnet() for i in xrange(10): subnet.add_dns(fake_network_cache_model.new_ip( dict(address='9.9.9.9'))) 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')), fake_network_cache_model.new_ip(dict(address='9.9.9.9'))])
def test_hydrate(self): new_network = dict(id=1, bridge='br0', label='public', subnets=[ fake_network_cache_model.new_subnet(), fake_network_cache_model.new_subnet( dict(cidr='255.255.255.255')) ]) network = model.Network.hydrate(fake_network_cache_model.new_network()) self.assertEqual(network['id'], 1) self.assertEqual(network['bridge'], 'br0') self.assertEqual(network['label'], 'public') self.assertEqual(network['subnets'], [ fake_network_cache_model.new_subnet(), fake_network_cache_model.new_subnet(dict(cidr='255.255.255.255')) ])
def test_add_ip(self): subnet = fake_network_cache_model.new_subnet() subnet.add_ip( fake_network_cache_model.new_ip(dict(address='192.168.1.102'))) 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')), fake_network_cache_model.new_ip(dict(address='192.168.1.102')) ])
def test_add_dns(self): subnet = fake_network_cache_model.new_subnet() dns = fake_network_cache_model.new_ip(dict(address='9.9.9.9')) subnet.add_dns(dns) 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')), fake_network_cache_model.new_ip(dict(address='9.9.9.9')) ])
def test_add_dns_a_lot(self): subnet = fake_network_cache_model.new_subnet() for i in xrange(10): subnet.add_dns( fake_network_cache_model.new_ip(dict(address='9.9.9.9'))) 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')), fake_network_cache_model.new_ip(dict(address='9.9.9.9')) ])
def test_add_ip(self): subnet = fake_network_cache_model.new_subnet() subnet.add_ip(fake_network_cache_model.new_ip( dict(address='192.168.1.102'))) 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')), fake_network_cache_model.new_ip( dict(address='192.168.1.102'))])
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_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)