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

L2SS-705: Add test for read_attribute

parent 19fce86c
No related branches found
No related tags found
1 merge request!274L2SS-705: Read values directly from the hardware instead of through the proxy
# -*- coding: utf-8 -*-
#
# This file is part of the LOFAR 2.0 Station Software
#
#
#
# Distributed under the terms of the APACHE license.
# See LICENSE.txt for more info.
from tango.test_context import DeviceTestContext
from tango.server import attribute
from tangostationcontrol.devices import lofar_device
import mock
from tangostationcontrol.test import base
class TestLofarDevice(base.TestCase):
def setUp(self):
super(TestLofarDevice, self).setUp()
# Patch DeviceProxy to allow making the proxies during initialisation
# that we otherwise avoid using
for device in [lofar_device]:
proxy_patcher = mock.patch.object(
device, 'DeviceProxy')
proxy_patcher.start()
self.addCleanup(proxy_patcher.stop)
def test_read_attribute(self):
""" Test whether read_attribute really returns the attribute. """
class MyLofarDevice(lofar_device.lofar_device):
@attribute(dtype=float)
def A(self):
return 42.0
@attribute(dtype=float)
def read_attribute_A(self):
return self.read_attribute("A")
@attribute(dtype=(float,), max_dim_x=2)
def B_array(self):
return [42.0, 43.0]
@attribute(dtype=(float,), max_dim_x=2)
def read_attribute_B_array(self):
return self.read_attribute("B_array")
with DeviceTestContext(MyLofarDevice, process=True, timeout=10) as proxy:
proxy.initialise()
self.assertEqual(42.0, proxy.read_attribute_A)
self.assertListEqual([42.0, 43.0], proxy.read_attribute_B_array.tolist())
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment