Skip to contentSkip to conversation

auto-t: Remove unnecessary disconnect calls

PATCH In review Tim Kourt 2 participants 6 messages May 7, 2020

lore
Share & tools
lore

Tim Kourt

author
#0 lore raw

PATCH 1/5 auto-t: Remove unnecessary disconnect calls

With the introduction of AutoConnect=False network setting the initial disconnect calls are no longer needed

---
 autotests/testAP/failure_test.py | 2 --
 autotests/testAP/test.py         | 2 --
 2 files changed, 4 deletions(-)
autotests/testAP/failure_test.py +0 -2
index cad7bf6e..d419c05b 100644
@@ -58,8 +58,6 @@ class Test(unittest.TestCase):
         wd = IWD()
 
         dev1, dev2 = wd.list_devices(2)
-        dev1.disconnect()
-        dev2.disconnect()
 
         self.client_connect(wd, dev1)
 
autotests/testAP/test.py +0 -2
index 39161981..455c9916 100644
@@ -51,8 +51,6 @@ class Test(unittest.TestCase):
         wd = IWD()
 
         dev1, dev2 = wd.list_devices(2)
-        dev1.disconnect()
-        dev2.disconnect()
 
         self.client_connect(wd, dev1)
 
Signature · 1 line
2.13.6
author
#1 lore raw

PATCH 2/5 auto-t: Rename test case to reflect its purpose

---
 autotests/testAP/failure_test.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
autotests/testAP/failure_test.py +1 -1
index d419c05b..2c1e14b3 100644
@@ -54,7 +54,7 @@ class Test(unittest.TestCase):
         condition = 'not obj.connected'
         wd.wait_for_object_condition(ordered_network.network_object, condition)
 
-    def test_connection_success(self):
+    def test_connection_failure(self):
         wd = IWD()
 
         dev1, dev2 = wd.list_devices(2)
Signature · 1 line
2.13.6
author
#2 lore raw

PATCH 3/5 auto-t: Return None instead of empty known net list

In reply to Tim Kourt

To match the original behavior of get_ordered_networks, return None for the empty list of known networks after the scan is complete

---
 autotests/util/iwd.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
autotests/util/iwd.py +4 -1
index c8d11f91..b9eeb0ff 100755
@@ -395,7 +395,10 @@ class Device(IWDDBusAbstract):
             ordered_network = OrderedNetwork(bus_obj)
             ordered_networks.append(ordered_network)
 
-        return ordered_networks
+        if len(ordered_networks) > 0:
+            return ordered_networks
+
+        return None
 
     def get_ordered_network(self, network, scan_if_needed = False):
         '''Returns a single network from ordered network call, or None if the
Signature · 1 line
2.13.6
author
#3 lore raw

PATCH 4/5 auto-t: Use changed get_ordered_network API

In reply to Tim Kourt

Rely on internal scan and wait implementation of get_ordered_network to obtain the known networks

---
 autotests/testAP/failure_test.py | 11 +----------
 autotests/testAP/test.py         | 11 +----------
 2 files changed, 2 insertions(+), 20 deletions(-)
autotests/testAP/failure_test.py +1 -10
index 2c1e14b3..9944abaa 100644
@@ -14,17 +14,8 @@ import testutil
 class Test(unittest.TestCase):
 
     def client_connect(self, wd, dev):
-        condition = 'not obj.scanning'
-        wd.wait_for_object_condition(dev, condition)
 
-        if not dev.get_ordered_networks():
-            dev.scan()
-            condition = 'obj.scanning'
-            wd.wait_for_object_condition(dev, condition)
-            condition = 'not obj.scanning'
-            wd.wait_for_object_condition(dev, condition)
-
-        ordered_network = dev.get_ordered_network('TestAP1')
+        ordered_network = dev.get_ordered_network('TestAP1', True)
 
         self.assertEqual(ordered_network.type, NetworkType.psk)
 
autotests/testAP/test.py +1 -10
index 455c9916..4cacf9ad 100644
@@ -14,17 +14,8 @@ import testutil
 class Test(unittest.TestCase):
 
     def client_connect(self, wd, dev):
-        condition = 'not obj.scanning'
-        wd.wait_for_object_condition(dev, condition)
 
-        if not dev.get_ordered_networks():
-            dev.scan()
-            condition = 'obj.scanning'
-            wd.wait_for_object_condition(dev, condition)
-            condition = 'not obj.scanning'
-            wd.wait_for_object_condition(dev, condition)
-
-        ordered_network = dev.get_ordered_network('TestAP1')
+        ordered_network = dev.get_ordered_network('TestAP1', True)
 
         self.assertEqual(ordered_network.type, NetworkType.psk)
 
Signature · 1 line
2.13.6
author
#4 lore raw

PATCH 5/5 auto-t: Remove bogus logic

In reply to Tim Kourt

Device object has no property named 'connected'.
client_connect has no member dev2

---
 autotests/testAP/failure_test.py | 7 -------
 1 file changed, 7 deletions(-)
autotests/testAP/failure_test.py +0 -7
index 9944abaa..d30bccb4 100644
@@ -22,13 +22,6 @@ class Test(unittest.TestCase):
         psk_agent = PSKAgent('Password1')
         wd.register_psk_agent(psk_agent)
 
-        try:
-            dev2.disconnect()
-            condition = 'not obj.connected'
-            wd.wait_for_object_condition(dev2, condition)
-        except:
-            pass
-
         ordered_network.network_object.connect()
 
         condition = 'obj.connected'
Signature · 1 line
2.13.6
#5 lore raw
In reply to Tim Kourt

Hi Tim,

Quoted 7 lines · Tim Kourt

With the introduction of AutoConnect=False network setting the initial disconnect calls are no longer needed

---
  autotests/testAP/failure_test.py | 2 --
  autotests/testAP/test.py         | 2 --
  2 files changed, 4 deletions(-)

All applied, thanks.

Regards,
-Denis