commit 9d3d65a2827bccd63476fc9db1fd0e7ab3226ce9
parent 699b83cb1fd52739b0c8ce0d70112fcb53bf1a17
Author: James Prestwood <james.prestwood@linux.intel.com>
Date: Fri, 14 Dec 2018 11:15:27 -0800
auto-t: add get_ordered_network(ssid)
This is a helper/shortcut to get_ordered_networks (plural). In nearly
all the autotests we had (roughly) the same block of code:
ordered_network = get_ordered_networks()[0]
self.assertNotEqual(ordered_network, None)
self.assertEqual(ordered_network.name, "someSsid")
Rather than having to do this, we can simplify and just have a single
call to get_ordered_network, which takes the SSID. If the SSID is not
found, we raise an exception. This avoids needing both asserts since
we are guarenteed that the return is valid and the SSID matches.
This also avoids possible issues with multiple networks showing up in
the GetOrderedNetworks call. Eventually test-runner will support running
tests on real wireless hardware, so its possible we could pick up
unexpected networks in the scan.
Diffstat:
1 file changed, 13 insertions(+), 0 deletions(-)
diff --git a/autotests/util/iwd.py b/autotests/util/iwd.py
@@ -376,6 +376,19 @@ class Device(IWDDBusAbstract):
ordered_networks.append(ordered_network)
return ordered_networks
+ def get_ordered_network(self, network):
+ '''Returns a single network from ordered network call, or None if the
+ network wasn't found. If the network is not found an exception is
+ raised, this removes the need to extra asserts in autotests.
+ '''
+ ordered_networks = self.get_ordered_networks()
+
+ for n in ordered_networks:
+ if n.name == network:
+ return n
+
+ raise Exception('Network %s not found' % network)
+
def wps_push_button(self):
self._wps_manager.PushButton(dbus_interface=IWD_WSC_INTERFACE,
reply_handler=self._success,