From 1d707647a5068eed20d42b236aaf987e1c4623c6 Mon Sep 17 00:00:00 2001
From: lukken <lukken@astron.nl>
Date: Thu, 19 Aug 2021 17:01:06 +0000
Subject: [PATCH] L2SS-240: Test if we can enable SDP and APSCT devices

---
 .../devices/test_device_apsct.py              | 36 +++++++++++++++++++
 .../devices/test_device_sdp.py                | 35 ++++++++++++++++++
 2 files changed, 71 insertions(+)

diff --git a/devices/integration_test/devices/test_device_apsct.py b/devices/integration_test/devices/test_device_apsct.py
index f26bdd26e..8d2d384b7 100644
--- a/devices/integration_test/devices/test_device_apsct.py
+++ b/devices/integration_test/devices/test_device_apsct.py
@@ -7,6 +7,8 @@
 # Distributed under the terms of the APACHE license.
 # See LICENSE.txt for more info.
 
+import time
+
 from tango import DeviceProxy
 from tango._tango import DevState
 
@@ -18,6 +20,16 @@ class TestDeviceAPSCT(base.IntegrationTestCase):
     def setUp(self):
         super(TestDeviceAPSCT, self).setUp()
 
+    def tearDown(self):
+        """Turn device Off in teardown to prevent blocking tests"""
+        d = DeviceProxy("LTS/PCC/1")
+
+        try:
+            d.Off()
+        except Exception as e:
+            """Failing to turn Off devices should not raise errors here"""
+            print("Failed to turn device off in teardown %s" % e)
+
     def test_device_proxy_apsct(self):
         """Test if we can successfully create a DeviceProxy and fetch state"""
 
@@ -25,3 +37,27 @@ class TestDeviceAPSCT(base.IntegrationTestCase):
         d = DeviceProxy("LTS/PCC/1")
 
         self.assertEqual(DevState.OFF, d.state())
+
+    def test_device_apsct_initialize(self):
+        """Test if we can transition to standby"""
+
+        # TODO(Corne): Change name to APSCT once ready
+        d = DeviceProxy("LTS/PCC/1")
+
+        d.initialise()
+        time.sleep(1)
+
+        self.assertEqual(DevState.STANDBY, d.state())
+
+    def test_device_apsct_on(self):
+        """Test if we can transition to on"""
+
+        # TODO(Corne): Change name to APSCT once ready
+        d = DeviceProxy("LTS/PCC/1")
+
+        d.initialise()
+        time.sleep(1)
+
+        d.on()
+
+        self.assertEqual(DevState.ON, d.state())
diff --git a/devices/integration_test/devices/test_device_sdp.py b/devices/integration_test/devices/test_device_sdp.py
index 89a30acca..040df6c10 100644
--- a/devices/integration_test/devices/test_device_sdp.py
+++ b/devices/integration_test/devices/test_device_sdp.py
@@ -7,6 +7,8 @@
 # Distributed under the terms of the APACHE license.
 # See LICENSE.txt for more info.
 
+import time
+
 from tango import DeviceProxy
 from tango._tango import DevState
 
@@ -16,11 +18,44 @@ from integration_test import base
 class TestDeviceSDP(base.IntegrationTestCase):
 
     def setUp(self):
+        """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 = DeviceProxy("LTS/SDP/1")
+
+        try:
+            d.Off()
+        except Exception as e:
+            """Failing to turn Off devices should not raise errors here"""
+            print("Failed to turn device off in teardown %s" % e)
+
     def test_device_proxy_sdp(self):
         """Test if we can successfully create a DeviceProxy and fetch state"""
 
         d = DeviceProxy("LTS/SDP/1")
 
         self.assertEqual(DevState.OFF, d.state())
+
+    def test_device_sdp_initialize(self):
+        """Test if we can transition to standby"""
+
+        d = DeviceProxy("LTS/SDP/1")
+
+        d.initialise()
+        time.sleep(1)
+
+        self.assertEqual(DevState.STANDBY, d.state())
+
+    def test_device_sdp_on(self):
+        """Test if we can transition to on"""
+
+        d = DeviceProxy("LTS/SDP/1")
+
+        d.initialise()
+        time.sleep(1)
+
+        d.on()
+
+        self.assertEqual(DevState.ON, d.state())
-- 
GitLab