From 847accb6475f36a4d0c06e2a3e0ad9e39b8b435e Mon Sep 17 00:00:00 2001
From: SKAJohanVenter <aventer@ska.ac.za>
Date: Mon, 25 Oct 2021 19:17:05 +0200
Subject: [PATCH] SAR-288 Changed isCapabilityAchievable to long running

---
 src/ska_tango_base/base/base_device.py  |  8 ++++----
 src/ska_tango_base/controller_device.py | 10 ++++++----
 tests/test_controller_device.py         |  9 +++++++--
 3 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/src/ska_tango_base/base/base_device.py b/src/ska_tango_base/base/base_device.py
index 68345970..ef2d9e28 100644
--- a/src/ska_tango_base/base/base_device.py
+++ b/src/ska_tango_base/base/base_device.py
@@ -1184,7 +1184,7 @@ class SKABaseDevice(Device):
 
     @command(
         dtype_out="DevVarLongStringArray",
-        doc_out="(ReturnType, 'Command unique ID')",
+        doc_out="(ResultCode, 'Command unique ID')",
     )
     @DebugIt()
     def GetVersionInfo(self):
@@ -1195,11 +1195,11 @@ class SKABaseDevice(Device):
         To modify behaviour for this command, modify the do() method of
         the command class.
 
-        :return: Version details of the device.
+        :return: The result code and the command unique ID
         """
         command = self.get_command_object("GetVersionInfo")
-        unique_id, return_code = self.component_manager.enqueue(command)
-        return [[return_code], [unique_id]]
+        unique_id, result_code = self.component_manager.enqueue(command)
+        return [[result_code], [unique_id]]
         # PROTECTED REGION END #    //  SKABaseDevice.GetVersionInfo
 
     class ResetCommand(StateModelCommand, ResponseCommand):
diff --git a/src/ska_tango_base/controller_device.py b/src/ska_tango_base/controller_device.py
index a4401208..a390d9a1 100644
--- a/src/ska_tango_base/controller_device.py
+++ b/src/ska_tango_base/controller_device.py
@@ -240,7 +240,8 @@ class SKAController(SKABaseDevice):
     @command(
         dtype_in="DevVarLongStringArray",
         doc_in="[nrInstances][Capability types]",
-        dtype_out="bool",
+        dtype_out="DevVarLongStringArray",
+        doc_out="(ResultCode, 'Command unique ID')",
     )
     @DebugIt()
     def isCapabilityAchievable(self, argin):
@@ -258,11 +259,12 @@ class SKAController(SKABaseDevice):
 
         :type argin: :py:class:`tango.DevVarLongStringArray`.
 
-        :return: True if capability can be achieved, False if cannot
-        :rtype: DevBoolean
+        :return: result_code, unique_id
+        :rtype: DevVarLongStringArray
         """
         command = self.get_command_object("IsCapabilityAchievable")
-        return command(argin)
+        unique_id, result_code = self.component_manager.enqueue(command, argin)
+        return [[result_code], [unique_id]]
         # PROTECTED REGION END #    //  SKAController.isCapabilityAchievable
 
 
diff --git a/tests/test_controller_device.py b/tests/test_controller_device.py
index 8173ddd5..981a1d03 100644
--- a/tests/test_controller_device.py
+++ b/tests/test_controller_device.py
@@ -108,7 +108,10 @@ class TestSKAController(object):
     def test_isCapabilityAchievable_failure(self, device_under_test):
         """Test for isCapabilityAchievable to test failure condition."""
         # PROTECTED REGION ID(SKAController.test_isCapabilityAchievable_failure) ENABLED START #
-        assert device_under_test.isCapabilityAchievable([[2], ["BAND1"]]) is False
+        device_under_test.isCapabilityAchievable([[2], ["BAND1"]])
+        capability_achievalble = device_under_test.longRunningCommandResult[2]
+        assert capability_achievalble == "False"
+        # assert device_under_test.isCapabilityAchievable([[2], ["BAND1"]]) is False
         # PROTECTED REGION END #    //  SKAController.test_isCapabilityAchievable_failure
 
         # PROTECTED REGION ID(SKAController.test_isCapabilityAchievable_success_decorators) ENABLED START #
@@ -117,7 +120,9 @@ class TestSKAController(object):
     def test_isCapabilityAchievable_success(self, device_under_test):
         """Test for isCapabilityAchievable to test success condition."""
         # PROTECTED REGION ID(SKAController.test_isCapabilityAchievable_success) ENABLED START #
-        assert device_under_test.isCapabilityAchievable([[1], ["BAND1"]]) is True
+        device_under_test.isCapabilityAchievable([[1], ["BAND1"]])
+        capability_achievalble = device_under_test.longRunningCommandResult[2]
+        assert capability_achievalble == "True"
         # PROTECTED REGION END #    //  SKAController.test_isCapabilityAchievable_success
 
     # PROTECTED REGION ID(SKAController.test_elementLoggerAddress_decorators) ENABLED START #
-- 
GitLab