Skip to content

Commit

Permalink
fix unittest for routemap check
Browse files Browse the repository at this point in the history
  • Loading branch information
indy-independence committed Feb 24, 2025
1 parent 0a79f2b commit e132940
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/cnaas_nms/db/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ def check_vlan_collisions(devices_dict: Dict[str, dict], mgmt_vlans: Set[int], u
if "vni" not in vxlan_data or not isinstance(vxlan_data["vni"], int):
logger.error("VXLAN {} is missing vni".format(vxlan_name))
continue
if settings["vxlan_vni_range"] and "-" in settings["vxlan_vni_range"]:
if "vxlan_vni_range" in settings and settings["vxlan_vni_range"]:
vni_range = settings["vxlan_vni_range"].split("-")
if not int(vni_range[0]) < vxlan_data["vni"] < int(vni_range[1]):
raise VlanConflictError(
Expand Down
16 changes: 16 additions & 0 deletions src/cnaas_nms/db/tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
DIR_STRUCTURE,
VerifyPathException,
VlanConflictError,
check_bgp_neighbor_routemaps,
check_group_priority_collisions,
check_vlan_collisions,
get_device_primary_groups,
Expand Down Expand Up @@ -171,6 +172,21 @@ def test_vlan_collisions(self):
}
self.assertIsNone(check_vlan_collisions(devices_dict, mgmt_vlans))

def test_routing_policy(self):
test_device_name = "policytest"
test_vrfs = [
{
"name": "testvrf",
"neighbor_v4": [{"route_map_in": "routemap1", "route_map_out": "routemap1"}],
"neighbor_v6": [{"route_map_in": "routemap2", "route_map_out": "routemap2"}],
}
]
with self.assertRaises(ValueError, msg="Undefined route map routemap1 should raise error"):
check_bgp_neighbor_routemaps(test_device_name, test_vrfs, {})
check_bgp_neighbor_routemaps(test_device_name, test_vrfs, {"routemap1", "routemap2"})
with self.assertRaises(KeyError):
check_bgp_neighbor_routemaps(test_device_name, [{"name": "emptyvrf"}], {})

def test_groups_priorities_sorted(self):
group_settings_dict = {
"groups": [
Expand Down

0 comments on commit e132940

Please sign in to comment.