Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pkgs/ops-pkg/src/genie/libs/ops/interface/nxos/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,11 +464,11 @@ def _match_keys(self, dic, match):
if isinstance(dic, dict):
for key, value in match.items():
for dic_key in dic:
if key in dic[dic_key] and dic[dic_key][key] == value:
if not isinstance(dic[dic_key], dict):
Comment thread
toeknee2120 marked this conversation as resolved.
pass
elif key in dic[dic_key] and dic[dic_key][key] == value:
self.ret_dict.update(dic)
break
elif not isinstance(dic[dic_key], dict):
pass
else:
self._match_keys(dic=dic[dic_key], match=match)
return(self.ret_dict)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,11 +485,11 @@ def _match_keys(self, dic, match):
if isinstance(dic, dict):
for key, value in match.items():
for dic_key in dic:
if key in dic[dic_key] and dic[dic_key][key] == value:
if not isinstance(dic[dic_key], dict):
pass
elif key in dic[dic_key] and dic[dic_key][key] == value:
self.ret_dict.update(dic)
break
elif not isinstance(dic[dic_key], dict):
pass
else:
self._match_keys(dic=dic[dic_key], match=match)
return(self.ret_dict)
return(self.ret_dict)
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,22 @@ def test_incomplete_output(self):
# Verify Ops was created successfully
self.assertDictEqual(intf.info, expect_dict)

def test_match_keys_ignores_scalar_values(self):
intf = Interface(device=self.device)
intf.ret_dict = {}
g
routing_dict = {
"route1": {
"interface": "Ethernet2/1",
"tag": 10,
},
"scalar": "not-a-dict",
}

intf._match_keys(dic=routing_dict, match={"interface": "Ethernet2/1"})

self.assertEqual(intf.ret_dict, routing_dict)

def test_brief_output(self):
self.maxDiff = None
intf = InterfaceRev1(device=self.device)
Expand Down