diff --git a/tangostationcontrol/tangostationcontrol/devices/abstract_device.py b/tangostationcontrol/tangostationcontrol/devices/abstract_device.py index 8250e4e481dc9d27ec88654b6fef777d0e9bc4e4..32b82052d8a55e8928deee6324b4616212f21a9a 100644 --- a/tangostationcontrol/tangostationcontrol/devices/abstract_device.py +++ b/tangostationcontrol/tangostationcontrol/devices/abstract_device.py @@ -19,10 +19,15 @@ from tango.server import DeviceMeta logger = logging.getLogger() -class AbstractDeviceMetas(DeviceMeta, ABCMeta): +# TODO(Corne): Fix combining metaclasses by iterating over their variables and +# methods. https://support.astron.nl/jira/browse/L2SS-551 +# class AbstractDeviceMetas(DeviceMeta, ABCMeta): +class AbstractDeviceMetas(DeviceMeta): """Collects meta classes to allow lofar_device to be both a Device and an ABC. """ def __new__(mcs, name, bases, namespace, **kwargs): - cls = ABCMeta.__new__(mcs, name, bases, namespace, **kwargs) - cls = DeviceMeta.__new__(type(cls), name, bases, namespace) + cls = DeviceMeta.__new__(mcs, name, bases, namespace, **kwargs) + # temp_cls = ABCMeta.__new__(mcs, name, bases, namespace) + # setattr(cls, '__abstractmethods__', temp_cls.__abstractmethods__) + # setattr(cls, '_abc_impl', temp_cls._abc_impl) return cls diff --git a/tangostationcontrol/tangostationcontrol/devices/sdp/statistics.py b/tangostationcontrol/tangostationcontrol/devices/sdp/statistics.py index 4b03f2db7848cf37d1b2d8ccacfcf0ac81e928cc..3bf6d8cc4f1881d6f15692b43d8367c6aa769769 100644 --- a/tangostationcontrol/tangostationcontrol/devices/sdp/statistics.py +++ b/tangostationcontrol/tangostationcontrol/devices/sdp/statistics.py @@ -11,7 +11,7 @@ """ -from abc import ABCMeta, abstractmethod +from abc import abstractmethod # PyTango imports from tango.server import device_property, attribute @@ -33,7 +33,9 @@ import numpy __all__ = ["Statistics"] -class Statistics(opcua_device, metaclass=ABCMeta): +# TODO(Corne): Make Statistics use ABCMeta again when L2SS-551 is fixed +# https://support.astron.nl/jira/browse/L2SS-551 +class Statistics(opcua_device): # In derived classes, set this to a subclass of StatisticsCollector @property diff --git a/tangostationcontrol/tangostationcontrol/integration_test/devices/base.py b/tangostationcontrol/tangostationcontrol/integration_test/devices/base.py index ef4854a8241aaee7e6099ae7d417d7b94acfa21e..3e6fa389a1739acce868fd098b91357979768d7f 100644 --- a/tangostationcontrol/tangostationcontrol/integration_test/devices/base.py +++ b/tangostationcontrol/tangostationcontrol/integration_test/devices/base.py @@ -12,6 +12,7 @@ import unittest from tango._tango import DevState +from tangostationcontrol.devices.opcua_device import opcua_device from tangostationcontrol.integration_test.device_proxy import TestDeviceProxy from tangostationcontrol.integration_test import base @@ -55,6 +56,12 @@ class AbstractTestBases: self.assertEqual(DevState.STANDBY, self.proxy.state()) + def test_device_missing_attributes(self): + """Test if any attributes are missing from opcua devices""" + + if isinstance(self.proxy, opcua_device): + self.self.assertListEqual([], self.proxy.opcua_missing_attributes_R) + def test_device_on(self): """Test if we can transition to on""" diff --git a/tangostationcontrol/tangostationcontrol/test/devices/test_abstract_device.py b/tangostationcontrol/tangostationcontrol/test/devices/test_abstract_device.py index 469ea19fa970cf48c2de9c4c6b5648bd7b756040..badfadade01521aeb104f77a86f6b42df2f26927 100644 --- a/tangostationcontrol/tangostationcontrol/test/devices/test_abstract_device.py +++ b/tangostationcontrol/tangostationcontrol/test/devices/test_abstract_device.py @@ -86,4 +86,9 @@ class TestAbstractDevice(base.TestCase): # the expected error. self.assertRaises(TypeError, self.AbstractExample) + @mock.patch.object(server, 'get_worker') + @mock.patch.object(server, 'LatestDeviceImpl') + def test_isinstance(self, m_worker, m_implement): + m_device = self.TestHardwareDevice(mock.Mock(), mock.Mock()) + self.assertFalse(isinstance(m_device, AbstractDeviceMetas))