Skip to content

Commit 9226a4a

Browse files
committed
test/infamy: minor, whitespace + coding style
Signed-off-by: Joachim Wiberg <[email protected]>
1 parent 9b83b82 commit 9226a4a

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

test/infamy/iface.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
Fetch interface status from remote device.
33
"""
44

5+
56
def get_xpath(iface, path=None):
67
"""Compose complete XPath to a YANG node in /ietf-interfaces"""
7-
xpath=f"/ietf-interfaces:interfaces/interface[name='{iface}']"
8-
if not path is None:
9-
xpath=f"{xpath}/{path}"
8+
xpath = f"/ietf-interfaces:interfaces/interface[name='{iface}']"
9+
if path is not None:
10+
xpath = f"{xpath}/{path}"
1011
return xpath
1112

13+
1214
def _extract_param(json_content, param):
1315
"""Returns (extracted) value for parameter 'param'"""
1416
interfaces = json_content.get('interfaces')
@@ -22,13 +24,15 @@ def _extract_param(json_content, param):
2224

2325
return None
2426

27+
2528
def get_param(target, iface, param=None):
2629
"""Fetch target dict for iface and extract param from JSON"""
2730
content = target.get_data(get_xpath(iface, param))
2831
if content is None:
2932
return None
3033
return _extract_param(content, param)
3134

35+
3236
def exist(target, iface):
3337
"""Verify that the target interface exists"""
3438
return get_param(target, iface, "name") is not None
@@ -60,21 +64,23 @@ def get_phys_address(target, iface):
6064
"""Fetch interface MAC address (operational status)"""
6165
return get_param(target, iface, "phys-address")
6266

67+
6368
def exist_bridge_multicast_filter(target, group, iface, bridge):
64-
# The interface array is different in restconf/netconf, netconf has a keyed list but
65-
# restconf has a numbered list, i think i read that this was a bug in rousette, but
66-
# have not found it.
67-
interface=target.get_iface(bridge)
69+
"""Check if a bridge has a multicast filter for group with iface"""
70+
# The interface array is different in restconf/netconf, netconf has
71+
# a keyed list but restconf has a numbered list, i think i read that
72+
# this was a bug in rousette, but have not found it.
73+
interface = target.get_iface(bridge)
6874
if interface is None:
6975
raise "Interface not found"
7076

7177
brif = interface.get("bridge") or interface.get("infix-interfaces:bridge")
7278
if brif is None:
7379
return False
7480

75-
for filter in brif.get("multicast-filters", {}).get("multicast-filter", {}):
76-
if filter.get("group") == group:
77-
for p in filter.get("ports"):
81+
for f in brif.get("multicast-filters", {}).get("multicast-filter", {}):
82+
if f.get("group") == group:
83+
for p in f.get("ports"):
7884
if p["port"] == iface:
7985
return True
8086

0 commit comments

Comments
 (0)