def test_subnet_config(self): expected = { 'cidr': '192.168.1.0/24', 'dhcp_enabled': True, 'dns_nameservers': ['8.8.8.8'], 'gateway_ip': '192.168.1.1', 'host_routes': {} } self.assertEqual(common._subnet_config(fakes.fake_subnet), expected)
def test_subnet_config_with_slaac_enabled(self): expected = { 'cidr': 'fdee:9f85:83be::/48', 'dhcp_enabled': False, 'dns_nameservers': ['8.8.8.8'], 'gateway_ip': 'fdee:9f85:83be::1', 'host_routes': {} } self.assertEqual( common._subnet_config(fakes.fake_subnet_with_slaac), expected)
def test_subnet_config(self): expected = { 'cidr': '192.168.1.0/24', 'dhcp_enabled': True, 'dns_nameservers': ['8.8.8.8'], 'gateway_ip': '192.168.1.1', 'host_routes': {}, 'id': 's1', } self.assertEqual(common._subnet_config(fakes.fake_subnet), expected)
def test_subnet_config_with_slaac_enabled(self): expected = { 'cidr': 'fdee:9f85:83be::/48', 'dhcp_enabled': False, 'dns_nameservers': ['8.8.8.8'], 'gateway_ip': 'fdee:9f85:83be::1', 'host_routes': {}, 'id': 'fake_id', } self.assertEqual(common._subnet_config(fakes.fake_subnet_with_slaac), expected)
def test_subnet_config_gateway_none(self): expected = { 'cidr': '192.168.1.0/24', 'dhcp_enabled': True, 'dns_nameservers': ['8.8.8.8'], 'gateway_ip': '', 'host_routes': {} } sn = fakes.FakeModel( 's1', cidr=netaddr.IPNetwork('192.168.1.0/24'), gateway_ip=None, enable_dhcp=True, dns_nameservers=['8.8.8.8'], ipv6_ra_mode='', host_routes={}) self.assertEqual(common._subnet_config(sn), expected)
def test_subnet_config_gateway_none(self): expected = { 'cidr': '192.168.1.0/24', 'dhcp_enabled': True, 'dns_nameservers': ['8.8.8.8'], 'gateway_ip': '', 'host_routes': {}, 'id': 's1', } sn = fakes.FakeModel('s1', cidr=netaddr.IPNetwork('192.168.1.0/24'), gateway_ip=None, enable_dhcp=True, dns_nameservers=['8.8.8.8'], ipv6_ra_mode='', host_routes={}) self.assertEqual(common._subnet_config(sn), expected)