commit fc9342f75135e2674f396574cbef059e19253326
parent 6c2b10b1189eb558c861502379104e7b24309a6b
Author: James Prestwood <prestwoj@gmail.com>
Date: Mon, 28 Oct 2019 12:51:59 -0700
auto-t: return None with get_ordered_network(s)
If no networks are found, return None rather than an empty
array. This is easier to check by the caller (and was assumed
in some cases). Also add an exception to get_ordered_network
if no network is found.
Diffstat:
1 file changed, 7 insertions(+), 0 deletions(-)
diff --git a/autotests/util/iwd.py b/autotests/util/iwd.py
@@ -376,6 +376,10 @@ class Device(IWDDBusAbstract):
for bus_obj in self._station.GetOrderedNetworks():
ordered_network = OrderedNetwork(bus_obj)
ordered_networks.append(ordered_network)
+
+ if len(ordered_networks) == 0:
+ return None
+
return ordered_networks
def get_ordered_network(self, network):
@@ -385,6 +389,9 @@ class Device(IWDDBusAbstract):
'''
ordered_networks = self.get_ordered_networks()
+ if not ordered_networks:
+ raise Exception('Network %s not found' % network)
+
for n in ordered_networks:
if n.name == network:
return n