Skip to content
Snippets Groups Projects
Commit 10b3866d authored by Corné Lukken's avatar Corné Lukken
Browse files

L2SS-205: Dry method to perform device turn off

Closes-Bug: L2SS-493
parent 83bab814
Branches
No related tags found
1 merge request!183Docker image building & pushing with CI pipeline caching
import time
from tango import DeviceProxy
......@@ -6,3 +8,15 @@ class TestDeviceProxy(DeviceProxy):
def __init__(self, *args, **kwargs):
super(TestDeviceProxy, self).__init__(*args, **kwargs)
self.set_timeout_millis(10000)
@staticmethod
def test_device_turn_off(endpoint):
d = TestDeviceProxy(endpoint)
try:
d.Off()
except Exception as e:
"""Failing to turn Off devices should not raise errors here"""
print(f"Failed to turn device off in teardown {e}")
"""Wait for 1 second to prevent propagating reconnection errors"""
time.sleep(1)
......@@ -7,6 +7,8 @@
# Distributed under the terms of the APACHE license.
# See LICENSE.txt for more info.
import time
from tango._tango import DevState
from tangostationcontrol.integration_test.device_proxy import TestDeviceProxy
......@@ -18,15 +20,7 @@ class TestDeviceRECV(base.IntegrationTestCase):
def setUp(self):
super(TestDeviceRECV, self).setUp()
def tearDown(self):
"""Turn device Off in teardown to prevent blocking tests"""
d = TestDeviceProxy("STAT/RECV/1")
try:
d.Off()
except Exception as e:
"""Failing to turn Off devices should not raise errors here"""
print(f"Failed to turn device off in teardown {e}")
self.addCleanup(TestDeviceProxy.test_device_turn_off, "STAT/RECV/1")
def test_device_proxy_recv(self):
"""Test if we can successfully create a DeviceProxy and fetch state"""
......
......@@ -7,7 +7,8 @@
# Distributed under the terms of the APACHE license.
# See LICENSE.txt for more info.
from tango import DeviceProxy
import time
from tango._tango import DevState
from tangostationcontrol.integration_test.device_proxy import TestDeviceProxy
......@@ -20,15 +21,7 @@ class TestDeviceSDP(base.IntegrationTestCase):
"""Intentionally recreate the device object in each test"""
super(TestDeviceSDP, self).setUp()
def tearDown(self):
"""Turn device Off in teardown to prevent blocking tests"""
d = TestDeviceProxy("STAT/SDP/1")
try:
d.Off()
except Exception as e:
"""Failing to turn Off devices should not raise errors here"""
print(f"Failed to turn device off in teardown {e}")
self.addCleanup(TestDeviceProxy.test_device_turn_off, "STAT/SDP/1")
def test_device_proxy_sdp(self):
"""Test if we can successfully create a DeviceProxy and fetch state"""
......
......@@ -22,15 +22,7 @@ class TestDeviceSST(base.IntegrationTestCase):
"""Intentionally recreate the device object in each test"""
super(TestDeviceSST, self).setUp()
def tearDown(self):
"""Turn device Off in teardown to prevent blocking tests"""
d = TestDeviceProxy("STAT/SST/1")
try:
d.Off()
except Exception as e:
"""Failing to turn Off devices should not raise errors here"""
print(f"Failed to turn device off in teardown {e}")
self.addCleanup(TestDeviceProxy.test_device_turn_off, "STAT/SST/1")
def test_device_proxy_sst(self):
"""Test if we can successfully create a DeviceProxy and fetch state"""
......
......@@ -19,15 +19,7 @@ class TestDeviceUNB2(base.IntegrationTestCase):
"""Intentionally recreate the device object in each test"""
super(TestDeviceUNB2, self).setUp()
def tearDown(self):
"""Turn device Off in teardown to prevent blocking tests"""
d = TestDeviceProxy("STAT/UNB2/1")
try:
d.Off()
except Exception as e:
"""Failing to turn Off devices should not raise errors here"""
print(f"Failed to turn device off in teardown {e}")
self.addCleanup(TestDeviceProxy.test_device_turn_off, "STAT/UNB2/1")
def test_device_proxy_unb2(self):
"""Test if we can successfully create a DeviceProxy and fetch state"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment