3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-26 09:32:34 +01:00

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.
This commit is contained in:
James Prestwood 2018-12-14 11:15:27 -08:00 committed by Denis Kenzior
parent 699b83cb1f
commit 9d3d65a282

View File

@ -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,