Change get_interfaces_on_bridge() to return [] instead of None
if the bridge is not found, as callers are expecting an iterator.
Change-Id: I359a2a0cf932c049f6891d4ba3eb8b9b23ab360d
Related-Bug:
1284311
bridge_interface_path = BRIDGE_INTERFACES_FS.replace(
BRIDGE_NAME_PLACEHOLDER, bridge_name)
return os.listdir(bridge_interface_path)
+ else:
+ return []
def get_tap_devices_count(self, bridge_name):
bridge_interface_path = BRIDGE_INTERFACES_FS.replace(
self.assertEqual(self.lbm.get_interfaces_on_bridge("br0"),
["qbr1"])
+ def test_get_interfaces_on_bridge_not_existing(self):
+ self.lbm.device_exists = mock.Mock(return_value=False)
+ self.assertEqual([], self.lbm.get_interfaces_on_bridge("br0"))
+
def test_get_tap_devices_count(self):
with mock.patch.object(os, 'listdir') as listdir_fn:
listdir_fn.return_value = ['tap2101', 'eth0.100', 'vxlan-1000']