Skip to content
Snippets Groups Projects
Commit b4961cf8 authored by Corné Lukken's avatar Corné Lukken
Browse files

Merge branch 'L2SS-456-opcua-missing' into 'master'

L2SS-456: Integration test check missing opcua attributes

Closes L2SS-456

See merge request !203
parents 26aecc9e d14ccebc
No related branches found
No related tags found
1 merge request!203L2SS-456: Integration test check missing opcua attributes
...@@ -19,10 +19,15 @@ from tango.server import DeviceMeta ...@@ -19,10 +19,15 @@ from tango.server import DeviceMeta
logger = logging.getLogger() 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. """ """Collects meta classes to allow lofar_device to be both a Device and an ABC. """
def __new__(mcs, name, bases, namespace, **kwargs): def __new__(mcs, name, bases, namespace, **kwargs):
cls = ABCMeta.__new__(mcs, name, bases, namespace, **kwargs) cls = DeviceMeta.__new__(mcs, name, bases, namespace, **kwargs)
cls = DeviceMeta.__new__(type(cls), name, bases, namespace) # temp_cls = ABCMeta.__new__(mcs, name, bases, namespace)
# setattr(cls, '__abstractmethods__', temp_cls.__abstractmethods__)
# setattr(cls, '_abc_impl', temp_cls._abc_impl)
return cls return cls
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
""" """
from abc import ABCMeta, abstractmethod from abc import abstractmethod
# PyTango imports # PyTango imports
from tango.server import device_property, attribute from tango.server import device_property, attribute
...@@ -33,7 +33,9 @@ import numpy ...@@ -33,7 +33,9 @@ import numpy
__all__ = ["Statistics"] __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 # In derived classes, set this to a subclass of StatisticsCollector
@property @property
......
...@@ -12,6 +12,7 @@ import unittest ...@@ -12,6 +12,7 @@ import unittest
from tango._tango import DevState 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.device_proxy import TestDeviceProxy
from tangostationcontrol.integration_test import base from tangostationcontrol.integration_test import base
...@@ -55,6 +56,12 @@ class AbstractTestBases: ...@@ -55,6 +56,12 @@ class AbstractTestBases:
self.assertEqual(DevState.STANDBY, self.proxy.state()) 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): def test_device_on(self):
"""Test if we can transition to on""" """Test if we can transition to on"""
......
...@@ -86,4 +86,9 @@ class TestAbstractDevice(base.TestCase): ...@@ -86,4 +86,9 @@ class TestAbstractDevice(base.TestCase):
# the expected error. # the expected error.
self.assertRaises(TypeError, self.AbstractExample) 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))
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