commit d4e27b8ee2c9badd1a3e4d791dd159914ab59c84
parent 45dd5d2f7cbf05c3a3df82bf01a3f39a57c59fd6
Author: James Prestwood <prestwoj@gmail.com>
Date: Wed, 21 Apr 2021 11:42:28 -0700
auto-t: move AuthCenter to Setup/Tear down
By moving the AuthCenter initializer to SetUpClass we can now
call stop() in TearDownClass which handles any exception the
test might throw.
Diffstat:
3 files changed, 14 insertions(+), 28 deletions(-)
diff --git a/autotests/testEAP-AKA-ofono/connection_test.py b/autotests/testEAP-AKA-ofono/connection_test.py
@@ -12,10 +12,7 @@ from ofono import Ofono
from config import ctx
class Test(unittest.TestCase):
-
def test_connection_success(self):
- auth = AuthCenter('/tmp/hlrauc.sock', '/tmp/sim.db')
-
ofono = Ofono()
ofono.enable_modem('/phonesim')
ofono.wait_for_sim_auth()
@@ -40,11 +37,7 @@ class Test(unittest.TestCase):
condition = 'not obj.connected'
wd.wait_for_object_condition(ordered_network.network_object, condition)
- try:
- ordered_network.network_object.connect()
- except:
- auth.stop()
- raise
+ ordered_network.network_object.connect()
condition = 'obj.state == DeviceState.connected'
wd.wait_for_object_condition(device, condition)
@@ -54,7 +47,6 @@ class Test(unittest.TestCase):
condition = 'not obj.connected'
wd.wait_for_object_condition(ordered_network.network_object, condition)
- auth.stop()
@classmethod
def setUpClass(cls):
if not ctx.is_process_running('ofonod'):
@@ -62,9 +54,13 @@ class Test(unittest.TestCase):
IWD.copy_to_storage('ssidEAP-AKA.8021x')
+ cls.auth = AuthCenter('/tmp/hlrauc.sock', '/tmp/sim.db')
+
@classmethod
def tearDownClass(cls):
IWD.clear_storage()
+ cls.auth.stop()
+
if __name__ == '__main__':
unittest.main(exit=True)
diff --git a/autotests/testEAP-AKA-prime-ofono/connection_test.py b/autotests/testEAP-AKA-prime-ofono/connection_test.py
@@ -12,10 +12,7 @@ from ofono import Ofono
from config import ctx
class Test(unittest.TestCase):
-
def test_connection_success(self):
- auth = AuthCenter('/tmp/hlrauc.sock', '/tmp/sim.db')
-
ofono = Ofono()
ofono.enable_modem('/phonesim')
ofono.wait_for_sim_auth()
@@ -40,11 +37,7 @@ class Test(unittest.TestCase):
condition = 'not obj.connected'
wd.wait_for_object_condition(ordered_network.network_object, condition)
- try:
- ordered_network.network_object.connect()
- except:
- auth.stop()
- raise
+ ordered_network.network_object.connect()
condition = 'obj.state == DeviceState.connected'
wd.wait_for_object_condition(device, condition)
@@ -54,8 +47,6 @@ class Test(unittest.TestCase):
condition = 'not obj.connected'
wd.wait_for_object_condition(ordered_network.network_object, condition)
- auth.stop()
-
@classmethod
def setUpClass(cls):
if not ctx.is_process_running('ofonod'):
@@ -63,9 +54,12 @@ class Test(unittest.TestCase):
IWD.copy_to_storage('ssidEAP-AKA.8021x')
+ cls.auth = AuthCenter('/tmp/hlrauc.sock', '/tmp/sim.db')
+
@classmethod
def tearDownClass(cls):
IWD.clear_storage()
+ cls.auth.stop()
if __name__ == '__main__':
unittest.main(exit=True)
diff --git a/autotests/testEAP-SIM-ofono/connection_test.py b/autotests/testEAP-SIM-ofono/connection_test.py
@@ -14,8 +14,6 @@ from config import ctx
class Test(unittest.TestCase):
def test_connection_success(self):
- auth = AuthCenter('/tmp/hlrauc.sock', '/tmp/sim.db')
-
ofono = Ofono()
ofono.enable_modem('/phonesim')
ofono.wait_for_sim_auth()
@@ -40,11 +38,7 @@ class Test(unittest.TestCase):
condition = 'not obj.connected'
wd.wait_for_object_condition(ordered_network.network_object, condition)
- try:
- ordered_network.network_object.connect()
- except:
- auth.stop()
- raise
+ ordered_network.network_object.connect()
condition = 'obj.state == DeviceState.connected'
wd.wait_for_object_condition(device, condition)
@@ -54,8 +48,6 @@ class Test(unittest.TestCase):
condition = 'not obj.connected'
wd.wait_for_object_condition(ordered_network.network_object, condition)
- auth.stop()
-
@classmethod
def setUpClass(cls):
if not ctx.is_process_running('ofonod'):
@@ -63,9 +55,13 @@ class Test(unittest.TestCase):
IWD.copy_to_storage('ssidEAP-SIM.8021x')
+ cls.auth = AuthCenter('/tmp/hlrauc.sock', '/tmp/sim.db')
+
@classmethod
def tearDownClass(cls):
IWD.clear_storage()
+ cls.auth.stop()
+
if __name__ == '__main__':
unittest.main(exit=True)