From 21a00c45e0866a4bb0d6ca83bda833e836aa7bd5 Mon Sep 17 00:00:00 2001 From: stedif <stefano.difrischia@inaf.it> Date: Thu, 3 Feb 2022 14:53:43 +0100 Subject: [PATCH] L2SS-574: fix recv unit test --- .../devices/test_device_beam.py | 24 +++++++++++++++++++ .../test/devices/test_beam_device.py | 1 - .../test/devices/test_recv_device.py | 15 ++++++++++-- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/tangostationcontrol/tangostationcontrol/integration_test/devices/test_device_beam.py b/tangostationcontrol/tangostationcontrol/integration_test/devices/test_device_beam.py index 19b578a75..6c403d98c 100644 --- a/tangostationcontrol/tangostationcontrol/integration_test/devices/test_device_beam.py +++ b/tangostationcontrol/tangostationcontrol/integration_test/devices/test_device_beam.py @@ -9,6 +9,7 @@ import time import numpy +from tango import DevState from tangostationcontrol.integration_test.device_proxy import TestDeviceProxy from .base import AbstractTestBases @@ -18,6 +19,29 @@ class TestDeviceBeam(AbstractTestBases.TestDeviceBase): def setUp(self): super().setUp("STAT/Beam/1") + def test_HBAT_delays_dims(self): + """Verify HBAT delays are retrieved with correct dimensions""" + + # setup RECV + recv_proxy = TestDeviceProxy("STAT/RECV/1") + recv_proxy.off() + recv_proxy.initialise() + recv_proxy.set_defaults() + recv_proxy.on() + + # setup BEAM + self.proxy.init() + self.proxy.Initialise() + self.self.assertEqual(DevState.STANDBY, self.proxy.state()) + self.proxy.set_defaults() + self.proxy.on() + self.self.assertEqual(DevState.ON, self.proxy.state()) + + # verify HBAT_delays method returns the correct dimensions + pointing_direction = numpy.array([["J2000","0deg","0deg"]] * 96).flatten() + HBAT_delays = self.proxy.HBAT_delays(pointing_direction) + self.assertEqual(1536, len(HBAT_delays)) # 96*16 + def test_write_HBAT_delays(self): """ Test whether the delay values are correctly saved into the relative RECV attribute""" diff --git a/tangostationcontrol/tangostationcontrol/test/devices/test_beam_device.py b/tangostationcontrol/tangostationcontrol/test/devices/test_beam_device.py index d5a1b701d..9c559a69a 100644 --- a/tangostationcontrol/tangostationcontrol/test/devices/test_beam_device.py +++ b/tangostationcontrol/tangostationcontrol/test/devices/test_beam_device.py @@ -36,7 +36,6 @@ class TestBeamDevice(base.TestCase): def test_get_pointing_timestamps(self): """Verify can read timestamps attribute and length matches without err""" - with DeviceTestContext(beam.Beam, process=True) as proxy: self.assertEqual(96, len(proxy.read_attribute( "HBAT_pointing_timestamp_R").value)) diff --git a/tangostationcontrol/tangostationcontrol/test/devices/test_recv_device.py b/tangostationcontrol/tangostationcontrol/test/devices/test_recv_device.py index 519b80944..f918f5e65 100644 --- a/tangostationcontrol/tangostationcontrol/test/devices/test_recv_device.py +++ b/tangostationcontrol/tangostationcontrol/test/devices/test_recv_device.py @@ -8,8 +8,9 @@ # See LICENSE.txt for more info. from tango.test_context import DeviceTestContext +from tango import DeviceProxy -from tangostationcontrol.devices import recv, opcua_device, lofar_device +from tangostationcontrol.devices import recv, lofar_device import mock @@ -24,28 +25,38 @@ class TestRecvDevice(base.TestCase): # Patch DeviceProxy to allow making the proxies during initialisation # that we otherwise avoid using - for device in [recv, opcua_device, lofar_device]: + for device in [lofar_device]: proxy_patcher = mock.patch.object( device, 'DeviceProxy') proxy_patcher.start() self.addCleanup(proxy_patcher.stop) + + def init_device(self, proxy:DeviceProxy): + proxy.off() + proxy.initialise() + proxy.set_defaults() + proxy.on() def test_get_hbat_bf_delay_step_delays(self): """Verify can read delay step attribute and length matches without err""" with DeviceTestContext(recv.RECV, properties=self.recv_properties, process=True) as proxy: + self.init_device(proxy) self.assertEqual(32, len(proxy.get_hbat_bf_delay_step_delays())) def test_get_hbat_reference_itrf(self): """Verify can read hbat reference itrf attribute and length matches without err""" with DeviceTestContext(recv.RECV, properties=self.recv_properties, process=True) as proxy: + self.init_device(proxy) self.assertEqual(288, len(proxy.get_hbat_reference_itrf())) # 96x3=288 def test_get_hbat_antenna_itrf(self): """Verify can read hbat antenna itrf attribute and length matches without err""" with DeviceTestContext(recv.RECV, properties=self.recv_properties, process=True) as proxy: + self.init_device(proxy) self.assertEqual(4608, len(proxy.get_hbat_antenna_itrf())) # 96x16X3=4608 def test_get_hbat_signal_input_delays(self): """Verify can read signal input delay attribute and length matches without err""" with DeviceTestContext(recv.RECV, properties=self.recv_properties, process=True) as proxy: + self.init_device(proxy) self.assertEqual(3072, len(proxy.get_hbat_signal_input_delays())) # 96x32=3072 -- GitLab