diff --git a/src/ska_tango_base/base/base_device.py b/src/ska_tango_base/base/base_device.py index 6bbfc93a56c54de9fd33a2516e6bfee69c7b05b0..b9c904d174bb8e225bb9a07edfa3f3a8fd5766cc 100644 --- a/src/ska_tango_base/base/base_device.py +++ b/src/ska_tango_base/base/base_device.py @@ -1197,8 +1197,8 @@ class SKABaseDevice(Device): :return: The result code and the command unique ID """ - command = self.get_command_object("GetVersionInfo") - unique_id, result_code = self.component_manager.enqueue(command) + handler = self.get_command_object("GetVersionInfo") + unique_id, result_code = self.component_manager.enqueue(handler) return [[result_code], [unique_id]] # PROTECTED REGION END # // SKABaseDevice.GetVersionInfo @@ -1254,8 +1254,8 @@ class SKABaseDevice(Device): information purpose only. :rtype: (ResultCode, str) """ - command = self.get_command_object("Reset") - unique_id, return_code = self.component_manager.enqueue(command) + handler = self.get_command_object("Reset") + unique_id, return_code = self.component_manager.enqueue(handler) return [[return_code], [unique_id]] @@ -1311,8 +1311,8 @@ class SKABaseDevice(Device): information purpose only. :rtype: (ResultCode, str) """ - command = self.get_command_object("Standby") - unique_id, return_code = self.component_manager.enqueue(command) + handler = self.get_command_object("Standby") + unique_id, return_code = self.component_manager.enqueue(handler) return [[return_code], [unique_id]] @@ -1368,8 +1368,8 @@ class SKABaseDevice(Device): information purpose only. :rtype: (ResultCode, str) """ - command = self.get_command_object("Off") - unique_id, return_code = self.component_manager.enqueue(command) + handler = self.get_command_object("Off") + unique_id, return_code = self.component_manager.enqueue(handler) return [[return_code], [unique_id]] @@ -1425,8 +1425,8 @@ class SKABaseDevice(Device): information purpose only. :rtype: (ResultCode, str) """ - command = self.get_command_object("On") - unique_id, return_code = self.component_manager.enqueue(command) + handler = self.get_command_object("On") + unique_id, return_code = self.component_manager.enqueue(handler) return [[return_code], [unique_id]] @@ -1460,8 +1460,8 @@ class SKABaseDevice(Device): @DebugIt() def AbortCommands(self): """Empty out long running commands in queue.""" - command = self.get_command_object("AbortCommands") - (return_code, message) = command() + handler = self.get_command_object("AbortCommands") + (return_code, message) = handler() return [[return_code], [message]] class CheckLongRunningCommandStatusCommand(ResponseCommand): @@ -1503,8 +1503,8 @@ class SKABaseDevice(Device): @DebugIt() def CheckLongRunningCommandStatus(self, argin): """Check the status of a long running command by ID.""" - command = self.get_command_object("CheckLongRunningCommandStatus") - (return_code, command_state) = command(argin) + handler = self.get_command_object("CheckLongRunningCommandStatus") + (return_code, command_state) = handler(argin) return [[return_code], [command_state]] class DebugDeviceCommand(BaseCommand): diff --git a/src/ska_tango_base/base/task_queue_manager.py b/src/ska_tango_base/base/task_queue_manager.py index dc4a384902ea53e0b24b8d5ee167b968a36a2b9f..1c56b9657e37e55bebab0b8b7309440850aba689 100644 --- a/src/ska_tango_base/base/task_queue_manager.py +++ b/src/ska_tango_base/base/task_queue_manager.py @@ -112,6 +112,7 @@ import logging import threading import time import traceback +import numpy from uuid import uuid4 from queue import Empty, Queue from datetime import datetime @@ -240,16 +241,22 @@ class TaskResult: raise ValueError(f"Cannot parse task_result {task_result}") return TaskResult( - result_code=ResultCode(int(task_result[1])), + result_code=ResultCode(int(task_result[1])) + if task_result[1] + else ResultCode.UNKNOWN, task_result=task_result[2], unique_id=task_result[0], ) @classmethod - def from_response_command(cls, command_result: Tuple[str, str]) -> TaskResult: + def from_response_command( + cls, command_result: Union[Tuple[str, str], numpy.ndarray] + ) -> TaskResult: """Convert from ResponseCommand to TaskResult. - :param command_result: The task_result (unique_id, result_code) + Either from (str, str) or DevVarLongStringArray + + :param command_result: Either (unique_id, result_code) or numpy.ndarray [[result_code], [unique_id]] :type command_result: tuple :return: The task result :rtype: TaskResult @@ -258,11 +265,18 @@ class TaskResult: if not command_result or len(command_result) != 2: raise ValueError(f"Cannot parse task_result {command_result}") - return TaskResult( - result_code=ResultCode(int(command_result[1])), - task_result="", - unique_id=command_result[0], - ) + if isinstance(command_result[0], str): + return TaskResult( + result_code=ResultCode(int(command_result[1])), + task_result="", + unique_id=command_result[0], + ) + else: + return TaskResult( + result_code=ResultCode(command_result[0][0]), + task_result="", + unique_id=command_result[1][0], + ) def get_task_unique_id(self) -> TaskUniqueId: """Convert from the unique_id string to TaskUniqueId.""" @@ -448,7 +462,7 @@ class QueueManager: self._property_update_lock = threading.Lock() self._logger = logger if logger else logging.getLogger(__name__) - self._task_result: Union[Tuple[str, str, str], Tuple[()]] = () + self._task_result: Tuple[str, str, str] = ("", "", "") self._tasks_in_queue: Dict[str, str] = {} # unique_id, task_name self._task_status: Dict[str, str] = {} # unique_id, status self._threads = [] diff --git a/src/ska_tango_base/subarray/reference_component_manager.py b/src/ska_tango_base/subarray/reference_component_manager.py index a878aadc2f5bb6afe055abfb567519d77cd400d5..013b0069e02fad13a88f2ed87017f4fac6996dbc 100644 --- a/src/ska_tango_base/subarray/reference_component_manager.py +++ b/src/ska_tango_base/subarray/reference_component_manager.py @@ -1,5 +1,6 @@ """This module models component management for SKA subarray devices.""" import functools +from ska_tango_base.base.task_queue_manager import QueueManager from ska_tango_base.subarray import SubarrayComponentManager from ska_tango_base.base import ( @@ -421,6 +422,9 @@ class ReferenceSubarrayComponentManager( capability_types, logger=None, _component=None, + max_queue_size=0, + num_workers=0, + push_change_event=None, ): """ Initialise a new ReferenceSubarrayComponentManager instance. @@ -434,9 +438,15 @@ class ReferenceSubarrayComponentManager( :param logger: a logger for this component manager :param _component: allows setting of the component to be managed; for testing purposes only + :param max_queue_size: The size of the QueueManager queue + :param num_workers: The number of QueueManager workers + :param push_change_event: Function to call to push change events """ self.obs_state_model = obs_state_model self._resource_pool = self._ResourcePool(self.component_resourced) + self._max_queue_size = max_queue_size + self._num_workers = num_workers + self._push_change_event = push_change_event super().__init__( op_state_model, @@ -649,3 +659,16 @@ class ReferenceSubarrayComponentManager( This is a callback hook. """ self.obs_state_model.perform_action("component_obsfault") + + def create_queue_manager(self) -> QueueManager: + """Create a Queue Manager. + + :return: The queue manager + :rtype: QueueManager + """ + return QueueManager( + num_workers=self._num_workers, + max_queue_size=self._max_queue_size, + logger=self.logger, + push_change_event=self._push_change_event, + ) diff --git a/src/ska_tango_base/subarray/subarray_device.py b/src/ska_tango_base/subarray/subarray_device.py index a093e8f3cac0965f1ba0d8253e49784a33580f7d..20e09ea9f9b26e6b99b29eb7504fe178cc0bb0f8 100644 --- a/src/ska_tango_base/subarray/subarray_device.py +++ b/src/ska_tango_base/subarray/subarray_device.py @@ -637,17 +637,6 @@ class SKASubarray(SKAObsDevice): # -------- # Commands # -------- - - def is_AssignResources_allowed(self): - """ - Check if command `AssignResources` is allowed in the current device state. - - :return: ``True`` if the command is allowed - :rtype: boolean - """ - command = self.get_command_object("AssignResources") - return command.is_allowed(raise_if_disallowed=True) - @command( dtype_in="DevString", doc_in="JSON-encoded string with the resources to add to subarray", @@ -670,10 +659,10 @@ class SKASubarray(SKAObsDevice): information purpose only. :rtype: (ResultCode, str) """ - command = self.get_command_object("AssignResources") + handler = self.get_command_object("AssignResources") args = json.loads(argin) - (return_code, message) = command(args) - return [[return_code], [message]] + unique_id, return_code = self.component_manager.enqueue(handler, args) + return [[return_code], [unique_id]] def is_ReleaseResources_allowed(self): """ diff --git a/tests/conftest.py b/tests/conftest.py index 87da31a373856fb5f6d1386c7c37e005b5af2c31..21fe0dae50d5e6000bc8500b8aade1f223aae8a1 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,18 +1,22 @@ """This module defines elements of the pytest test harness shared by all tests.""" import logging from queue import Empty, Queue +from unittest import mock import pytest from tango import EventType from tango.test_context import DeviceTestContext +from ska_tango_base.base.task_queue_manager import TaskResult +from ska_tango_base.commands import ResultCode + @pytest.fixture(scope="class") def device_properties(): """ Fixture that returns device_properties to be provided to the device under test. - This is a default implementiong that provides no properties. + This is a default implementation that provides no properties. """ return {} @@ -24,10 +28,27 @@ def tango_context(device_test_config): if component_manager_patch is not None: device_test_config["device"].create_component_manager = component_manager_patch - tango_context = DeviceTestContext(**device_test_config) - tango_context.start() - yield tango_context - tango_context.stop() + def _get_command_func(dp, cmd_info, name): + """Patch __get_command_func so that we can return a TaskResult if applicable.""" + _, doc = cmd_info + + def f(*args, **kwds): + result = dp.command_inout(name, *args, **kwds) + if isinstance(result, list): + if len(result) == 2: + if len(result[0]) == 1 and len(result[1]) == 1: + if result[0][0] == ResultCode.QUEUED: + return TaskResult.from_response_command(result) + return result + + f.__doc__ = doc + return f + + with mock.patch("tango.device_proxy.__get_command_func", _get_command_func): + tango_context = DeviceTestContext(**device_test_config) + tango_context.start() + yield tango_context + tango_context.stop() @pytest.fixture() @@ -122,6 +143,7 @@ def tango_change_event_helper(device_under_test): self._value = None self._values_queue = Queue() self._errors = [] + self._attribute_name = attribute_name # Subscription will result in an immediate # synchronous callback with the current value, @@ -212,6 +234,21 @@ def tango_change_event_helper(device_under_test): for value in values: self.assert_call(value) + def wait_for_lrc_id(self, unique_id: str): + """Wait for the longRunningCommandResult unique ID to be the same as the parameter. + + :param unique_id: The long running command unique ID + :type unique_id: str + """ + assert ( + self._attribute_name == "longRunningCommandResult" + ), "Method only available for longRunningCommandResult" + while True: + next_val = self._next() + assert next_val, "No more events" + if unique_id == next_val[0]: + break + yield _Callback diff --git a/tests/long_running_tasks/test_multi_device.py b/tests/long_running_tasks/test_multi_device.py index 01ab65638defc952c87209dd72882ea41894628d..5025fe24dc8aae9bb98d53be1f0c917097c8b8bb 100644 --- a/tests/long_running_tasks/test_multi_device.py +++ b/tests/long_running_tasks/test_multi_device.py @@ -210,7 +210,9 @@ class TestMultiDevice: events = [ i.attr_value.value for i in event_callback.get_events() - if i.attr_value and i.attr_value.value + if i.attr_value + and i.attr_value.value + and i.attr_value.value != ("", "", "") ] time.sleep(0.2) return events diff --git a/tests/long_running_tasks/test_reference_base_device.py b/tests/long_running_tasks/test_reference_base_device.py index 470c5e52ffb3e141009903367dbf266a18d5fa9b..96ebde7806b10a73acea0a6da66bd7f02bda7171 100644 --- a/tests/long_running_tasks/test_reference_base_device.py +++ b/tests/long_running_tasks/test_reference_base_device.py @@ -32,7 +32,7 @@ class TestCommands: with DeviceTestContext(class_name, process=True) as proxy: proxy.Short(1) # Wait for a result, if the task does not abort, we'll time out here - while not proxy.longRunningCommandResult: + while not any(proxy.longRunningCommandResult): time.sleep(0.1) result = TaskResult.from_task_result(proxy.longRunningCommandResult) @@ -47,7 +47,7 @@ class TestCommands: with DeviceTestContext(class_name, process=True) as proxy: proxy.NonAbortingLongRunning(0.01) # Wait for a result, if the task does not abort, we'll time out here - while not proxy.longRunningCommandResult: + while not any(proxy.longRunningCommandResult): time.sleep(0.1) result = TaskResult.from_task_result(proxy.longRunningCommandResult) assert result.result_code == ResultCode.OK @@ -72,7 +72,7 @@ class TestCommands: # Abort the tasks proxy.AbortCommands() # Wait for a result, if the task does not abort, we'll time out here - while not proxy.longRunningCommandResult: + while not any(proxy.longRunningCommandResult): time.sleep(0.1) result = TaskResult.from_task_result(proxy.longRunningCommandResult) assert result.unique_id == unique_id @@ -86,7 +86,7 @@ class TestCommands: for class_name in [BlockingBaseDevice, AsyncBaseDevice]: with DeviceTestContext(class_name, process=True) as proxy: unique_id, _ = proxy.LongRunningException() - while not proxy.longRunningCommandResult: + while not any(proxy.longRunningCommandResult): time.sleep(0.1) result = TaskResult.from_task_result(proxy.longRunningCommandResult) assert result.unique_id == unique_id @@ -104,7 +104,7 @@ def test_callbacks(): with DeviceTestContext(AsyncBaseDevice, process=False) as proxy: # Execute some commands proxy.TestProgress(0.5) - while not proxy.longRunningCommandResult: + while not any(proxy.longRunningCommandResult): time.sleep(0.1) assert my_cb.called @@ -185,7 +185,7 @@ def test_events(): proxy.TestProgress(0.2) # Wait for task to finish - while not proxy.longRunningCommandResult: + while not any(proxy.longRunningCommandResult): time.sleep(0.1) # Wait for progress events diff --git a/tests/long_running_tasks/test_task_queue_manager.py b/tests/long_running_tasks/test_task_queue_manager.py index f20b0e56df428ff6591fb4c31d8e4d26e692b659..bd26f59d5bb430b23ab38e0ec95754746c60a100 100644 --- a/tests/long_running_tasks/test_task_queue_manager.py +++ b/tests/long_running_tasks/test_task_queue_manager.py @@ -202,7 +202,7 @@ class TestQueueManagerTasks: exc_task = exc_task() qm.enqueue_task(add_task_one, 3) - while not qm.task_result: + while not any(qm.task_result): time.sleep(0.5) task_result = TaskResult.from_task_result(qm.task_result) assert task_result.unique_id.endswith("SimpleTask") @@ -274,7 +274,7 @@ class TestQueueManagerTasks: assert res.endswith(expected_name) # Wait for the task to be picked up - while not qm.task_result: + while not any(qm.task_result): time.sleep(0.5) assert qm.task_result[0].endswith(expected_name) assert int(qm.task_result[1]) == expected_result_code @@ -349,7 +349,7 @@ class TestQueueManagerTasks: """Test the QueueTask get state is completed.""" qm = QueueManager(max_queue_size=8, num_workers=2, logger=logger) unique_id_one, _ = qm.enqueue_task(simple_task(), 3) - while not qm.task_result: + while not any(qm.task_result): time.sleep(0.1) assert qm.get_task_state(unique_id=unique_id_one) == TaskState.COMPLETED diff --git a/tests/test_subarray_device.py b/tests/test_subarray_device.py index 420e4608ed7ba084114a018a3bbd70b39bbfccc9..c331816a1d6feb7dea9a4278b94e2dd730d126c5 100644 --- a/tests/test_subarray_device.py +++ b/tests/test_subarray_device.py @@ -66,6 +66,9 @@ class TestSKASubarray: self.obs_state_model, self.CapabilityTypes, logger=self.logger, + num_workers=1, + max_queue_size=5, + push_change_event=self.push_change_event, ), "properties": device_properties, "memorized": {"adminMode": str(AdminMode.ONLINE.value)}, @@ -84,8 +87,15 @@ class TestSKASubarray: """Test for Abort.""" # PROTECTED REGION ID(SKASubarray.test_Abort) ENABLED START # - device_under_test.On() - device_under_test.AssignResources(json.dumps(["BAND1"])) + result_callback = tango_change_event_helper.subscribe( + "longRunningCommandResult" + ) + + on_tr = device_under_test.On() + assign_tr = device_under_test.AssignResources(json.dumps(["BAND1"])) + result_callback.wait_for_lrc_id(on_tr.unique_id) + result_callback.wait_for_lrc_id(assign_tr.unique_id) + device_under_test.Configure('{"BAND1": 2}') obs_state_callback = tango_change_event_helper.subscribe("obsState") @@ -103,8 +113,14 @@ class TestSKASubarray: def test_Configure(self, device_under_test, tango_change_event_helper): """Test for Configure.""" # PROTECTED REGION ID(SKASubarray.test_Configure) ENABLED START # - device_under_test.On() - device_under_test.AssignResources(json.dumps(["BAND1"])) + result_callback = tango_change_event_helper.subscribe( + "longRunningCommandResult" + ) + + on_tr = device_under_test.On() + assign_tr = device_under_test.AssignResources(json.dumps(["BAND1"])) + result_callback.wait_for_lrc_id(on_tr.unique_id) + result_callback.wait_for_lrc_id(assign_tr.unique_id) obs_state_callback = tango_change_event_helper.subscribe("obsState") obs_state_callback.assert_call(ObsState.IDLE) @@ -118,14 +134,20 @@ class TestSKASubarray: # PROTECTED REGION ID(SKASubarray.test_GetVersionInfo_decorators) ENABLED START # # PROTECTED REGION END # // SKASubarray.test_GetVersionInfo_decorators - def test_GetVersionInfo(self, device_under_test): + def test_GetVersionInfo(self, device_under_test, tango_change_event_helper): """Test for GetVersionInfo.""" # PROTECTED REGION ID(SKASubarray.test_GetVersionInfo) ENABLED START # versionPattern = re.compile( f"['{device_under_test.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " "A set of generic base devices for SKA Telescope.']" ) - device_under_test.GetVersionInfo() + result_callback = tango_change_event_helper.subscribe( + "longRunningCommandResult" + ) + + ver_info_tr = device_under_test.GetVersionInfo() + result_callback.wait_for_lrc_id(ver_info_tr.unique_id) + versionInfo = device_under_test.longRunningCommandResult[2] assert (re.match(versionPattern, versionInfo)) is not None # PROTECTED REGION END # // SKASubarray.test_GetVersionInfo @@ -151,13 +173,20 @@ class TestSKASubarray: def test_AssignResources(self, device_under_test, tango_change_event_helper): """Test for AssignResources.""" # PROTECTED REGION ID(SKASubarray.test_AssignResources) ENABLED START # - device_under_test.On() + + result_callback = tango_change_event_helper.subscribe( + "longRunningCommandResult" + ) + + on_tr = device_under_test.On() + result_callback.wait_for_lrc_id(on_tr.unique_id) obs_state_callback = tango_change_event_helper.subscribe("obsState") obs_state_callback.assert_call(ObsState.EMPTY) resources_to_assign = ["BAND1", "BAND2"] - device_under_test.AssignResources(json.dumps(resources_to_assign)) + assign_tr = device_under_test.AssignResources(json.dumps(resources_to_assign)) + result_callback.wait_for_lrc_id(assign_tr.unique_id) obs_state_callback.assert_calls([ObsState.RESOURCING, ObsState.IDLE]) assert device_under_test.ObsState == ObsState.IDLE @@ -176,8 +205,15 @@ class TestSKASubarray: def test_End(self, device_under_test, tango_change_event_helper): """Test for EndSB.""" # PROTECTED REGION ID(SKASubarray.test_EndSB) ENABLED START # - device_under_test.On() - device_under_test.AssignResources(json.dumps(["BAND1"])) + result_callback = tango_change_event_helper.subscribe( + "longRunningCommandResult" + ) + + on_tr = device_under_test.On() + assign_tr = device_under_test.AssignResources(json.dumps(["BAND1"])) + result_callback.wait_for_lrc_id(on_tr.unique_id) + result_callback.wait_for_lrc_id(assign_tr.unique_id) + device_under_test.Configure('{"BAND1": 2}') obs_state_callback = tango_change_event_helper.subscribe("obsState") @@ -196,8 +232,15 @@ class TestSKASubarray: def test_EndScan(self, device_under_test, tango_change_event_helper): """Test for EndScan.""" # PROTECTED REGION ID(SKASubarray.test_EndScan) ENABLED START # - device_under_test.On() - device_under_test.AssignResources(json.dumps(["BAND1"])) + result_callback = tango_change_event_helper.subscribe( + "longRunningCommandResult" + ) + + on_tr = device_under_test.On() + assign_tr = device_under_test.AssignResources(json.dumps(["BAND1"])) + result_callback.wait_for_lrc_id(on_tr.unique_id) + result_callback.wait_for_lrc_id(assign_tr.unique_id) + device_under_test.Configure('{"BAND1": 2}') device_under_test.Scan('{"id": 123}') @@ -219,8 +262,14 @@ class TestSKASubarray: """Test for ReleaseAllResources.""" # PROTECTED REGION ID(SKASubarray.test_ReleaseAllResources) ENABLED START # # assert device_under_test.ReleaseAllResources() == [""] - device_under_test.On() - device_under_test.AssignResources(json.dumps(["BAND1", "BAND2"])) + result_callback = tango_change_event_helper.subscribe( + "longRunningCommandResult" + ) + + on_tr = device_under_test.On() + assign_tr = device_under_test.AssignResources(json.dumps(["BAND1", "BAND2"])) + result_callback.wait_for_lrc_id(on_tr.unique_id) + result_callback.wait_for_lrc_id(assign_tr.unique_id) obs_state_callback = tango_change_event_helper.subscribe("obsState") obs_state_callback.assert_call(ObsState.IDLE) @@ -236,8 +285,14 @@ class TestSKASubarray: def test_ReleaseResources(self, device_under_test, tango_change_event_helper): """Test for ReleaseResources.""" # PROTECTED REGION ID(SKASubarray.test_ReleaseResources) ENABLED START # - device_under_test.On() - device_under_test.AssignResources(json.dumps(["BAND1", "BAND2"])) + result_callback = tango_change_event_helper.subscribe( + "longRunningCommandResult" + ) + + on_tr = device_under_test.On() + assign_tr = device_under_test.AssignResources(json.dumps(["BAND1", "BAND2"])) + result_callback.wait_for_lrc_id(on_tr.unique_id) + result_callback.wait_for_lrc_id(assign_tr.unique_id) obs_state_callback = tango_change_event_helper.subscribe("obsState") obs_state_callback.assert_call(ObsState.IDLE) @@ -254,8 +309,15 @@ class TestSKASubarray: def test_ObsReset(self, device_under_test, tango_change_event_helper): """Test for Reset.""" # PROTECTED REGION ID(SKASubarray.test_Reset) ENABLED START # - device_under_test.On() - device_under_test.AssignResources(json.dumps(["BAND1"])) + result_callback = tango_change_event_helper.subscribe( + "longRunningCommandResult" + ) + + on_tr = device_under_test.On() + assign_tr = device_under_test.AssignResources(json.dumps(["BAND1"])) + result_callback.wait_for_lrc_id(on_tr.unique_id) + result_callback.wait_for_lrc_id(assign_tr.unique_id) + device_under_test.Configure('{"BAND1": 2}') device_under_test.Abort() @@ -276,8 +338,15 @@ class TestSKASubarray: def test_Scan(self, device_under_test, tango_change_event_helper): """Test for Scan.""" # PROTECTED REGION ID(SKASubarray.test_Scan) ENABLED START # - device_under_test.On() - device_under_test.AssignResources(json.dumps(["BAND1"])) + result_callback = tango_change_event_helper.subscribe( + "longRunningCommandResult" + ) + + on_tr = device_under_test.On() + assign_tr = device_under_test.AssignResources(json.dumps(["BAND1"])) + result_callback.wait_for_lrc_id(on_tr.unique_id) + result_callback.wait_for_lrc_id(assign_tr.unique_id) + device_under_test.Configure('{"BAND1": 2}') obs_state_callback = tango_change_event_helper.subscribe("obsState") @@ -417,19 +486,31 @@ class TestSKASubarray: # PROTECTED REGION ID(SKASubarray.test_assignedResources_decorators) ENABLED START # # PROTECTED REGION END # // SKASubarray.test_assignedResources_decorators - def test_assignedResources(self, device_under_test): + def test_assignedResources(self, device_under_test, tango_change_event_helper): """Test for assignedResources.""" # PROTECTED REGION ID(SKASubarray.test_assignedResources) ENABLED START # - device_under_test.On() + result_callback = tango_change_event_helper.subscribe( + "longRunningCommandResult" + ) + + on_tr = device_under_test.On() + result_callback.wait_for_lrc_id(on_tr.unique_id) + assert device_under_test.assignedResources is None # PROTECTED REGION END # // SKASubarray.test_assignedResources # PROTECTED REGION ID(SKASubarray.test_configuredCapabilities_decorators) ENABLED START # # PROTECTED REGION END # // SKASubarray.test_configuredCapabilities_decorators - def test_configuredCapabilities(self, device_under_test): + def test_configuredCapabilities(self, device_under_test, tango_change_event_helper): """Test for configuredCapabilities.""" # PROTECTED REGION ID(SKASubarray.test_configuredCapabilities) ENABLED START # - device_under_test.On() + result_callback = tango_change_event_helper.subscribe( + "longRunningCommandResult" + ) + + on_tr = device_under_test.On() + result_callback.wait_for_lrc_id(on_tr.unique_id) + assert device_under_test.configuredCapabilities == ("BAND1:0", "BAND2:0") # PROTECTED REGION END # // SKASubarray.test_configuredCapabilities