mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-21 03:32:42 +01:00
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.
This commit is contained in:
parent
45dd5d2f7c
commit
d4e27b8ee2
@ -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
|
||||
|
||||
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)
|
||||
|
@ -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
|
||||
|
||||
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)
|
||||
|
@ -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
|
||||
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user