def test_basic_config(self): """Tests the minimal config""" input_config = {'vid': 100} expected_config = self.default_config expected_config.update(input_config) vlan = VLAN(1, 1, input_config) output_config = vlan.to_conf() self.assertEqual(output_config, expected_config) key_exceptions = [ 'name', 'tagged', 'dyn_gws_by_ipv', 'dyn_host_cache_by_port', 'dp_id', 'bgp_neighbor_addresses', 'bgp_neighbor_as', 'dyn_routes_by_ipv', '_id', 'dyn_neigh_cache_by_ipv', 'dyn_ipvs', 'dyn_bgp_ipvs', 'dyn_host_cache', 'dyn_faucet_vips_by_ipv', 'dyn_bgp_neighbor_addresses_by_ipv', 'dyn_bgp_server_addresses_by_ipv', 'untagged' ] dict_keys = set(vlan.__dict__.keys()) conf_keys = set(vlan.to_conf().keys()) for exception in key_exceptions: dict_keys.remove(exception) self.assertEqual(dict_keys, conf_keys)
def test_with_routes(self): """Tests a config with routes""" input_config = { 'routes': [{ 'route': { 'ip_dst': '10.99.99.0/24', 'ip_gw': '10.0.0.1' } }, { 'route': { 'ip_dst': '10.99.98.0/24', 'ip_gw': '10.0.0.99' } }], 'vid': 100 } expected_config = self.default_config expected_config.update(input_config) vlan = VLAN(1, 1, input_config) output_config = vlan.to_conf() self.assertEqual(output_config, expected_config)
def test_with_vips(self): """Tests a config with virtual IPs""" input_config = {'faucet_vips': ['10.0.0.254/24'], 'vid': 100} expected_config = self.default_config expected_config.update(input_config) vlan = VLAN(1, 1, input_config) output_config = vlan.to_conf() self.assertEqual(output_config, expected_config)