Skip to content
Snippets Groups Projects
Commit 634e66c8 authored by Jan David Mol's avatar Jan David Mol
Browse files

L2SS-480: Mock the DeviceProxy in unit tests, as they do not work in the...

L2SS-480: Mock the DeviceProxy in unit tests, as they do not work in the DeviceTestContext and we avoid using them anyway.
parent aab40872
No related branches found
No related tags found
1 merge request!220Resolve L2SS-480 "Delays to beam weights"
...@@ -59,8 +59,6 @@ class Beam(lofar_device): ...@@ -59,8 +59,6 @@ class Beam(lofar_device):
dtype=(numpy.double,), max_dim_x=96, dtype=(numpy.double,), max_dim_x=96,
fget=lambda self: self._hbat_pointing_timestamp) fget=lambda self: self._hbat_pointing_timestamp)
RECV_name = 'stat/recv/1'
# Directory where the casacore measures that we use, reside. We configure ~/.casarc to # Directory where the casacore measures that we use, reside. We configure ~/.casarc to
# use the symlink /opt/IERS/current, which we switch to the actual set of files to use. # use the symlink /opt/IERS/current, which we switch to the actual set of files to use.
measures_directory_R = attribute(dtype=str, access=AttrWriteType.READ, fget = lambda self: get_measures_directory()) measures_directory_R = attribute(dtype=str, access=AttrWriteType.READ, fget = lambda self: get_measures_directory())
...@@ -73,13 +71,11 @@ class Beam(lofar_device): ...@@ -73,13 +71,11 @@ class Beam(lofar_device):
# -------- # --------
@log_exceptions() @log_exceptions()
def configure_for_initialise(self): def configure_for_initialise(self):
# Set a reference of RECV device
try:
self.recv_proxy = DeviceProxy(self.RECV_name)
except:
logger.warning("RECV device offline") # avoid error raising in unittest
super().configure_for_initialise() super().configure_for_initialise()
# Set a reference of RECV device
self.recv_proxy = DeviceProxy("STAT/RECV/1")
# -------- # --------
# internal functions # internal functions
# -------- # --------
......
...@@ -31,6 +31,13 @@ class TestBeamDevice(base.TestCase): ...@@ -31,6 +31,13 @@ class TestBeamDevice(base.TestCase):
beam.Beam, 'init_device', spec=beam.Beam.init_device) beam.Beam, 'init_device', spec=beam.Beam.init_device)
self.m_init = init_patcher.start() self.m_init = init_patcher.start()
self.addCleanup(init_patcher.stop) self.addCleanup(init_patcher.stop)
# Patch DeviceProxy to allow making the proxies during initialisation
# that we otherwise avoid using
proxy_patcher = mock.patch.object(
beam, 'DeviceProxy')
self.m_init = proxy_patcher.start()
self.addCleanup(proxy_patcher.stop)
def test_get_pointing_directions(self): def test_get_pointing_directions(self):
"""Verify can read pointings attribute and length matches without err""" """Verify can read pointings attribute and length matches without err"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment