2019-04-16 23:51:43 +02:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
|
|
|
import unittest
|
|
|
|
import sys
|
|
|
|
import time
|
|
|
|
|
|
|
|
sys.path.append('../util')
|
|
|
|
import iwd
|
|
|
|
from iwd import IWD
|
|
|
|
|
|
|
|
class Test(unittest.TestCase):
|
|
|
|
dict = {
|
|
|
|
'ssid_open_1': False,
|
|
|
|
'ssid_open_2': False,
|
|
|
|
'ssid_open_3': False,
|
|
|
|
}
|
|
|
|
|
|
|
|
def set_network(self, ssid):
|
|
|
|
if ssid not in self.dict:
|
|
|
|
return
|
|
|
|
|
|
|
|
self.dict[ssid] = True
|
|
|
|
|
|
|
|
def validate_quick_scan(self, wd):
|
|
|
|
devices = wd.list_devices(1)
|
|
|
|
device = devices[0]
|
2021-08-12 22:38:12 +02:00
|
|
|
device.autoconnect = True
|
2019-04-16 23:51:43 +02:00
|
|
|
|
|
|
|
# Device initiates a passive quick scan and scans only for the known
|
|
|
|
# frequencies (listed in .known_network.freq file).
|
|
|
|
condition = 'obj.scanning'
|
|
|
|
wd.wait_for_object_condition(device, condition)
|
|
|
|
condition = 'not obj.scanning'
|
|
|
|
wd.wait_for_object_condition(device, condition)
|
|
|
|
|
|
|
|
ordered_networks = device.get_ordered_networks()
|
|
|
|
|
|
|
|
for network in ordered_networks:
|
|
|
|
self.set_network(network.name)
|
|
|
|
|
|
|
|
def test_scan(self):
|
|
|
|
wd = IWD(True)
|
|
|
|
|
2019-04-20 22:29:05 +02:00
|
|
|
self.validate_quick_scan(wd)
|
2019-04-16 23:51:43 +02:00
|
|
|
|
|
|
|
# Only ssid_open_1 and ssid_open_2 should be discovered.
|
|
|
|
self.assertEqual(self.dict['ssid_open_1'], True)
|
|
|
|
self.assertEqual(self.dict['ssid_open_2'], True)
|
|
|
|
self.assertEqual(self.dict['ssid_open_3'], False)
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def setUpClass(cls):
|
|
|
|
IWD.copy_to_storage('.known_network.freq')
|
|
|
|
IWD.copy_to_storage('ssid_open_1.open')
|
|
|
|
IWD.copy_to_storage('ssid_open_2.open')
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def tearDownClass(cls):
|
|
|
|
IWD.clear_storage()
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main(exit=True)
|