diff --git a/setup.py b/setup.py index 8c78ed3b2f3cc4110b8c14fc9e682be6fee62b93..78556a3f3b5c99d5da0c23179b8a44c0ae35c2d3 100644 --- a/setup.py +++ b/setup.py @@ -45,11 +45,7 @@ setup(name="levpro", "coverage", "pytest", "pytest-cov", - "pytest-xdist", - "python-devicetest", - "unittest2" + "pytest-xdist" ], - dependency_links=[ - 'git+https://github.com/vxgmichel/pytango-devicetest.git#egg=python_devicetest'], keywords="levpro lmc ska", zip_safe=False) diff --git a/skabase/SKAAlarmHandler/SKAAlarmHandler.py b/skabase/SKAAlarmHandler/SKAAlarmHandler.py deleted file mode 100644 index cfd986f3de0e647261eec70cd827ea4fa2acea80..0000000000000000000000000000000000000000 --- a/skabase/SKAAlarmHandler/SKAAlarmHandler.py +++ /dev/null @@ -1,247 +0,0 @@ -# -*- coding: utf-8 -*- -# -# This file is part of the SKAAlarmHandler project -# -# -# -# Distributed under the terms of the GPL license. -# See LICENSE.txt for more info. - -""" SKAAlarmHandler - -A generic base device for Alarms for SKA. -""" - -# PyTango imports -import PyTango -from PyTango import DebugIt -from PyTango.server import run -from PyTango.server import Device, DeviceMeta -from PyTango.server import attribute, command -from PyTango.server import device_property -from PyTango import AttrQuality, DispLevel, DevState -from PyTango import AttrWriteType, PipeWriteType -from SKABaseDevice import SKABaseDevice -# Additional import -# PROTECTED REGION ID(SKAAlarmHandler.additionnal_import) ENABLED START # -# PROTECTED REGION END # // SKAAlarmHandler.additionnal_import - -__all__ = ["SKAAlarmHandler", "main"] - - -class SKAAlarmHandler(SKABaseDevice): - """ - A generic base device for Alarms for SKA. - """ - __metaclass__ = DeviceMeta - # PROTECTED REGION ID(SKAAlarmHandler.class_variable) ENABLED START # - # PROTECTED REGION END # // SKAAlarmHandler.class_variable - - # ----------------- - # Device Properties - # ----------------- - - SubAlarmHandlers = device_property( - dtype=('str',), - ) - - AlarmConfigFile = device_property( - dtype='str', - ) - - - - - - - - # ---------- - # Attributes - # ---------- - - statsNrAlerts = attribute( - dtype='int', - doc="Number of Alarm alerts", - ) - - statsNrAlarms = attribute( - dtype='int', - doc="Number of Alarms active", - ) - - statsNrNewAlarms = attribute( - dtype='int', - doc="Number of New active alarms", - ) - - statsNrUnackAlarms = attribute( - dtype='double', - doc="Number of unacknowledged alarms", - ) - - statsNrRtnAlarms = attribute( - dtype='double', - doc="Number of returned alarms", - ) - - - - - - - - - - - - activeAlerts = attribute( - dtype=('str',), - max_dim_x=10000, - doc="List of active alerts", - ) - - activeAlarms = attribute( - dtype=('str',), - max_dim_x=10000, - doc="List of active alarms", - ) - - # --------------- - # General methods - # --------------- - - def init_device(self): - SKABaseDevice.init_device(self) - # PROTECTED REGION ID(SKAAlarmHandler.init_device) ENABLED START # - # PROTECTED REGION END # // SKAAlarmHandler.init_device - - def always_executed_hook(self): - # PROTECTED REGION ID(SKAAlarmHandler.always_executed_hook) ENABLED START # - pass - # PROTECTED REGION END # // SKAAlarmHandler.always_executed_hook - - def delete_device(self): - # PROTECTED REGION ID(SKAAlarmHandler.delete_device) ENABLED START # - pass - # PROTECTED REGION END # // SKAAlarmHandler.delete_device - - # ------------------ - # Attributes methods - # ------------------ - - def read_statsNrAlerts(self): - # PROTECTED REGION ID(SKAAlarmHandler.statsNrAlerts_read) ENABLED START # - return 0 - # PROTECTED REGION END # // SKAAlarmHandler.statsNrAlerts_read - - def read_statsNrAlarms(self): - # PROTECTED REGION ID(SKAAlarmHandler.statsNrAlarms_read) ENABLED START # - return 0 - # PROTECTED REGION END # // SKAAlarmHandler.statsNrAlarms_read - - def read_statsNrNewAlarms(self): - # PROTECTED REGION ID(SKAAlarmHandler.statsNrNewAlarms_read) ENABLED START # - return 0 - # PROTECTED REGION END # // SKAAlarmHandler.statsNrNewAlarms_read - - def read_statsNrUnackAlarms(self): - # PROTECTED REGION ID(SKAAlarmHandler.statsNrUnackAlarms_read) ENABLED START # - return 0.0 - # PROTECTED REGION END # // SKAAlarmHandler.statsNrUnackAlarms_read - - def read_statsNrRtnAlarms(self): - # PROTECTED REGION ID(SKAAlarmHandler.statsNrRtnAlarms_read) ENABLED START # - return 0.0 - # PROTECTED REGION END # // SKAAlarmHandler.statsNrRtnAlarms_read - - def read_activeAlerts(self): - # PROTECTED REGION ID(SKAAlarmHandler.activeAlerts_read) ENABLED START # - return [''] - # PROTECTED REGION END # // SKAAlarmHandler.activeAlerts_read - - def read_activeAlarms(self): - # PROTECTED REGION ID(SKAAlarmHandler.activeAlarms_read) ENABLED START # - return [''] - # PROTECTED REGION END # // SKAAlarmHandler.activeAlarms_read - - - # -------- - # Commands - # -------- - - @command( - dtype_in='str', - doc_in="Alarm name", - dtype_out='str', - doc_out="JSON string", - ) - @DebugIt() - def GetAlarmRule(self, argin): - # PROTECTED REGION ID(SKAAlarmHandler.GetAlarmRule) ENABLED START # - return "" - # PROTECTED REGION END # // SKAAlarmHandler.GetAlarmRule - - @command( - dtype_in='str', - doc_in="Alarm name", - dtype_out='str', - doc_out="JSON string", - ) - @DebugIt() - def GetAlarmData(self, argin): - # PROTECTED REGION ID(SKAAlarmHandler.GetAlarmData) ENABLED START # - return "" - # PROTECTED REGION END # // SKAAlarmHandler.GetAlarmData - - @command( - dtype_in='str', - doc_in="Alarm name", - dtype_out='str', - doc_out="JSON string", - ) - @DebugIt() - def GetAlarmAdditionalInfo(self, argin): - # PROTECTED REGION ID(SKAAlarmHandler.GetAlarmAdditionalInfo) ENABLED START # - return "" - # PROTECTED REGION END # // SKAAlarmHandler.GetAlarmAdditionalInfo - - @command( - dtype_out='str', - doc_out="JSON string", - ) - @DebugIt() - def GetAlarmStats(self): - # PROTECTED REGION ID(SKAAlarmHandler.GetAlarmStats) ENABLED START # - return "" - # PROTECTED REGION END # // SKAAlarmHandler.GetAlarmStats - - @command( - dtype_out='str', - doc_out="JSON string", - ) - @DebugIt() - def GetAlertStats(self): - # PROTECTED REGION ID(SKAAlarmHandler.GetAlertStats) ENABLED START # - return "" - # PROTECTED REGION END # // SKAAlarmHandler.GetAlertStats - - @command( - ) - @DebugIt() - def Reset(self): - # PROTECTED REGION ID(SKAAlarmHandler.Reset) ENABLED START # - pass - # PROTECTED REGION END # // SKAAlarmHandler.Reset - -# ---------- -# Run server -# ---------- - - -def main(args=None, **kwargs): - # PROTECTED REGION ID(SKAAlarmHandler.main) ENABLED START # - return run((SKAAlarmHandler,), args=args, **kwargs) - # PROTECTED REGION END # // SKAAlarmHandler.main - -if __name__ == '__main__': - main() diff --git a/skabase/SKAAlarmHandler/SKAAlarmHandler.xmi b/skabase/SKAAlarmHandler/SKAAlarmHandler.xmi index 5e4a15b4c1ea51a290c345a09642dedab145f8b6..aca6187517d4e39a6d70cc87efe9bb8c0a5fba73 100644 --- a/skabase/SKAAlarmHandler/SKAAlarmHandler.xmi +++ b/skabase/SKAAlarmHandler/SKAAlarmHandler.xmi @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="ASCII"?> <pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl"> <classes name="SKAAlarmHandler" pogoRevision="9.6"> - <description description="A generic base device for Alarms for SKA." title="SKAAlarmHandler" sourcePath="/home/kat/src/levpro/skabase/SKAAlarmHandler" language="PythonHL" filestogenerate="XMI file,Code files, Python Package, Protected Regions" license="GPL" copyright="" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> + <description description="A generic base device for Alarms for SKA." title="SKAAlarmHandler" sourcePath="/home/pogo/src/levpro/skabase/SKAAlarmHandler" language="PythonHL" filestogenerate="XMI file,Code files,Python Package,Protected Regions" license="GPL" copyright="" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> <inheritances classname="Device_Impl" sourcePath=""/> <inheritances classname="SKABaseDevice" sourcePath="../SKABaseDevice"/> <identification contact="at ska.ac.za - cam" author="cam" emailDomain="ska.ac.za" classFamily="OtherInstruments" siteSpecific="" platform="All Platforms" bus="Not Applicable" manufacturer="SKASA" reference="SKA-SKAAlarmHandler"/> @@ -20,11 +20,13 @@ <DefaultPropValue>4</DefaultPropValue> </deviceProperties> <deviceProperties name="MetricList" description="A subset of attributes we want to expose as metrics for this device."> - <type xsi:type="pogoDsl:StringType"/> + <type xsi:type="pogoDsl:StringVectorType"/> <status abstract="false" inherited="true" concrete="true"/> - <DefaultPropValue>healthState,adminMode,controlMode</DefaultPropValue> + <DefaultPropValue>healthState</DefaultPropValue> + <DefaultPropValue>adminMode</DefaultPropValue> + <DefaultPropValue>controlMode</DefaultPropValue> </deviceProperties> - <deviceProperties name="GroupDefinitions" description="List of grouped devices managed by a master. Each string in the array is a JSON 
document defining the ``groupname``, ``devices`` and ``groups`` in the group.
A proxy client will be opened for each of the managed devices.
A group will be instantiated for the managed devices per group.
Each entry in the array contains a JSON defining the group, like:
[ {``groupname``: ``group1``, 
 ``devices``: ``csv list of devices in group1``},
 {``groupname``: ``group2``, # a group with devices and a subgroup
 ``devices``: ``csv list of devices in group2``,
 ``groups`` : ``csv list of sub groups``},
 {``groupname``: ``group3``, 
 ``devices`` : ``csv list of devices in group3``}},
 {``groupname``: ``group4``, # a group with only subgroups
 ``groups`` : ``csv list of sub groups``}}]

e.g. for a hierarchy of racks, servers and switches
[{ ``groupname``: ``servers``, 
 ``devices``: ``elt/server/1,elt/server/2,elt/server/3,elt/server/4``},
 {``groupname``: ``switches``, 
 ``devices``: ``elt/switch/A,elt/switch/B``},
 {``groupname``: ``pdus``, 
 ``devices``: ``elt/pdu/rackA,elt/pdu/rackB``},
 {``groupname``:``rackA``, 
 ``devices``: ``elt/server/1,elt/server/2,elt/switch/A,elt/pdu/rackA``},
 {``groupname``:``rackB``,
 ``devices``: ``elt/server/3,elt/server/4,elt/switch/B,elt/pdu/rackB``},
 {``groupname``:``racks``,
 ``groups``: ``rackA,rackB``}]"> + <deviceProperties name="GroupDefinitions" description="Each string in the list is a JSON serialised dict defining the ``group_name``,
``devices`` and ``subgroups`` in the group. A TANGO Group object is created
for each item in the list, according to the hierarchy defined. This provides
easy access to the managed devices in bulk, or individually.

The general format of the list is as follows, with optional ``devices`` and
``subgroups`` keys:
 [ {``group_name``: ``<name>``,
 ``devices``: [``<dev name>``, ...]},
 {``group_name``: ``<name>``,
 ``devices``: [``<dev name>``, ``<dev name>``, ...],
 ``subgroups`` : [{<nested group>},
 {<nested group>}, ...]},
 ...
 ]

For example, a hierarchy of racks, servers and switches:
 [ {``group_name``: ``servers``,
 ``devices``: [``elt/server/1``, ``elt/server/2``,
 ``elt/server/3``, ``elt/server/4``]},
 {``group_name``: ``switches``,
 ``devices``: [``elt/switch/A``, ``elt/switch/B``]},
 {``group_name``: ``pdus``,
 ``devices``: [``elt/pdu/rackA``, ``elt/pdu/rackB``]},
 {``group_name``: ``racks``,
 ``subgroups``: [
 {``group_name``: ``rackA``,
 ``devices``: [``elt/server/1``, ``elt/server/2``,
 ``elt/switch/A``, ``elt/pdu/rackA``]},
 {``group_name``: ``rackB``,
 ``devices``: [``elt/server/3``, ``elt/server/4``,
 ``elt/switch/B``, ``elt/pdu/rackB``],
 ``subgroups``: []}
 ]} ]"> <type xsi:type="pogoDsl:StringVectorType"/> <status abstract="false" inherited="true" concrete="true"/> </deviceProperties> @@ -104,14 +106,14 @@ </argout> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </commands> - <commands name="Reset" description="Reset device to its default state" execMethod="reset" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> + <commands name="Reset" description="Reset device to its default state" execMethod="reset" displayLevel="OPERATOR" polledPeriod="0"> <argin description=""> <type xsi:type="pogoDsl:VoidType"/> </argin> <argout description=""> <type xsi:type="pogoDsl:VoidType"/> </argout> - <status abstract="true" inherited="true" concrete="true" concreteHere="false"/> + <status abstract="false" inherited="true" concrete="true" concreteHere="false"/> </commands> <commands name="GetMetrics" description="Gets list of attributes marked as metrics, with their values, 
for device" execMethod="get_metrics" displayLevel="OPERATOR" polledPeriod="0"> <argin description=""> @@ -290,6 +292,6 @@ <states name="DISABLE" description="The device cannot be switched ON for an external reason. E.g. the power supply has its door open, the safety conditions are not satisfactory to allow the device to operate."> <status abstract="false" inherited="true" concrete="true"/> </states> - <preferences docHome="./doc_html" makefileHome="/usr/share/pogo/preferences"/> + <preferences docHome="./doc_html" makefileHome="$(TANGO_HOME)"/> </classes> </pogoDsl:PogoSystem> diff --git a/skabase/SKAAlarmHandler/__init__.py b/skabase/SKAAlarmHandler/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..4ccd0e9cc9bccc5dd3cc2aeb53adc6296dc9d628 --- /dev/null +++ b/skabase/SKAAlarmHandler/__init__.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# +# This file is part of the SKABaseDevice project +# +# +# +# Distributed under the terms of the GPL license. +# See LICENSE.txt for more info. + +"""SKABASE + +A generic base device for SKA. +""" + +from . import release +from .SKAAlarmHandler import SKAAlarmHandler, main + +__version__ = release.version +__version_info__ = release.version_info +__author__ = release.author diff --git a/skabase/SKAAlarmHandler/__main__.py b/skabase/SKAAlarmHandler/__main__.py new file mode 100644 index 0000000000000000000000000000000000000000..eb09d39d7c735624e4aa2fc426d8b107b9d4ea84 --- /dev/null +++ b/skabase/SKAAlarmHandler/__main__.py @@ -0,0 +1,11 @@ +# -*- coding: utf-8 -*- +# +# This file is part of the SKABaseDevice project +# +# +# +# Distributed under the terms of the GPL license. +# See LICENSE.txt for more info. + +from SKAAlarmHandler import main +main() diff --git a/skabase/SKAAlarmHandler/release.py b/skabase/SKAAlarmHandler/release.py new file mode 100644 index 0000000000000000000000000000000000000000..4687daf1cf744b08be049bfe7b2635ce85a8b0ba --- /dev/null +++ b/skabase/SKAAlarmHandler/release.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# +# This file is part of the SKABaseDevice project +# +# +# +# Distributed under the terms of the GPL license. +# See LICENSE.txt for more info. + +"""Release information for Python Package""" + +name = """tangods-skaalarmhandler""" +version = "1.0.0" +version_info = version.split(".") +description = """A generic base device for SKA.""" +author = "cam" +author_email = "cam at ska.ac.za" +license = """GPL""" +url = """www.tango-controls.org""" +copyright = """""" diff --git a/skabase/SKAAlarmHandler/test/SKAAlarmHandler_test.py b/skabase/SKAAlarmHandler/test/SKAAlarmHandler_test.py index bd406cfdcce93d4c8d5a3fdca55ae2dc3722087e..9e21cbced9c2bb1a01cb7af5a46628745adaedd3 100644 --- a/skabase/SKAAlarmHandler/test/SKAAlarmHandler_test.py +++ b/skabase/SKAAlarmHandler/test/SKAAlarmHandler_test.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +######################################################################################### # -*- coding: utf-8 -*- # # This file is part of the SKAAlarmHandler project @@ -7,6 +7,7 @@ # # Distributed under the terms of the GPL license. # See LICENSE.txt for more info. +######################################################################################### """Contain the tests for the SKAAlarmHandler.""" # Path @@ -16,32 +17,32 @@ path = os.path.join(os.path.dirname(__file__), os.pardir) sys.path.insert(0, os.path.abspath(path)) # Imports -from time import sleep +import pytest from mock import MagicMock -from PyTango import DevFailed, DevState -from devicetest import DeviceTestCase, main -from SKAAlarmHandler import SKAAlarmHandler -# Note: -# -# Since the device uses an inner thread, it is necessary to -# wait during the tests in order the let the device update itself. -# Hence, the sleep calls have to be secured enough not to produce -# any inconsistent behavior. However, the unittests need to run fast. -# Here, we use a factor 3 between the read period and the sleep calls. -# -# Look at devicetest examples for more advanced testing +from PyTango import DevState + +# PROTECTED REGION ID(SKAAlarmHandler.test_additional_imports) ENABLED START # +# PROTECTED REGION END # // SKAAlarmHandler.test_additional_imports # Device test case -class SKAAlarmHandlerDeviceTestCase(DeviceTestCase): +@pytest.mark.usefixtures("tango_context", "initialize_device") +# PROTECTED REGION ID(SKAAlarmHandler.test_SKAAlarmHandler_decorators) ENABLED START # +# PROTECTED REGION END # // SKAAlarmHandler.test_SKAAlarmHandler_decorators +class TestSKAAlarmHandler(object): """Test case for packet generation.""" - # PROTECTED REGION ID(SKAAlarmHandler.test_additionnal_import) ENABLED START # - # PROTECTED REGION END # // SKAAlarmHandler.test_additionnal_import - device = SKAAlarmHandler - properties = {'SubAlarmHandlers': '', 'AlarmConfigFile': '', 'SkaLevel': '4', 'MetricList': 'healthState,adminMode,controlMode', 'GroupDefinitions': '', 'CentralLoggingTarget': '', 'ElementLoggingTarget': '', 'StorageLoggingTarget': 'localhost', - } - empty = None # Should be [] + + properties = { + 'SubAlarmHandlers': '', + 'AlarmConfigFile': '', + 'SkaLevel': '4', + 'MetricList': 'healthState', + 'GroupDefinitions': '', + 'CentralLoggingTarget': '', + 'ElementLoggingTarget': '', + 'StorageLoggingTarget': 'localhost', + } @classmethod def mocking(cls): @@ -51,181 +52,235 @@ class SKAAlarmHandlerDeviceTestCase(DeviceTestCase): # PROTECTED REGION ID(SKAAlarmHandler.test_mocking) ENABLED START # # PROTECTED REGION END # // SKAAlarmHandler.test_mocking - def test_properties(self): - # test the properties + def test_properties(self, tango_context): + # Test the properties # PROTECTED REGION ID(SKAAlarmHandler.test_properties) ENABLED START # # PROTECTED REGION END # // SKAAlarmHandler.test_properties pass - def test_State(self): + # PROTECTED REGION ID(SKAAlarmHandler.test_State_decorators) ENABLED START # + # PROTECTED REGION END # // SKAAlarmHandler.test_State_decorators + def test_State(self, tango_context): """Test for State""" # PROTECTED REGION ID(SKAAlarmHandler.test_State) ENABLED START # - self.device.State() + assert tango_context.device.State() == DevState.UNKNOWN # PROTECTED REGION END # // SKAAlarmHandler.test_State - def test_Status(self): + # PROTECTED REGION ID(SKAAlarmHandler.test_Status_decorators) ENABLED START # + # PROTECTED REGION END # // SKAAlarmHandler.test_Status_decorators + def test_Status(self, tango_context): """Test for Status""" # PROTECTED REGION ID(SKAAlarmHandler.test_Status) ENABLED START # - self.device.Status() + assert tango_context.device.Status() == "The device is in UNKNOWN state." # PROTECTED REGION END # // SKAAlarmHandler.test_Status - def test_GetAlarmRule(self): + # PROTECTED REGION ID(SKAAlarmHandler.test_GetAlarmRule_decorators) ENABLED START # + # PROTECTED REGION END # // SKAAlarmHandler.test_GetAlarmRule_decorators + def test_GetAlarmRule(self, tango_context): """Test for GetAlarmRule""" # PROTECTED REGION ID(SKAAlarmHandler.test_GetAlarmRule) ENABLED START # - self.device.GetAlarmRule("") + assert tango_context.device.GetAlarmRule("") == "" # PROTECTED REGION END # // SKAAlarmHandler.test_GetAlarmRule - def test_GetAlarmData(self): + # PROTECTED REGION ID(SKAAlarmHandler.test_GetAlarmData_decorators) ENABLED START # + # PROTECTED REGION END # // SKAAlarmHandler.test_GetAlarmData_decorators + def test_GetAlarmData(self, tango_context): """Test for GetAlarmData""" # PROTECTED REGION ID(SKAAlarmHandler.test_GetAlarmData) ENABLED START # - self.device.GetAlarmData("") + assert tango_context.device.GetAlarmData("") == "" # PROTECTED REGION END # // SKAAlarmHandler.test_GetAlarmData - def test_GetAlarmAdditionalInfo(self): + # PROTECTED REGION ID(SKAAlarmHandler.test_GetAlarmAdditionalInfo_decorators) ENABLED START # + # PROTECTED REGION END # // SKAAlarmHandler.test_GetAlarmAdditionalInfo_decorators + def test_GetAlarmAdditionalInfo(self, tango_context): """Test for GetAlarmAdditionalInfo""" # PROTECTED REGION ID(SKAAlarmHandler.test_GetAlarmAdditionalInfo) ENABLED START # - self.device.GetAlarmAdditionalInfo("") + assert tango_context.device.GetAlarmAdditionalInfo("") == "" # PROTECTED REGION END # // SKAAlarmHandler.test_GetAlarmAdditionalInfo - def test_GetAlarmStats(self): + # PROTECTED REGION ID(SKAAlarmHandler.test_GetAlarmStats_decorators) ENABLED START # + # PROTECTED REGION END # // SKAAlarmHandler.test_GetAlarmStats_decorators + def test_GetAlarmStats(self, tango_context): """Test for GetAlarmStats""" # PROTECTED REGION ID(SKAAlarmHandler.test_GetAlarmStats) ENABLED START # - self.device.GetAlarmStats() + assert tango_context.device.GetAlarmStats() == "" # PROTECTED REGION END # // SKAAlarmHandler.test_GetAlarmStats - def test_GetAlertStats(self): + # PROTECTED REGION ID(SKAAlarmHandler.test_GetAlertStats_decorators) ENABLED START # + # PROTECTED REGION END # // SKAAlarmHandler.test_GetAlertStats_decorators + def test_GetAlertStats(self, tango_context): """Test for GetAlertStats""" # PROTECTED REGION ID(SKAAlarmHandler.test_GetAlertStats) ENABLED START # - self.device.GetAlertStats() + assert tango_context.device.GetAlertStats() == "" # PROTECTED REGION END # // SKAAlarmHandler.test_GetAlertStats - def test_Reset(self): + # PROTECTED REGION ID(SKAAlarmHandler.test_Reset_decorators) ENABLED START # + # PROTECTED REGION END # // SKAAlarmHandler.test_Reset_decorators + def test_Reset(self, tango_context): """Test for Reset""" # PROTECTED REGION ID(SKAAlarmHandler.test_Reset) ENABLED START # - self.device.Reset() + assert tango_context.device.Reset() == None # PROTECTED REGION END # // SKAAlarmHandler.test_Reset - def test_GetMetrics(self): + # PROTECTED REGION ID(SKAAlarmHandler.test_GetMetrics_decorators) ENABLED START # + # PROTECTED REGION END # // SKAAlarmHandler.test_GetMetrics_decorators + def test_GetMetrics(self, tango_context): """Test for GetMetrics""" # PROTECTED REGION ID(SKAAlarmHandler.test_GetMetrics) ENABLED START # - self.device.GetMetrics() + assert tango_context.device.GetMetrics() == "" # PROTECTED REGION END # // SKAAlarmHandler.test_GetMetrics - def test_ToJson(self): + # PROTECTED REGION ID(SKAAlarmHandler.test_ToJson_decorators) ENABLED START # + # PROTECTED REGION END # // SKAAlarmHandler.test_ToJson_decorators + def test_ToJson(self, tango_context): """Test for ToJson""" # PROTECTED REGION ID(SKAAlarmHandler.test_ToJson) ENABLED START # - self.device.ToJson("") + assert tango_context.device.ToJson("") == "" # PROTECTED REGION END # // SKAAlarmHandler.test_ToJson - def test_GetVersionInfo(self): + # PROTECTED REGION ID(SKAAlarmHandler.test_GetVersionInfo_decorators) ENABLED START # + # PROTECTED REGION END # // SKAAlarmHandler.test_GetVersionInfo_decorators + def test_GetVersionInfo(self, tango_context): """Test for GetVersionInfo""" # PROTECTED REGION ID(SKAAlarmHandler.test_GetVersionInfo) ENABLED START # - self.device.GetVersionInfo() + assert tango_context.device.GetVersionInfo() == [""] # PROTECTED REGION END # // SKAAlarmHandler.test_GetVersionInfo - def test_statsNrAlerts(self): + + # PROTECTED REGION ID(SKAAlarmHandler.test_statsNrAlerts_decorators) ENABLED START # + # PROTECTED REGION END # // SKAAlarmHandler.test_statsNrAlerts_decorators + def test_statsNrAlerts(self, tango_context): """Test for statsNrAlerts""" # PROTECTED REGION ID(SKAAlarmHandler.test_statsNrAlerts) ENABLED START # - self.device.statsNrAlerts + assert tango_context.device.statsNrAlerts == 0 # PROTECTED REGION END # // SKAAlarmHandler.test_statsNrAlerts - def test_statsNrAlarms(self): + # PROTECTED REGION ID(SKAAlarmHandler.test_statsNrAlarms_decorators) ENABLED START # + # PROTECTED REGION END # // SKAAlarmHandler.test_statsNrAlarms_decorators + def test_statsNrAlarms(self, tango_context): """Test for statsNrAlarms""" # PROTECTED REGION ID(SKAAlarmHandler.test_statsNrAlarms) ENABLED START # - self.device.statsNrAlarms + assert tango_context.device.statsNrAlarms == 0 # PROTECTED REGION END # // SKAAlarmHandler.test_statsNrAlarms - def test_statsNrNewAlarms(self): + # PROTECTED REGION ID(SKAAlarmHandler.test_statsNrNewAlarms_decorators) ENABLED START # + # PROTECTED REGION END # // SKAAlarmHandler.test_statsNrNewAlarms_decorators + def test_statsNrNewAlarms(self, tango_context): """Test for statsNrNewAlarms""" # PROTECTED REGION ID(SKAAlarmHandler.test_statsNrNewAlarms) ENABLED START # - self.device.statsNrNewAlarms + assert tango_context.device.statsNrNewAlarms == 0 # PROTECTED REGION END # // SKAAlarmHandler.test_statsNrNewAlarms - def test_statsNrUnackAlarms(self): + # PROTECTED REGION ID(SKAAlarmHandler.test_statsNrUnackAlarms_decorators) ENABLED START # + # PROTECTED REGION END # // SKAAlarmHandler.test_statsNrUnackAlarms_decorators + def test_statsNrUnackAlarms(self, tango_context): """Test for statsNrUnackAlarms""" # PROTECTED REGION ID(SKAAlarmHandler.test_statsNrUnackAlarms) ENABLED START # - self.device.statsNrUnackAlarms + assert tango_context.device.statsNrUnackAlarms == 0.0 # PROTECTED REGION END # // SKAAlarmHandler.test_statsNrUnackAlarms - def test_statsNrRtnAlarms(self): + # PROTECTED REGION ID(SKAAlarmHandler.test_statsNrRtnAlarms_decorators) ENABLED START # + # PROTECTED REGION END # // SKAAlarmHandler.test_statsNrRtnAlarms_decorators + def test_statsNrRtnAlarms(self, tango_context): """Test for statsNrRtnAlarms""" # PROTECTED REGION ID(SKAAlarmHandler.test_statsNrRtnAlarms) ENABLED START # - self.device.statsNrRtnAlarms + assert tango_context.device.statsNrRtnAlarms == 0.0 # PROTECTED REGION END # // SKAAlarmHandler.test_statsNrRtnAlarms - def test_buildState(self): + # PROTECTED REGION ID(SKAAlarmHandler.test_buildState_decorators) ENABLED START # + # PROTECTED REGION END # // SKAAlarmHandler.test_buildState_decorators + def test_buildState(self, tango_context): """Test for buildState""" # PROTECTED REGION ID(SKAAlarmHandler.test_buildState) ENABLED START # - self.device.buildState + assert tango_context.device.buildState == '' # PROTECTED REGION END # // SKAAlarmHandler.test_buildState - def test_versionId(self): + # PROTECTED REGION ID(SKAAlarmHandler.test_versionId_decorators) ENABLED START # + # PROTECTED REGION END # // SKAAlarmHandler.test_versionId_decorators + def test_versionId(self, tango_context): """Test for versionId""" # PROTECTED REGION ID(SKAAlarmHandler.test_versionId) ENABLED START # - self.device.versionId + assert tango_context.device.versionId == '' # PROTECTED REGION END # // SKAAlarmHandler.test_versionId - def test_centralLoggingLevel(self): + # PROTECTED REGION ID(SKAAlarmHandler.test_centralLoggingLevel_decorators) ENABLED START # + # PROTECTED REGION END # // SKAAlarmHandler.test_centralLoggingLevel_decorators + def test_centralLoggingLevel(self, tango_context): """Test for centralLoggingLevel""" # PROTECTED REGION ID(SKAAlarmHandler.test_centralLoggingLevel) ENABLED START # - self.device.centralLoggingLevel + assert tango_context.device.centralLoggingLevel == 0 # PROTECTED REGION END # // SKAAlarmHandler.test_centralLoggingLevel - def test_elementLoggingLevel(self): + # PROTECTED REGION ID(SKAAlarmHandler.test_elementLoggingLevel_decorators) ENABLED START # + # PROTECTED REGION END # // SKAAlarmHandler.test_elementLoggingLevel_decorators + def test_elementLoggingLevel(self, tango_context): """Test for elementLoggingLevel""" # PROTECTED REGION ID(SKAAlarmHandler.test_elementLoggingLevel) ENABLED START # - self.device.elementLoggingLevel + assert tango_context.device.elementLoggingLevel == 0 # PROTECTED REGION END # // SKAAlarmHandler.test_elementLoggingLevel - def test_storageLoggingLevel(self): + # PROTECTED REGION ID(SKAAlarmHandler.test_storageLoggingLevel_decorators) ENABLED START # + # PROTECTED REGION END # // SKAAlarmHandler.test_storageLoggingLevel_decorators + def test_storageLoggingLevel(self, tango_context): """Test for storageLoggingLevel""" # PROTECTED REGION ID(SKAAlarmHandler.test_storageLoggingLevel) ENABLED START # - self.device.storageLoggingLevel + assert tango_context.device.storageLoggingLevel == 0 # PROTECTED REGION END # // SKAAlarmHandler.test_storageLoggingLevel - def test_healthState(self): + # PROTECTED REGION ID(SKAAlarmHandler.test_healthState_decorators) ENABLED START # + # PROTECTED REGION END # // SKAAlarmHandler.test_healthState_decorators + def test_healthState(self, tango_context): """Test for healthState""" # PROTECTED REGION ID(SKAAlarmHandler.test_healthState) ENABLED START # - self.device.healthState + assert tango_context.device.healthState == 0 # PROTECTED REGION END # // SKAAlarmHandler.test_healthState - def test_adminMode(self): + # PROTECTED REGION ID(SKAAlarmHandler.test_adminMode_decorators) ENABLED START # + # PROTECTED REGION END # // SKAAlarmHandler.test_adminMode_decorators + def test_adminMode(self, tango_context): """Test for adminMode""" # PROTECTED REGION ID(SKAAlarmHandler.test_adminMode) ENABLED START # - self.device.adminMode + assert tango_context.device.adminMode == 0 # PROTECTED REGION END # // SKAAlarmHandler.test_adminMode - def test_controlMode(self): + # PROTECTED REGION ID(SKAAlarmHandler.test_controlMode_decorators) ENABLED START # + # PROTECTED REGION END # // SKAAlarmHandler.test_controlMode_decorators + def test_controlMode(self, tango_context): """Test for controlMode""" # PROTECTED REGION ID(SKAAlarmHandler.test_controlMode) ENABLED START # - self.device.controlMode + assert tango_context.device.controlMode == 0 # PROTECTED REGION END # // SKAAlarmHandler.test_controlMode - def test_simulationMode(self): + # PROTECTED REGION ID(SKAAlarmHandler.test_simulationMode_decorators) ENABLED START # + # PROTECTED REGION END # // SKAAlarmHandler.test_simulationMode_decorators + def test_simulationMode(self, tango_context): """Test for simulationMode""" # PROTECTED REGION ID(SKAAlarmHandler.test_simulationMode) ENABLED START # - self.device.simulationMode + assert tango_context.device.simulationMode == False # PROTECTED REGION END # // SKAAlarmHandler.test_simulationMode - def test_testMode(self): + # PROTECTED REGION ID(SKAAlarmHandler.test_testMode_decorators) ENABLED START # + # PROTECTED REGION END # // SKAAlarmHandler.test_testMode_decorators + def test_testMode(self, tango_context): """Test for testMode""" # PROTECTED REGION ID(SKAAlarmHandler.test_testMode) ENABLED START # - self.device.testMode + assert tango_context.device.testMode == '' # PROTECTED REGION END # // SKAAlarmHandler.test_testMode - def test_activeAlerts(self): + # PROTECTED REGION ID(SKAAlarmHandler.test_activeAlerts_decorators) ENABLED START # + # PROTECTED REGION END # // SKAAlarmHandler.test_activeAlerts_decorators + def test_activeAlerts(self, tango_context): """Test for activeAlerts""" # PROTECTED REGION ID(SKAAlarmHandler.test_activeAlerts) ENABLED START # - self.device.activeAlerts + assert tango_context.device.activeAlerts == ('',) # PROTECTED REGION END # // SKAAlarmHandler.test_activeAlerts - def test_activeAlarms(self): + # PROTECTED REGION ID(SKAAlarmHandler.test_activeAlarms_decorators) ENABLED START # + # PROTECTED REGION END # // SKAAlarmHandler.test_activeAlarms_decorators + def test_activeAlarms(self, tango_context): """Test for activeAlarms""" # PROTECTED REGION ID(SKAAlarmHandler.test_activeAlarms) ENABLED START # - self.device.activeAlarms + assert tango_context.device.activeAlarms == ('',) # PROTECTED REGION END # // SKAAlarmHandler.test_activeAlarms -# Main execution -if __name__ == "__main__": - main() diff --git a/skabase/SKABaseDevice/SKABaseDevice.xmi b/skabase/SKABaseDevice/SKABaseDevice.xmi index 1c5c2b85689129f8ec8e28f933c26a0d7d84aec1..130216d0d1ede5e8dfa55bff10e099c476296c0a 100644 --- a/skabase/SKABaseDevice/SKABaseDevice.xmi +++ b/skabase/SKABaseDevice/SKABaseDevice.xmi @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="ASCII"?> <pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl"> <classes name="SKABaseDevice" pogoRevision="9.6"> - <description description="A generic base device for SKA." title="SKABASE" sourcePath="/home/tango-cs/src/levpro/skabase/SKABaseDevice" language="PythonHL" filestogenerate="XMI file,Code files,Python Package,Protected Regions" license="GPL" copyright="" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> + <description description="A generic base device for SKA." title="SKABASE" sourcePath="/home/pogo/src/levpro/skabase/SKABaseDevice" language="PythonHL" filestogenerate="XMI file,Code files,Python Package,Protected Regions" license="GPL" copyright="" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> <inheritances classname="Device_Impl" sourcePath=""/> <identification contact="at ska.ac.za - cam" author="cam" emailDomain="ska.ac.za" classFamily="OtherInstruments" siteSpecific="" platform="All Platforms" bus="Not Applicable" manufacturer="SKASA" reference="SKA-SKABaseDevice"/> </description> @@ -52,15 +52,6 @@ </argout> <status abstract="true" inherited="true" concrete="true" concreteHere="false"/> </commands> - <commands name="Reset" description="Reset device to its default state" execMethod="reset" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> - <argin description=""> - <type xsi:type="pogoDsl:VoidType"/> - </argin> - <argout description=""> - <type xsi:type="pogoDsl:VoidType"/> - </argout> - <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> - </commands> <commands name="GetMetrics" description="Gets list of attributes marked as metrics, with their values, 
for device" execMethod="get_metrics" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> <argin description=""> <type xsi:type="pogoDsl:VoidType"/> @@ -88,6 +79,15 @@ </argout> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </commands> + <commands name="Reset" description="Reset device to its default state" execMethod="reset" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> + <argin description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argin> + <argout description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argout> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </commands> <attributes name="buildState" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="60000" maxX="" maxY="" allocReadMember="true" isDynamic="false"> <dataType xsi:type="pogoDsl:StringType"/> <dataReadyEvent fire="false" libCheckCriteria="true"/> @@ -183,6 +183,6 @@ <states name="DISABLE" description="The device cannot be switched ON for an external reason. E.g. the power supply has its door open, the safety conditions are not satisfactory to allow the device to operate."> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </states> - <preferences docHome="./doc_html" makefileHome="/usr/share/pogo/preferences"/> + <preferences docHome="./doc_html" makefileHome="$(TANGO_HOME)"/> </classes> </pogoDsl:PogoSystem> diff --git a/skabase/SKABaseDevice/SKABaseDevice/SKABaseDevice.py b/skabase/SKABaseDevice/SKABaseDevice/SKABaseDevice.py index 16f67287f55edb235ed1e47066081273707ff53b..fccbac63969c9eb5c499b275a07fcc58bf2f91f4 100644 --- a/skabase/SKABaseDevice/SKABaseDevice/SKABaseDevice.py +++ b/skabase/SKABaseDevice/SKABaseDevice/SKABaseDevice.py @@ -259,7 +259,7 @@ class SKABaseDevice(Device): dtype='DevEnum', access=AttrWriteType.READ_WRITE, memorized=True, - doc="The control mode of the device. REMOTE, LOCAL\nTANGO Device accepts only from a ?local? client and ignores commands and queries received from TM\nor any other ?remote? clients. The Local clients has to release LOCAL control before REMOTE clients\ncan take control again.", + doc="The control mode of the device. REMOTE, LOCAL\nTANGO Device accepts only from a ‘local’ client and ignores commands and queries received from TM\nor any other ‘remote’ clients. The Local clients has to release LOCAL control before REMOTE clients\ncan take control again.", enum_labels=["REMOTE", "LOCAL", ], ) @@ -414,14 +414,6 @@ class SKABaseDevice(Device): # Commands # -------- - @command( - ) - @DebugIt() - def Reset(self): - # PROTECTED REGION ID(SKABaseDevice.Reset) ENABLED START # - pass - # PROTECTED REGION END # // SKABaseDevice.Reset - @command( dtype_out='str', ) @@ -468,6 +460,14 @@ class SKABaseDevice(Device): return ['{}, {}'.format(self.__class__.__name__, self.read_buildState())] # PROTECTED REGION END # // SKABaseDevice.GetVersionInfo + @command( + ) + @DebugIt() + def Reset(self): + # PROTECTED REGION ID(SKABaseDevice.Reset) ENABLED START # + pass + # PROTECTED REGION END # // SKABaseDevice.Reset + # ---------- # Run server # ---------- diff --git a/skabase/SKABaseDevice/test/SKABaseDevice_test.py b/skabase/SKABaseDevice/test/SKABaseDevice_test.py index 07240e5b6a095338fafb730f593aa541fc4d18cb..3f80d57d51ee571956f14b95577b536c7d4de9e0 100644 --- a/skabase/SKABaseDevice/test/SKABaseDevice_test.py +++ b/skabase/SKABaseDevice/test/SKABaseDevice_test.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +######################################################################################### # -*- coding: utf-8 -*- # # This file is part of the SKABaseDevice project @@ -7,149 +7,182 @@ # # Distributed under the terms of the GPL license. # See LICENSE.txt for more info. +######################################################################################### """Contain the tests for the SKABASE.""" # Path import sys import os -import pytest path = os.path.join(os.path.dirname(__file__), os.pardir) sys.path.insert(0, os.path.abspath(path)) # Imports -from time import sleep +import pytest from mock import MagicMock -from PyTango import DevFailed, DevState -# Note: -# -# Since the device uses an inner thread, it is necessary to -# wait during the tests in order the let the device update itself. -# Hence, the sleep calls have to be secured enough not to produce -# any inconsistent behavior. However, the unittests need to run fast. -# Here, we use a factor 3 between the read period and the sleep calls. -# -# Look at devicetest examples for more advanced testing +from PyTango import DevState + +# PROTECTED REGION ID(SKABaseDevice.test_additional_imports) ENABLED START # +# PROTECTED REGION END # // SKABaseDevice.test_additional_imports + # Device test case @pytest.mark.usefixtures("tango_context", "initialize_device") +# PROTECTED REGION ID(SKABaseDevice.test_SKABaseDevice_decorators) ENABLED START # +# PROTECTED REGION END # // SKABaseDevice.test_SKABaseDevice_decorators class TestSKABaseDevice(object): """Test case for packet generation.""" - # PROTECTED REGION ID(SKABaseDevice.test_additionnal_import) ENABLED START # - # PROTECTED REGION END # // SKABaseDevice.test_additionnal_import - properties = {'SkaLevel': '4', 'MetricList': 'healthState', 'GroupDefinitions': '', 'CentralLoggingTarget': '', 'ElementLoggingTarget': '', 'StorageLoggingTarget': 'localhost', - } + + properties = { + 'SkaLevel': '4', + 'MetricList': 'healthState', + 'GroupDefinitions': '', + 'CentralLoggingTarget': '', + 'ElementLoggingTarget': '', + 'StorageLoggingTarget': 'localhost', + } + + @classmethod + def mocking(cls): + """Mock external libraries.""" + # Example : Mock numpy + # cls.numpy = SKABaseDevice.numpy = MagicMock() + # PROTECTED REGION ID(SKABaseDevice.test_mocking) ENABLED START # + # PROTECTED REGION END # // SKABaseDevice.test_mocking + def test_properties(self, tango_context): - # test the properties + # Test the properties # PROTECTED REGION ID(SKABaseDevice.test_properties) ENABLED START # # PROTECTED REGION END # // SKABaseDevice.test_properties pass + # PROTECTED REGION ID(SKABaseDevice.test_State_decorators) ENABLED START # + # PROTECTED REGION END # // SKABaseDevice.test_State_decorators def test_State(self, tango_context): """Test for State""" # PROTECTED REGION ID(SKABaseDevice.test_State) ENABLED START # - tango_context.device.State() + assert tango_context.device.State() == DevState.UNKNOWN # PROTECTED REGION END # // SKABaseDevice.test_State + # PROTECTED REGION ID(SKABaseDevice.test_Status_decorators) ENABLED START # + # PROTECTED REGION END # // SKABaseDevice.test_Status_decorators def test_Status(self, tango_context): """Test for Status""" # PROTECTED REGION ID(SKABaseDevice.test_Status) ENABLED START # - tango_context.device.Status() + assert tango_context.device.Status() == "The device is in UNKNOWN state." # PROTECTED REGION END # // SKABaseDevice.test_Status - def test_Reset(self, tango_context): - """Test for Reset""" - # PROTECTED REGION ID(SKABaseDevice.test_Reset) ENABLED START # - tango_context.device.Reset() - # PROTECTED REGION END # // SKABaseDevice.test_Reset - + # PROTECTED REGION ID(SKABaseDevice.test_GetMetrics_decorators) ENABLED START # + # PROTECTED REGION END # // SKABaseDevice.test_GetMetrics_decorators def test_GetMetrics(self, tango_context): """Test for GetMetrics""" # PROTECTED REGION ID(SKABaseDevice.test_GetMetrics) ENABLED START # - tango_context.device.GetMetrics() + assert tango_context.device.GetMetrics() == "" # PROTECTED REGION END # // SKABaseDevice.test_GetMetrics + # PROTECTED REGION ID(SKABaseDevice.test_ToJson_decorators) ENABLED START # + # PROTECTED REGION END # // SKABaseDevice.test_ToJson_decorators def test_ToJson(self, tango_context): """Test for ToJson""" # PROTECTED REGION ID(SKABaseDevice.test_ToJson) ENABLED START # - tango_context.device.ToJson("") + assert tango_context.device.ToJson("") == "" # PROTECTED REGION END # // SKABaseDevice.test_ToJson + # PROTECTED REGION ID(SKABaseDevice.test_GetVersionInfo_decorators) ENABLED START # + # PROTECTED REGION END # // SKABaseDevice.test_GetVersionInfo_decorators def test_GetVersionInfo(self, tango_context): """Test for GetVersionInfo""" # PROTECTED REGION ID(SKABaseDevice.test_GetVersionInfo) ENABLED START # - tango_context.device.GetVersionInfo() + assert tango_context.device.GetVersionInfo() == [""] # PROTECTED REGION END # // SKABaseDevice.test_GetVersionInfo + # PROTECTED REGION ID(SKABaseDevice.test_Reset_decorators) ENABLED START # + # PROTECTED REGION END # // SKABaseDevice.test_Reset_decorators + def test_Reset(self, tango_context): + """Test for Reset""" + # PROTECTED REGION ID(SKABaseDevice.test_Reset) ENABLED START # + assert tango_context.device.Reset() == None + # PROTECTED REGION END # // SKABaseDevice.test_Reset + + + # PROTECTED REGION ID(SKABaseDevice.test_buildState_decorators) ENABLED START # + # PROTECTED REGION END # // SKABaseDevice.test_buildState_decorators def test_buildState(self, tango_context): """Test for buildState""" # PROTECTED REGION ID(SKABaseDevice.test_buildState) ENABLED START # - tango_context.device.buildState + assert tango_context.device.buildState == '' # PROTECTED REGION END # // SKABaseDevice.test_buildState + # PROTECTED REGION ID(SKABaseDevice.test_versionId_decorators) ENABLED START # + # PROTECTED REGION END # // SKABaseDevice.test_versionId_decorators def test_versionId(self, tango_context): """Test for versionId""" # PROTECTED REGION ID(SKABaseDevice.test_versionId) ENABLED START # - tango_context.device.versionId + assert tango_context.device.versionId == '' # PROTECTED REGION END # // SKABaseDevice.test_versionId + # PROTECTED REGION ID(SKABaseDevice.test_centralLoggingLevel_decorators) ENABLED START # + # PROTECTED REGION END # // SKABaseDevice.test_centralLoggingLevel_decorators def test_centralLoggingLevel(self, tango_context): """Test for centralLoggingLevel""" # PROTECTED REGION ID(SKABaseDevice.test_centralLoggingLevel) ENABLED START # assert tango_context.device.centralLoggingLevel == 0 - tango_context.device.write_attribute("centralLoggingLevel", 1) - assert tango_context.device.centralLoggingLevel == 1 # PROTECTED REGION END # // SKABaseDevice.test_centralLoggingLevel + # PROTECTED REGION ID(SKABaseDevice.test_elementLoggingLevel_decorators) ENABLED START # + # PROTECTED REGION END # // SKABaseDevice.test_elementLoggingLevel_decorators def test_elementLoggingLevel(self, tango_context): """Test for elementLoggingLevel""" # PROTECTED REGION ID(SKABaseDevice.test_elementLoggingLevel) ENABLED START # assert tango_context.device.elementLoggingLevel == 0 - tango_context.device.write_attribute("elementLoggingLevel", 1) - assert tango_context.device.elementLoggingLevel == 1 # PROTECTED REGION END # // SKABaseDevice.test_elementLoggingLevel + # PROTECTED REGION ID(SKABaseDevice.test_storageLoggingLevel_decorators) ENABLED START # + # PROTECTED REGION END # // SKABaseDevice.test_storageLoggingLevel_decorators def test_storageLoggingLevel(self, tango_context): """Test for storageLoggingLevel""" # PROTECTED REGION ID(SKABaseDevice.test_storageLoggingLevel) ENABLED START # assert tango_context.device.storageLoggingLevel == 0 - tango_context.device.write_attribute("storageLoggingLevel", 1) - assert tango_context.device.storageLoggingLevel == 1 # PROTECTED REGION END # // SKABaseDevice.test_storageLoggingLevel + # PROTECTED REGION ID(SKABaseDevice.test_healthState_decorators) ENABLED START # + # PROTECTED REGION END # // SKABaseDevice.test_healthState_decorators def test_healthState(self, tango_context): """Test for healthState""" # PROTECTED REGION ID(SKABaseDevice.test_healthState) ENABLED START # - tango_context.device.healthState + assert tango_context.device.healthState == 0 # PROTECTED REGION END # // SKABaseDevice.test_healthState + # PROTECTED REGION ID(SKABaseDevice.test_adminMode_decorators) ENABLED START # + # PROTECTED REGION END # // SKABaseDevice.test_adminMode_decorators def test_adminMode(self, tango_context): """Test for adminMode""" # PROTECTED REGION ID(SKABaseDevice.test_adminMode) ENABLED START # - tango_context.device.adminMode + assert tango_context.device.adminMode == 0 # PROTECTED REGION END # // SKABaseDevice.test_adminMode + # PROTECTED REGION ID(SKABaseDevice.test_controlMode_decorators) ENABLED START # + # PROTECTED REGION END # // SKABaseDevice.test_controlMode_decorators def test_controlMode(self, tango_context): """Test for controlMode""" # PROTECTED REGION ID(SKABaseDevice.test_controlMode) ENABLED START # - tango_context.device.controlMode + assert tango_context.device.controlMode == 0 # PROTECTED REGION END # // SKABaseDevice.test_controlMode + # PROTECTED REGION ID(SKABaseDevice.test_simulationMode_decorators) ENABLED START # + # PROTECTED REGION END # // SKABaseDevice.test_simulationMode_decorators def test_simulationMode(self, tango_context): """Test for simulationMode""" # PROTECTED REGION ID(SKABaseDevice.test_simulationMode) ENABLED START # assert tango_context.device.simulationMode == False - tango_context.device.write_attribute("simulationMode", True) - assert tango_context.device.simulationMode == True # PROTECTED REGION END # // SKABaseDevice.test_simulationMode + # PROTECTED REGION ID(SKABaseDevice.test_testMode_decorators) ENABLED START # + # PROTECTED REGION END # // SKABaseDevice.test_testMode_decorators def test_testMode(self, tango_context): """Test for testMode""" # PROTECTED REGION ID(SKABaseDevice.test_testMode) ENABLED START # - tango_context.device.testMode + assert tango_context.device.testMode == '' # PROTECTED REGION END # // SKABaseDevice.test_testMode -# Main execution -if __name__ == "__main__": - main() diff --git a/skabase/SKACapability/SKACapability.xmi b/skabase/SKACapability/SKACapability.xmi index 05859ed113be94307449a2044f6c79798d99be2c..dbe93ee5631f904cdf60b74c97b9746a83996fd1 100644 --- a/skabase/SKACapability/SKACapability.xmi +++ b/skabase/SKACapability/SKACapability.xmi @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="ASCII"?> <pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl"> <classes name="SKACapability" pogoRevision="9.6"> - <description description="Subarray handling device" title="SKACapability" sourcePath="/home/tango-cs/src/levpro/skabase/SKACapability" language="PythonHL" filestogenerate="XMI file,Code files,Python Package,Protected Regions" license="GPL" copyright="" hasMandatoryProperty="true" hasConcreteProperty="true" hasAbstractCommand="true" hasAbstractAttribute="false"> + <description description="Subarray handling device" title="SKACapability" sourcePath="/home/pogo/src/levpro/skabase/SKACapability" language="PythonHL" filestogenerate="XMI file,Code files,Python Package,Protected Regions" license="GPL" copyright="" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="true" hasAbstractAttribute="false"> <inheritances classname="Device_Impl" sourcePath=""/> <inheritances classname="SKAObsDevice" sourcePath="../SKAObsDevice"/> <identification contact="at ska.ac.za - cam" author="cam" emailDomain="ska.ac.za" classFamily="SkaBase" siteSpecific="" platform="All Platforms" bus="Not Applicable" manufacturer="none" reference=""/> @@ -35,11 +35,11 @@ <type xsi:type="pogoDsl:StringVectorType"/> <status abstract="false" inherited="true" concrete="true"/> </deviceProperties> - <deviceProperties name="CapType" mandatory="true" description="The capability type represented by this device: E.g. for
CSP-MID it will be one of CORRELATORS; PSS-BEAMS;
PST-BEAMS; VLBI-BEAMS"> + <deviceProperties name="CapType" description="The capability type represented by this device: E.g. for
CSP-MID it will be one of CORRELATORS; PSS-BEAMS;
PST-BEAMS; VLBI-BEAMS"> <type xsi:type="pogoDsl:StringType"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </deviceProperties> - <deviceProperties name="CapID" mandatory="true" description="Unique identification of this capability device <SubId><CapType>
e.g. Sub13PssBeams."> + <deviceProperties name="CapID" description="Unique identification of this capability device <SubId><CapType>
e.g. Sub13PssBeams."> <type xsi:type="pogoDsl:StringType"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </deviceProperties> @@ -56,15 +56,6 @@ </argout> <status abstract="true" inherited="true" concrete="false"/> </commands> - <commands name="Reset" description="Reset device to its default state" execMethod="reset" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> - <argin description=""> - <type xsi:type="pogoDsl:VoidType"/> - </argin> - <argout description=""> - <type xsi:type="pogoDsl:VoidType"/> - </argout> - <status abstract="false" inherited="true" concrete="true" concreteHere="true"/> - </commands> <commands name="State" description="This command gets the device state (stored in its device_state data member) and returns it to the caller." execMethod="dev_state" displayLevel="OPERATOR" polledPeriod="0"> <argin description="none"> <type xsi:type="pogoDsl:VoidType"/> @@ -119,6 +110,15 @@ </argout> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </commands> + <commands name="Reset" description="Reset device to its default state" execMethod="reset" displayLevel="OPERATOR" polledPeriod="0"> + <argin description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argin> + <argout description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argout> + <status abstract="false" inherited="true" concrete="true"/> + </commands> <attributes name="activationTime" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="1000" maxX="" maxY="" allocReadMember="true" isDynamic="false"> <dataType xsi:type="pogoDsl:DoubleType"/> <changeEvent fire="false" libCheckCriteria="false"/> @@ -237,7 +237,7 @@ <states name="DISABLE" description="The device cannot be switched ON for an external reason. E.g. the power supply has its door open, the safety conditions are not satisfactory to allow the device to operate."> <status abstract="false" inherited="true" concrete="true"/> </states> - <preferences docHome="./doc_html" makefileHome="/usr/share/pogo/preferences"/> + <preferences docHome="./doc_html" makefileHome="$(TANGO_HOME)"/> <overlodedPollPeriodObject name="obsState" type="attribute" pollPeriod="0"/> <overlodedPollPeriodObject name="obsMode" type="attribute" pollPeriod="0"/> <overlodedPollPeriodObject name="configurationProgress" type="attribute" pollPeriod="0"/> diff --git a/skabase/SKACapability/SKACapability/SKACapability.py b/skabase/SKACapability/SKACapability/SKACapability.py index ee6cd82b4674e6e8659cb3c4e6eb7ab97765551a..370c6123620d152ad06cb83d798cef04d8d7de0d 100644 --- a/skabase/SKACapability/SKACapability/SKACapability.py +++ b/skabase/SKACapability/SKACapability/SKACapability.py @@ -49,12 +49,10 @@ class SKACapability(SKAObsDevice): CapType = device_property( dtype='str', - mandatory=True ) CapID = device_property( dtype='str', - mandatory=True ) subID = device_property( @@ -144,14 +142,6 @@ class SKACapability(SKAObsDevice): # Commands # -------- - @command( - ) - @DebugIt() - def Reset(self): - # PROTECTED REGION ID(SKACapability.Reset) ENABLED START # - pass - # PROTECTED REGION END # // SKACapability.Reset - @command( dtype_in='uint16', doc_in="The number of instances to configure for this Capability.", diff --git a/skabase/SKACapability/test/SKACapability_test.py b/skabase/SKACapability/test/SKACapability_test.py index 461a97a3c53b4cc15e0ccb666da63638f237f6aa..ffaf7bccc053399b5d1983feab23727db82adf9a 100644 --- a/skabase/SKACapability/test/SKACapability_test.py +++ b/skabase/SKACapability/test/SKACapability_test.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +######################################################################################### # -*- coding: utf-8 -*- # # This file is part of the SKACapability project @@ -7,6 +7,7 @@ # # Distributed under the terms of the GPL license. # See LICENSE.txt for more info. +######################################################################################### """Contain the tests for the SKACapability.""" # Path @@ -16,32 +17,33 @@ path = os.path.join(os.path.dirname(__file__), os.pardir) sys.path.insert(0, os.path.abspath(path)) # Imports -from time import sleep +import pytest from mock import MagicMock -from PyTango import DevFailed, DevState -from devicetest import DeviceTestCase, main -from SKACapability import SKACapability -# Note: -# -# Since the device uses an inner thread, it is necessary to -# wait during the tests in order the let the device update itself. -# Hence, the sleep calls have to be secured enough not to produce -# any inconsistent behavior. However, the unittests need to run fast. -# Here, we use a factor 3 between the read period and the sleep calls. -# -# Look at devicetest examples for more advanced testing +from PyTango import DevState + +# PROTECTED REGION ID(SKACapability.test_additional_imports) ENABLED START # +# PROTECTED REGION END # // SKACapability.test_additional_imports # Device test case -class SKACapabilityDeviceTestCase(DeviceTestCase): +@pytest.mark.usefixtures("tango_context", "initialize_device") +# PROTECTED REGION ID(SKACapability.test_SKACapability_decorators) ENABLED START # +# PROTECTED REGION END # // SKACapability.test_SKACapability_decorators +class TestSKACapability(object): """Test case for packet generation.""" - # PROTECTED REGION ID(SKACapability.test_additionnal_import) ENABLED START # - # PROTECTED REGION END # // SKACapability.test_additionnal_import - device = SKACapability - properties = {'SkaLevel': '4', 'CentralLoggingTarget': '', 'ElementLoggingTarget': '', 'StorageLoggingTarget': 'localhost', 'MetricList': 'healthState', 'GroupDefinitions': '', 'CapType': '', 'CapID': '', 'subID': '', - } - empty = None # Should be [] + + properties = { + 'SkaLevel': '4', + 'CentralLoggingTarget': '', + 'ElementLoggingTarget': '', + 'StorageLoggingTarget': 'localhost', + 'MetricList': 'healthState', + 'GroupDefinitions': '', + 'CapType': '', + 'CapID': '', + 'subID': '', + } @classmethod def mocking(cls): @@ -51,163 +53,211 @@ class SKACapabilityDeviceTestCase(DeviceTestCase): # PROTECTED REGION ID(SKACapability.test_mocking) ENABLED START # # PROTECTED REGION END # // SKACapability.test_mocking - def test_properties(self): - # test the properties + def test_properties(self, tango_context): + # Test the properties # PROTECTED REGION ID(SKACapability.test_properties) ENABLED START # # PROTECTED REGION END # // SKACapability.test_properties pass - def test_ObsState(self): + # PROTECTED REGION ID(SKACapability.test_ObsState_decorators) ENABLED START # + # PROTECTED REGION END # // SKACapability.test_ObsState_decorators + def test_ObsState(self, tango_context): """Test for ObsState""" # PROTECTED REGION ID(SKACapability.test_ObsState) ENABLED START # - self.device.ObsState() + assert tango_context.device.ObsState() == "" # PROTECTED REGION END # // SKACapability.test_ObsState - def test_Reset(self): - """Test for Reset""" - # PROTECTED REGION ID(SKACapability.test_Reset) ENABLED START # - self.device.Reset() - # PROTECTED REGION END # // SKACapability.test_Reset - - def test_State(self): + # PROTECTED REGION ID(SKACapability.test_State_decorators) ENABLED START # + # PROTECTED REGION END # // SKACapability.test_State_decorators + def test_State(self, tango_context): """Test for State""" # PROTECTED REGION ID(SKACapability.test_State) ENABLED START # - self.device.State() + assert tango_context.device.State() == DevState.UNKNOWN # PROTECTED REGION END # // SKACapability.test_State - def test_Status(self): + # PROTECTED REGION ID(SKACapability.test_Status_decorators) ENABLED START # + # PROTECTED REGION END # // SKACapability.test_Status_decorators + def test_Status(self, tango_context): """Test for Status""" # PROTECTED REGION ID(SKACapability.test_Status) ENABLED START # - self.device.Status() + assert tango_context.device.Status() == "The device is in UNKNOWN state." # PROTECTED REGION END # // SKACapability.test_Status - def test_GetMetrics(self): + # PROTECTED REGION ID(SKACapability.test_GetMetrics_decorators) ENABLED START # + # PROTECTED REGION END # // SKACapability.test_GetMetrics_decorators + def test_GetMetrics(self, tango_context): """Test for GetMetrics""" # PROTECTED REGION ID(SKACapability.test_GetMetrics) ENABLED START # - self.device.GetMetrics() + assert tango_context.device.GetMetrics() == "" # PROTECTED REGION END # // SKACapability.test_GetMetrics - def test_ToJson(self): + # PROTECTED REGION ID(SKACapability.test_ToJson_decorators) ENABLED START # + # PROTECTED REGION END # // SKACapability.test_ToJson_decorators + def test_ToJson(self, tango_context): """Test for ToJson""" # PROTECTED REGION ID(SKACapability.test_ToJson) ENABLED START # - self.device.ToJson("") + assert tango_context.device.ToJson("") == "" # PROTECTED REGION END # // SKACapability.test_ToJson - def test_GetVersionInfo(self): + # PROTECTED REGION ID(SKACapability.test_GetVersionInfo_decorators) ENABLED START # + # PROTECTED REGION END # // SKACapability.test_GetVersionInfo_decorators + def test_GetVersionInfo(self, tango_context): """Test for GetVersionInfo""" # PROTECTED REGION ID(SKACapability.test_GetVersionInfo) ENABLED START # - self.device.GetVersionInfo() + assert tango_context.device.GetVersionInfo() == [""] # PROTECTED REGION END # // SKACapability.test_GetVersionInfo - def test_ConfigureInstances(self): + # PROTECTED REGION ID(SKACapability.test_ConfigureInstances_decorators) ENABLED START # + # PROTECTED REGION END # // SKACapability.test_ConfigureInstances_decorators + def test_ConfigureInstances(self, tango_context): """Test for ConfigureInstances""" # PROTECTED REGION ID(SKACapability.test_ConfigureInstances) ENABLED START # - self.device.ConfigureInstances(0) + assert tango_context.device.ConfigureInstances(0) == None # PROTECTED REGION END # // SKACapability.test_ConfigureInstances - def test_activationTime(self): + # PROTECTED REGION ID(SKACapability.test_Reset_decorators) ENABLED START # + # PROTECTED REGION END # // SKACapability.test_Reset_decorators + def test_Reset(self, tango_context): + """Test for Reset""" + # PROTECTED REGION ID(SKACapability.test_Reset) ENABLED START # + assert tango_context.device.Reset() == None + # PROTECTED REGION END # // SKACapability.test_Reset + + + # PROTECTED REGION ID(SKACapability.test_activationTime_decorators) ENABLED START # + # PROTECTED REGION END # // SKACapability.test_activationTime_decorators + def test_activationTime(self, tango_context): """Test for activationTime""" # PROTECTED REGION ID(SKACapability.test_activationTime) ENABLED START # - self.device.activationTime + assert tango_context.device.activationTime == 0.0 # PROTECTED REGION END # // SKACapability.test_activationTime - def test_obsState(self): + # PROTECTED REGION ID(SKACapability.test_obsState_decorators) ENABLED START # + # PROTECTED REGION END # // SKACapability.test_obsState_decorators + def test_obsState(self, tango_context): """Test for obsState""" # PROTECTED REGION ID(SKACapability.test_obsState) ENABLED START # - self.device.obsState + assert tango_context.device.obsState == 0 # PROTECTED REGION END # // SKACapability.test_obsState - def test_obsMode(self): + # PROTECTED REGION ID(SKACapability.test_obsMode_decorators) ENABLED START # + # PROTECTED REGION END # // SKACapability.test_obsMode_decorators + def test_obsMode(self, tango_context): """Test for obsMode""" # PROTECTED REGION ID(SKACapability.test_obsMode) ENABLED START # - self.device.obsMode + assert tango_context.device.obsMode == 0 # PROTECTED REGION END # // SKACapability.test_obsMode - def test_configurationProgress(self): + # PROTECTED REGION ID(SKACapability.test_configurationProgress_decorators) ENABLED START # + # PROTECTED REGION END # // SKACapability.test_configurationProgress_decorators + def test_configurationProgress(self, tango_context): """Test for configurationProgress""" # PROTECTED REGION ID(SKACapability.test_configurationProgress) ENABLED START # - self.device.configurationProgress + assert tango_context.device.configurationProgress == 0 # PROTECTED REGION END # // SKACapability.test_configurationProgress - def test_configurationDelayExpected(self): + # PROTECTED REGION ID(SKACapability.test_configurationDelayExpected_decorators) ENABLED START # + # PROTECTED REGION END # // SKACapability.test_configurationDelayExpected_decorators + def test_configurationDelayExpected(self, tango_context): """Test for configurationDelayExpected""" # PROTECTED REGION ID(SKACapability.test_configurationDelayExpected) ENABLED START # - self.device.configurationDelayExpected + assert tango_context.device.configurationDelayExpected == 0 # PROTECTED REGION END # // SKACapability.test_configurationDelayExpected - def test_buildState(self): + # PROTECTED REGION ID(SKACapability.test_buildState_decorators) ENABLED START # + # PROTECTED REGION END # // SKACapability.test_buildState_decorators + def test_buildState(self, tango_context): """Test for buildState""" # PROTECTED REGION ID(SKACapability.test_buildState) ENABLED START # - self.device.buildState + assert tango_context.device.buildState == '' # PROTECTED REGION END # // SKACapability.test_buildState - def test_versionId(self): + # PROTECTED REGION ID(SKACapability.test_versionId_decorators) ENABLED START # + # PROTECTED REGION END # // SKACapability.test_versionId_decorators + def test_versionId(self, tango_context): """Test for versionId""" # PROTECTED REGION ID(SKACapability.test_versionId) ENABLED START # - self.device.versionId + assert tango_context.device.versionId == '' # PROTECTED REGION END # // SKACapability.test_versionId - def test_centralLoggingLevel(self): + # PROTECTED REGION ID(SKACapability.test_centralLoggingLevel_decorators) ENABLED START # + # PROTECTED REGION END # // SKACapability.test_centralLoggingLevel_decorators + def test_centralLoggingLevel(self, tango_context): """Test for centralLoggingLevel""" # PROTECTED REGION ID(SKACapability.test_centralLoggingLevel) ENABLED START # - self.device.centralLoggingLevel + assert tango_context.device.centralLoggingLevel == 0 # PROTECTED REGION END # // SKACapability.test_centralLoggingLevel - def test_elementLoggingLevel(self): + # PROTECTED REGION ID(SKACapability.test_elementLoggingLevel_decorators) ENABLED START # + # PROTECTED REGION END # // SKACapability.test_elementLoggingLevel_decorators + def test_elementLoggingLevel(self, tango_context): """Test for elementLoggingLevel""" # PROTECTED REGION ID(SKACapability.test_elementLoggingLevel) ENABLED START # - self.device.elementLoggingLevel + assert tango_context.device.elementLoggingLevel == 0 # PROTECTED REGION END # // SKACapability.test_elementLoggingLevel - def test_storageLoggingLevel(self): + # PROTECTED REGION ID(SKACapability.test_storageLoggingLevel_decorators) ENABLED START # + # PROTECTED REGION END # // SKACapability.test_storageLoggingLevel_decorators + def test_storageLoggingLevel(self, tango_context): """Test for storageLoggingLevel""" # PROTECTED REGION ID(SKACapability.test_storageLoggingLevel) ENABLED START # - self.device.storageLoggingLevel + assert tango_context.device.storageLoggingLevel == 0 # PROTECTED REGION END # // SKACapability.test_storageLoggingLevel - def test_healthState(self): + # PROTECTED REGION ID(SKACapability.test_healthState_decorators) ENABLED START # + # PROTECTED REGION END # // SKACapability.test_healthState_decorators + def test_healthState(self, tango_context): """Test for healthState""" # PROTECTED REGION ID(SKACapability.test_healthState) ENABLED START # - self.device.healthState + assert tango_context.device.healthState == 0 # PROTECTED REGION END # // SKACapability.test_healthState - def test_adminMode(self): + # PROTECTED REGION ID(SKACapability.test_adminMode_decorators) ENABLED START # + # PROTECTED REGION END # // SKACapability.test_adminMode_decorators + def test_adminMode(self, tango_context): """Test for adminMode""" # PROTECTED REGION ID(SKACapability.test_adminMode) ENABLED START # - self.device.adminMode + assert tango_context.device.adminMode == 0 # PROTECTED REGION END # // SKACapability.test_adminMode - def test_controlMode(self): + # PROTECTED REGION ID(SKACapability.test_controlMode_decorators) ENABLED START # + # PROTECTED REGION END # // SKACapability.test_controlMode_decorators + def test_controlMode(self, tango_context): """Test for controlMode""" # PROTECTED REGION ID(SKACapability.test_controlMode) ENABLED START # - self.device.controlMode + assert tango_context.device.controlMode == 0 # PROTECTED REGION END # // SKACapability.test_controlMode - def test_simulationMode(self): + # PROTECTED REGION ID(SKACapability.test_simulationMode_decorators) ENABLED START # + # PROTECTED REGION END # // SKACapability.test_simulationMode_decorators + def test_simulationMode(self, tango_context): """Test for simulationMode""" # PROTECTED REGION ID(SKACapability.test_simulationMode) ENABLED START # - self.device.simulationMode + assert tango_context.device.simulationMode == False # PROTECTED REGION END # // SKACapability.test_simulationMode - def test_testMode(self): + # PROTECTED REGION ID(SKACapability.test_testMode_decorators) ENABLED START # + # PROTECTED REGION END # // SKACapability.test_testMode_decorators + def test_testMode(self, tango_context): """Test for testMode""" # PROTECTED REGION ID(SKACapability.test_testMode) ENABLED START # - self.device.testMode + assert tango_context.device.testMode == '' # PROTECTED REGION END # // SKACapability.test_testMode - def test_configuredInstances(self): + # PROTECTED REGION ID(SKACapability.test_configuredInstances_decorators) ENABLED START # + # PROTECTED REGION END # // SKACapability.test_configuredInstances_decorators + def test_configuredInstances(self, tango_context): """Test for configuredInstances""" # PROTECTED REGION ID(SKACapability.test_configuredInstances) ENABLED START # - self.device.configuredInstances + assert tango_context.device.configuredInstances == 0 # PROTECTED REGION END # // SKACapability.test_configuredInstances - def test_usedComponents(self): + # PROTECTED REGION ID(SKACapability.test_usedComponents_decorators) ENABLED START # + # PROTECTED REGION END # // SKACapability.test_usedComponents_decorators + def test_usedComponents(self, tango_context): """Test for usedComponents""" # PROTECTED REGION ID(SKACapability.test_usedComponents) ENABLED START # - self.device.usedComponents + assert tango_context.device.usedComponents == ('',) # PROTECTED REGION END # // SKACapability.test_usedComponents -# Main execution -if __name__ == "__main__": - main() diff --git a/skabase/SKALogger/SKALogger.xmi b/skabase/SKALogger/SKALogger.xmi index 6dab222d5f7a154a522dab60a957f617d68bbfaa..3380aa6dd5537accdbf98678918bbe88acda3c34 100644 --- a/skabase/SKALogger/SKALogger.xmi +++ b/skabase/SKALogger/SKALogger.xmi @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="ASCII"?> <pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl"> <classes name="SKALogger" pogoRevision="9.6"> - <description description="A generic base device for Logging for SKA." title="SKALogger" sourcePath="/home/tango-cs/src/levpro/skabase/SKALogger" language="PythonHL" filestogenerate="XMI file,Code files,Python Package,Protected Regions" license="GPL" copyright="" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> + <description description="A generic base device for Logging for SKA." title="SKALogger" sourcePath="/home/pogo/src/levpro/skabase/SKALogger" language="PythonHL" filestogenerate="XMI file,Code files,Python Package,Protected Regions" license="GPL" copyright="" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> <inheritances classname="Device_Impl" sourcePath=""/> <inheritances classname="SKABaseDevice" sourcePath="../SKABaseDevice"/> <identification contact="at ska.ac.za - cam" author="cam" emailDomain="ska.ac.za" classFamily="OtherInstruments" siteSpecific="" platform="All Platforms" bus="Not Applicable" manufacturer="SKASA" reference="SKA-SKALogger"/> @@ -104,15 +104,6 @@ </argout> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </commands> - <commands name="Reset" description="Reset device to its default state" execMethod="reset" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> - <argin description=""> - <type xsi:type="pogoDsl:VoidType"/> - </argin> - <argout description=""> - <type xsi:type="pogoDsl:VoidType"/> - </argout> - <status abstract="false" inherited="true" concrete="true" concreteHere="true"/> - </commands> <commands name="GetMetrics" description="Gets list of attributes marked as metrics, with their values, 
for device" execMethod="get_metrics" displayLevel="OPERATOR" polledPeriod="0"> <argin description=""> <type xsi:type="pogoDsl:VoidType"/> @@ -140,6 +131,15 @@ </argout> <status abstract="false" inherited="true" concrete="true"/> </commands> + <commands name="Reset" description="Reset device to its default state" execMethod="reset" displayLevel="OPERATOR" polledPeriod="0"> + <argin description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argin> + <argout description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argout> + <status abstract="false" inherited="true" concrete="true"/> + </commands> <attributes name="buildState" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="60000" maxX="" maxY="" allocReadMember="true"> <dataType xsi:type="pogoDsl:StringType"/> <status abstract="false" inherited="true" concrete="true"/> @@ -214,6 +214,6 @@ <states name="DISABLE" description="The device cannot be switched ON for an external reason. E.g. the power supply has its door open, the safety conditions are not satisfactory to allow the device to operate."> <status abstract="false" inherited="true" concrete="true"/> </states> - <preferences docHome="./doc_html" makefileHome="/usr/share/pogo/preferences"/> + <preferences docHome="./doc_html" makefileHome="$(TANGO_HOME)"/> </classes> </pogoDsl:PogoSystem> diff --git a/skabase/SKALogger/SKALogger/SKALogger.py b/skabase/SKALogger/SKALogger/SKALogger.py index 6761bf3890b9cd6a4aa16514289415015b34c874..5bb0474f08c332f099924bfba2db2312a50c0ee4 100644 --- a/skabase/SKALogger/SKALogger/SKALogger.py +++ b/skabase/SKALogger/SKALogger/SKALogger.py @@ -159,14 +159,6 @@ class SKALogger(SKABaseDevice): pass # PROTECTED REGION END # // SKALogger.SetStorageLoggingLevel - @command( - ) - @DebugIt() - def Reset(self): - # PROTECTED REGION ID(SKALogger.Reset) ENABLED START # - pass - # PROTECTED REGION END # // SKALogger.Reset - # ---------- # Run server # ---------- diff --git a/skabase/SKALogger/test/SKALogger_test.py b/skabase/SKALogger/test/SKALogger_test.py index 65824447af7d8dfe0da4ab9270ea12eb78206f95..55b7d04267b2a93b605ba1126d1764c7cb1c254a 100644 --- a/skabase/SKALogger/test/SKALogger_test.py +++ b/skabase/SKALogger/test/SKALogger_test.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +######################################################################################### # -*- coding: utf-8 -*- # # This file is part of the SKALogger project @@ -7,6 +7,7 @@ # # Distributed under the terms of the GPL license. # See LICENSE.txt for more info. +######################################################################################### """Contain the tests for the SKALogger.""" # Path @@ -16,32 +17,33 @@ path = os.path.join(os.path.dirname(__file__), os.pardir) sys.path.insert(0, os.path.abspath(path)) # Imports -from time import sleep +import pytest from mock import MagicMock -from PyTango import DevFailed, DevState -from devicetest import DeviceTestCase, main -from SKALogger import SKALogger -# Note: -# -# Since the device uses an inner thread, it is necessary to -# wait during the tests in order the let the device update itself. -# Hence, the sleep calls have to be secured enough not to produce -# any inconsistent behavior. However, the unittests need to run fast. -# Here, we use a factor 3 between the read period and the sleep calls. -# -# Look at devicetest examples for more advanced testing +from PyTango import DevState + +# PROTECTED REGION ID(SKALogger.test_additional_imports) ENABLED START # +# PROTECTED REGION END # // SKALogger.test_additional_imports # Device test case -class SKALoggerDeviceTestCase(DeviceTestCase): +@pytest.mark.usefixtures("tango_context", "initialize_device") +# PROTECTED REGION ID(SKALogger.test_SKALogger_decorators) ENABLED START # +# PROTECTED REGION END # // SKALogger.test_SKALogger_decorators +class TestSKALogger(object): """Test case for packet generation.""" - # PROTECTED REGION ID(SKALogger.test_additionnal_import) ENABLED START # - # PROTECTED REGION END # // SKALogger.test_additionnal_import - device = SKALogger - properties = {'SkaLevel': '4', 'MetricList': 'healthState', 'GroupDefinitions': '', 'CentralLoggingTarget': '', 'ElementLoggingTarget': '', 'StorageLoggingTarget': 'localhost', 'CentralLoggingLevelDefault': '2', 'ElementLoggingLevelDefault': '3', 'StorageLoggingLevelDefault': '4', - } - empty = None # Should be [] + + properties = { + 'SkaLevel': '4', + 'MetricList': 'healthState', + 'GroupDefinitions': '', + 'CentralLoggingTarget': '', + 'ElementLoggingTarget': '', + 'StorageLoggingTarget': 'localhost', + 'CentralLoggingLevelDefault': '2', + 'ElementLoggingLevelDefault': '3', + 'StorageLoggingLevelDefault': '4', + } @classmethod def mocking(cls): @@ -51,133 +53,171 @@ class SKALoggerDeviceTestCase(DeviceTestCase): # PROTECTED REGION ID(SKALogger.test_mocking) ENABLED START # # PROTECTED REGION END # // SKALogger.test_mocking - def test_properties(self): - # test the properties + def test_properties(self, tango_context): + # Test the properties # PROTECTED REGION ID(SKALogger.test_properties) ENABLED START # # PROTECTED REGION END # // SKALogger.test_properties pass - def test_Log(self): + # PROTECTED REGION ID(SKALogger.test_Log_decorators) ENABLED START # + # PROTECTED REGION END # // SKALogger.test_Log_decorators + def test_Log(self, tango_context): """Test for Log""" # PROTECTED REGION ID(SKALogger.test_Log) ENABLED START # - self.device.Log([""]) + assert tango_context.device.Log([""]) == None # PROTECTED REGION END # // SKALogger.test_Log - def test_State(self): + # PROTECTED REGION ID(SKALogger.test_State_decorators) ENABLED START # + # PROTECTED REGION END # // SKALogger.test_State_decorators + def test_State(self, tango_context): """Test for State""" # PROTECTED REGION ID(SKALogger.test_State) ENABLED START # - self.device.State() + assert tango_context.device.State() == DevState.UNKNOWN # PROTECTED REGION END # // SKALogger.test_State - def test_Status(self): + # PROTECTED REGION ID(SKALogger.test_Status_decorators) ENABLED START # + # PROTECTED REGION END # // SKALogger.test_Status_decorators + def test_Status(self, tango_context): """Test for Status""" # PROTECTED REGION ID(SKALogger.test_Status) ENABLED START # - self.device.Status() + assert tango_context.device.Status() == "The device is in UNKNOWN state." # PROTECTED REGION END # // SKALogger.test_Status - def test_SetCentralLoggingLevel(self): + # PROTECTED REGION ID(SKALogger.test_SetCentralLoggingLevel_decorators) ENABLED START # + # PROTECTED REGION END # // SKALogger.test_SetCentralLoggingLevel_decorators + def test_SetCentralLoggingLevel(self, tango_context): """Test for SetCentralLoggingLevel""" # PROTECTED REGION ID(SKALogger.test_SetCentralLoggingLevel) ENABLED START # - self.device.SetCentralLoggingLevel("") + assert tango_context.device.SetCentralLoggingLevel("") == None # PROTECTED REGION END # // SKALogger.test_SetCentralLoggingLevel - def test_SetElementLoggingLevel(self): + # PROTECTED REGION ID(SKALogger.test_SetElementLoggingLevel_decorators) ENABLED START # + # PROTECTED REGION END # // SKALogger.test_SetElementLoggingLevel_decorators + def test_SetElementLoggingLevel(self, tango_context): """Test for SetElementLoggingLevel""" # PROTECTED REGION ID(SKALogger.test_SetElementLoggingLevel) ENABLED START # - self.device.SetElementLoggingLevel("") + assert tango_context.device.SetElementLoggingLevel("") == None # PROTECTED REGION END # // SKALogger.test_SetElementLoggingLevel - def test_SetStorageLoggingLevel(self): + # PROTECTED REGION ID(SKALogger.test_SetStorageLoggingLevel_decorators) ENABLED START # + # PROTECTED REGION END # // SKALogger.test_SetStorageLoggingLevel_decorators + def test_SetStorageLoggingLevel(self, tango_context): """Test for SetStorageLoggingLevel""" # PROTECTED REGION ID(SKALogger.test_SetStorageLoggingLevel) ENABLED START # - self.device.SetStorageLoggingLevel("") + assert tango_context.device.SetStorageLoggingLevel("") == None # PROTECTED REGION END # // SKALogger.test_SetStorageLoggingLevel - def test_Reset(self): - """Test for Reset""" - # PROTECTED REGION ID(SKALogger.test_Reset) ENABLED START # - self.device.Reset() - # PROTECTED REGION END # // SKALogger.test_Reset - - def test_GetMetrics(self): + # PROTECTED REGION ID(SKALogger.test_GetMetrics_decorators) ENABLED START # + # PROTECTED REGION END # // SKALogger.test_GetMetrics_decorators + def test_GetMetrics(self, tango_context): """Test for GetMetrics""" # PROTECTED REGION ID(SKALogger.test_GetMetrics) ENABLED START # - self.device.GetMetrics() + assert tango_context.device.GetMetrics() == "" # PROTECTED REGION END # // SKALogger.test_GetMetrics - def test_ToJson(self): + # PROTECTED REGION ID(SKALogger.test_ToJson_decorators) ENABLED START # + # PROTECTED REGION END # // SKALogger.test_ToJson_decorators + def test_ToJson(self, tango_context): """Test for ToJson""" # PROTECTED REGION ID(SKALogger.test_ToJson) ENABLED START # - self.device.ToJson("") + assert tango_context.device.ToJson("") == "" # PROTECTED REGION END # // SKALogger.test_ToJson - def test_GetVersionInfo(self): + # PROTECTED REGION ID(SKALogger.test_GetVersionInfo_decorators) ENABLED START # + # PROTECTED REGION END # // SKALogger.test_GetVersionInfo_decorators + def test_GetVersionInfo(self, tango_context): """Test for GetVersionInfo""" # PROTECTED REGION ID(SKALogger.test_GetVersionInfo) ENABLED START # - self.device.GetVersionInfo() + assert tango_context.device.GetVersionInfo() == [""] # PROTECTED REGION END # // SKALogger.test_GetVersionInfo - def test_buildState(self): + # PROTECTED REGION ID(SKALogger.test_Reset_decorators) ENABLED START # + # PROTECTED REGION END # // SKALogger.test_Reset_decorators + def test_Reset(self, tango_context): + """Test for Reset""" + # PROTECTED REGION ID(SKALogger.test_Reset) ENABLED START # + assert tango_context.device.Reset() == None + # PROTECTED REGION END # // SKALogger.test_Reset + + + # PROTECTED REGION ID(SKALogger.test_buildState_decorators) ENABLED START # + # PROTECTED REGION END # // SKALogger.test_buildState_decorators + def test_buildState(self, tango_context): """Test for buildState""" # PROTECTED REGION ID(SKALogger.test_buildState) ENABLED START # - self.device.buildState + assert tango_context.device.buildState == '' # PROTECTED REGION END # // SKALogger.test_buildState - def test_versionId(self): + # PROTECTED REGION ID(SKALogger.test_versionId_decorators) ENABLED START # + # PROTECTED REGION END # // SKALogger.test_versionId_decorators + def test_versionId(self, tango_context): """Test for versionId""" # PROTECTED REGION ID(SKALogger.test_versionId) ENABLED START # - self.device.versionId + assert tango_context.device.versionId == '' # PROTECTED REGION END # // SKALogger.test_versionId - def test_centralLoggingLevel(self): + # PROTECTED REGION ID(SKALogger.test_centralLoggingLevel_decorators) ENABLED START # + # PROTECTED REGION END # // SKALogger.test_centralLoggingLevel_decorators + def test_centralLoggingLevel(self, tango_context): """Test for centralLoggingLevel""" # PROTECTED REGION ID(SKALogger.test_centralLoggingLevel) ENABLED START # - self.device.centralLoggingLevel + assert tango_context.device.centralLoggingLevel == 0 # PROTECTED REGION END # // SKALogger.test_centralLoggingLevel - def test_elementLoggingLevel(self): + # PROTECTED REGION ID(SKALogger.test_elementLoggingLevel_decorators) ENABLED START # + # PROTECTED REGION END # // SKALogger.test_elementLoggingLevel_decorators + def test_elementLoggingLevel(self, tango_context): """Test for elementLoggingLevel""" # PROTECTED REGION ID(SKALogger.test_elementLoggingLevel) ENABLED START # - self.device.elementLoggingLevel + assert tango_context.device.elementLoggingLevel == 0 # PROTECTED REGION END # // SKALogger.test_elementLoggingLevel - def test_storageLoggingLevel(self): + # PROTECTED REGION ID(SKALogger.test_storageLoggingLevel_decorators) ENABLED START # + # PROTECTED REGION END # // SKALogger.test_storageLoggingLevel_decorators + def test_storageLoggingLevel(self, tango_context): """Test for storageLoggingLevel""" # PROTECTED REGION ID(SKALogger.test_storageLoggingLevel) ENABLED START # - self.device.storageLoggingLevel + assert tango_context.device.storageLoggingLevel == 0 # PROTECTED REGION END # // SKALogger.test_storageLoggingLevel - def test_healthState(self): + # PROTECTED REGION ID(SKALogger.test_healthState_decorators) ENABLED START # + # PROTECTED REGION END # // SKALogger.test_healthState_decorators + def test_healthState(self, tango_context): """Test for healthState""" # PROTECTED REGION ID(SKALogger.test_healthState) ENABLED START # - self.device.healthState + assert tango_context.device.healthState == 0 # PROTECTED REGION END # // SKALogger.test_healthState - def test_adminMode(self): + # PROTECTED REGION ID(SKALogger.test_adminMode_decorators) ENABLED START # + # PROTECTED REGION END # // SKALogger.test_adminMode_decorators + def test_adminMode(self, tango_context): """Test for adminMode""" # PROTECTED REGION ID(SKALogger.test_adminMode) ENABLED START # - self.device.adminMode + assert tango_context.device.adminMode == 0 # PROTECTED REGION END # // SKALogger.test_adminMode - def test_controlMode(self): + # PROTECTED REGION ID(SKALogger.test_controlMode_decorators) ENABLED START # + # PROTECTED REGION END # // SKALogger.test_controlMode_decorators + def test_controlMode(self, tango_context): """Test for controlMode""" # PROTECTED REGION ID(SKALogger.test_controlMode) ENABLED START # - self.device.controlMode + assert tango_context.device.controlMode == 0 # PROTECTED REGION END # // SKALogger.test_controlMode - def test_simulationMode(self): + # PROTECTED REGION ID(SKALogger.test_simulationMode_decorators) ENABLED START # + # PROTECTED REGION END # // SKALogger.test_simulationMode_decorators + def test_simulationMode(self, tango_context): """Test for simulationMode""" # PROTECTED REGION ID(SKALogger.test_simulationMode) ENABLED START # - self.device.simulationMode + assert tango_context.device.simulationMode == False # PROTECTED REGION END # // SKALogger.test_simulationMode - def test_testMode(self): + # PROTECTED REGION ID(SKALogger.test_testMode_decorators) ENABLED START # + # PROTECTED REGION END # // SKALogger.test_testMode_decorators + def test_testMode(self, tango_context): """Test for testMode""" # PROTECTED REGION ID(SKALogger.test_testMode) ENABLED START # - self.device.testMode + assert tango_context.device.testMode == '' # PROTECTED REGION END # // SKALogger.test_testMode -# Main execution -if __name__ == "__main__": - main() diff --git a/skabase/SKAMaster/SKAMaster.xmi b/skabase/SKAMaster/SKAMaster.xmi index e25471e92296a3c90bc01a43dd4c70696546495d..baf5efda881c791da34471f521896c495afc1089 100644 --- a/skabase/SKAMaster/SKAMaster.xmi +++ b/skabase/SKAMaster/SKAMaster.xmi @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="ASCII"?> <pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl"> <classes name="SKAMaster" pogoRevision="9.6"> - <description description="A master test" title="SKAMaster" sourcePath="/home/kat/src/levpro/skabase/SKAMaster" language="PythonHL" filestogenerate="XMI file,Code files, Python Package, Protected Regions" license="GPL" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="true" hasAbstractAttribute="false"> + <description description="A master test" title="SKAMaster" sourcePath="/home/pogo/src/levpro/skabase/SKAMaster" language="PythonHL" filestogenerate="XMI file,Code files,Python Package,Protected Regions" license="GPL" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> <inheritances classname="Device_Impl" sourcePath=""/> <inheritances classname="SKABaseDevice" sourcePath="../SKABaseDevice"/> <identification contact="at ska.ac.za - cam" author="cam" emailDomain="ska.ac.za" classFamily="SkaBase" siteSpecific="" platform="All Platforms" bus="Not Applicable" manufacturer="none" reference=""/> @@ -25,9 +25,11 @@ <DefaultPropValue>localhost</DefaultPropValue> </deviceProperties> <deviceProperties name="MetricList" description="A subset of attributes we want to expose as metrics for this device."> - <type xsi:type="pogoDsl:StringType"/> + <type xsi:type="pogoDsl:StringVectorType"/> <status abstract="false" inherited="true" concrete="true"/> - <DefaultPropValue>healthState,adminMode,controlMode</DefaultPropValue> + <DefaultPropValue>healthState</DefaultPropValue> + <DefaultPropValue>adminMode</DefaultPropValue> + <DefaultPropValue>controlMode</DefaultPropValue> </deviceProperties> <deviceProperties name="GroupDefinitions" description="Each string in the list is a JSON serialised dict defining the ``group_name``,
``devices`` and ``subgroups`` in the group. A TANGO Group object is created
for each item in the list, according to the hierarchy defined. This provides
easy access to the managed devices in bulk, or individually.

The general format of the list is as follows, with optional ``devices`` and
``subgroups`` keys:
 [ {``group_name``: ``<name>``,
 ``devices``: [``<dev name>``, ...]},
 {``group_name``: ``<name>``,
 ``devices``: [``<dev name>``, ``<dev name>``, ...],
 ``subgroups`` : [{<nested group>},
 {<nested group>}, ...]},
 ...
 ]

For example, a hierarchy of racks, servers and switches:
 [ {``group_name``: ``servers``,
 ``devices``: [``elt/server/1``, ``elt/server/2``,
 ``elt/server/3``, ``elt/server/4``]},
 {``group_name``: ``switches``,
 ``devices``: [``elt/switch/A``, ``elt/switch/B``]},
 {``group_name``: ``pdus``,
 ``devices``: [``elt/pdu/rackA``, ``elt/pdu/rackB``]},
 {``group_name``: ``racks``,
 ``subgroups``: [
 {``group_name``: ``rackA``,
 ``devices``: [``elt/server/1``, ``elt/server/2``,
 ``elt/switch/A``, ``elt/pdu/rackA``]},
 {``group_name``: ``rackB``,
 ``devices``: [``elt/server/3``, ``elt/server/4``,
 ``elt/switch/B``, ``elt/pdu/rackB``],
 ``subgroups``: []}
 ]} ]"> <type xsi:type="pogoDsl:StringVectorType"/> @@ -46,15 +48,6 @@ <type xsi:type="pogoDsl:StringVectorType"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </deviceProperties> - <commands name="Reset" description="Reset device to its default state" execMethod="reset" displayLevel="OPERATOR" polledPeriod="0"> - <argin description=""> - <type xsi:type="pogoDsl:VoidType"/> - </argin> - <argout description=""> - <type xsi:type="pogoDsl:VoidType"/> - </argout> - <status abstract="true" inherited="true" concrete="false"/> - </commands> <commands name="State" description="This command gets the device state (stored in its device_state data member) and returns it to the caller." execMethod="dev_state" displayLevel="OPERATOR" polledPeriod="0"> <argin description="none"> <type xsi:type="pogoDsl:VoidType"/> @@ -109,6 +102,15 @@ </argout> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </commands> + <commands name="Reset" description="Reset device to its default state" execMethod="reset" displayLevel="OPERATOR" polledPeriod="0"> + <argin description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argin> + <argout description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argout> + <status abstract="false" inherited="true" concrete="true"/> + </commands> <attributes name="elementLoggerAddress" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="60000" maxX="" maxY="" allocReadMember="true" isDynamic="false"> <dataType xsi:type="pogoDsl:StringType"/> <changeEvent fire="false" libCheckCriteria="false"/> @@ -251,6 +253,6 @@ <states name="DISABLE" description="The device cannot be switched ON for an external reason. E.g. the power supply has its door open, the safety conditions are not satisfactory to allow the device to operate."> <status abstract="false" inherited="true" concrete="true"/> </states> - <preferences docHome="./doc_html" makefileHome="/usr/share/pogo/preferences"/> + <preferences docHome="./doc_html" makefileHome="$(TANGO_HOME)"/> </classes> </pogoDsl:PogoSystem> diff --git a/skabase/SKAMaster/test/SKAMaster_test.py b/skabase/SKAMaster/test/SKAMaster_test.py index 47005310be75aa7d83f899734190af921f045e5f..481f1386931c69f289a4612afae41528f57b143a 100644 --- a/skabase/SKAMaster/test/SKAMaster_test.py +++ b/skabase/SKAMaster/test/SKAMaster_test.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +######################################################################################### # -*- coding: utf-8 -*- # # This file is part of the SKAMaster project @@ -7,6 +7,7 @@ # # Distributed under the terms of the GPL license. # See LICENSE.txt for more info. +######################################################################################### """Contain the tests for the SKAMaster.""" # Path @@ -16,32 +17,33 @@ path = os.path.join(os.path.dirname(__file__), os.pardir) sys.path.insert(0, os.path.abspath(path)) # Imports -from time import sleep +import pytest from mock import MagicMock -from PyTango import DevFailed, DevState -from devicetest import DeviceTestCase, main -from SKAMaster import SKAMaster -# Note: -# -# Since the device uses an inner thread, it is necessary to -# wait during the tests in order the let the device update itself. -# Hence, the sleep calls have to be secured enough not to produce -# any inconsistent behavior. However, the unittests need to run fast. -# Here, we use a factor 3 between the read period and the sleep calls. -# -# Look at devicetest examples for more advanced testing +from PyTango import DevState + +# PROTECTED REGION ID(SKAMaster.test_additional_imports) ENABLED START # +# PROTECTED REGION END # // SKAMaster.test_additional_imports # Device test case -class SKAMasterDeviceTestCase(DeviceTestCase): +@pytest.mark.usefixtures("tango_context", "initialize_device") +# PROTECTED REGION ID(SKAMaster.test_SKAMaster_decorators) ENABLED START # +# PROTECTED REGION END # // SKAMaster.test_SKAMaster_decorators +class TestSKAMaster(object): """Test case for packet generation.""" - # PROTECTED REGION ID(SKAMaster.test_additionnal_import) ENABLED START # - # PROTECTED REGION END # // SKAMaster.test_additionnal_import - device = SKAMaster - properties = {'SkaLevel': '4', 'CentralLoggingTarget': '', 'ElementLoggingTarget': '', 'StorageLoggingTarget': 'localhost', 'MetricList': 'healthState,adminMode,controlMode', 'GroupDefinitions': '', 'NrSubarrays': '16', 'CapabilityTypes': '', 'MaxCapabilities': '', - } - empty = None # Should be [] + + properties = { + 'SkaLevel': '4', + 'CentralLoggingTarget': '', + 'ElementLoggingTarget': '', + 'StorageLoggingTarget': 'localhost', + 'MetricList': 'healthState', + 'GroupDefinitions': '', + 'NrSubarrays': '16', + 'CapabilityTypes': '', + 'MaxCapabilities': '', + } @classmethod def mocking(cls): @@ -51,151 +53,195 @@ class SKAMasterDeviceTestCase(DeviceTestCase): # PROTECTED REGION ID(SKAMaster.test_mocking) ENABLED START # # PROTECTED REGION END # // SKAMaster.test_mocking - def test_properties(self): - # test the properties + def test_properties(self, tango_context): + # Test the properties # PROTECTED REGION ID(SKAMaster.test_properties) ENABLED START # # PROTECTED REGION END # // SKAMaster.test_properties pass - def test_Reset(self): - """Test for Reset""" - # PROTECTED REGION ID(SKAMaster.test_Reset) ENABLED START # - self.device.Reset() - # PROTECTED REGION END # // SKAMaster.test_Reset - - def test_State(self): + # PROTECTED REGION ID(SKAMaster.test_State_decorators) ENABLED START # + # PROTECTED REGION END # // SKAMaster.test_State_decorators + def test_State(self, tango_context): """Test for State""" # PROTECTED REGION ID(SKAMaster.test_State) ENABLED START # - self.device.State() + assert tango_context.device.State() == DevState.UNKNOWN # PROTECTED REGION END # // SKAMaster.test_State - def test_Status(self): + # PROTECTED REGION ID(SKAMaster.test_Status_decorators) ENABLED START # + # PROTECTED REGION END # // SKAMaster.test_Status_decorators + def test_Status(self, tango_context): """Test for Status""" # PROTECTED REGION ID(SKAMaster.test_Status) ENABLED START # - self.device.Status() + assert tango_context.device.Status() == "The device is in UNKNOWN state." # PROTECTED REGION END # // SKAMaster.test_Status - def test_GetMetrics(self): + # PROTECTED REGION ID(SKAMaster.test_GetMetrics_decorators) ENABLED START # + # PROTECTED REGION END # // SKAMaster.test_GetMetrics_decorators + def test_GetMetrics(self, tango_context): """Test for GetMetrics""" # PROTECTED REGION ID(SKAMaster.test_GetMetrics) ENABLED START # - self.device.GetMetrics() + assert tango_context.device.GetMetrics() == "" # PROTECTED REGION END # // SKAMaster.test_GetMetrics - def test_ToJson(self): + # PROTECTED REGION ID(SKAMaster.test_ToJson_decorators) ENABLED START # + # PROTECTED REGION END # // SKAMaster.test_ToJson_decorators + def test_ToJson(self, tango_context): """Test for ToJson""" # PROTECTED REGION ID(SKAMaster.test_ToJson) ENABLED START # - self.device.ToJson("") + assert tango_context.device.ToJson("") == "" # PROTECTED REGION END # // SKAMaster.test_ToJson - def test_GetVersionInfo(self): + # PROTECTED REGION ID(SKAMaster.test_GetVersionInfo_decorators) ENABLED START # + # PROTECTED REGION END # // SKAMaster.test_GetVersionInfo_decorators + def test_GetVersionInfo(self, tango_context): """Test for GetVersionInfo""" # PROTECTED REGION ID(SKAMaster.test_GetVersionInfo) ENABLED START # - self.device.GetVersionInfo() + assert tango_context.device.GetVersionInfo() == [""] # PROTECTED REGION END # // SKAMaster.test_GetVersionInfo - def test_isCapabilityAchievable(self): + # PROTECTED REGION ID(SKAMaster.test_isCapabilityAchievable_decorators) ENABLED START # + # PROTECTED REGION END # // SKAMaster.test_isCapabilityAchievable_decorators + def test_isCapabilityAchievable(self, tango_context): """Test for isCapabilityAchievable""" # PROTECTED REGION ID(SKAMaster.test_isCapabilityAchievable) ENABLED START # - self.device.isCapabilityAchievable([""]) + assert tango_context.device.isCapabilityAchievable([[0], [""]]) == False # PROTECTED REGION END # // SKAMaster.test_isCapabilityAchievable - def test_elementLoggerAddress(self): + # PROTECTED REGION ID(SKAMaster.test_Reset_decorators) ENABLED START # + # PROTECTED REGION END # // SKAMaster.test_Reset_decorators + def test_Reset(self, tango_context): + """Test for Reset""" + # PROTECTED REGION ID(SKAMaster.test_Reset) ENABLED START # + assert tango_context.device.Reset() == None + # PROTECTED REGION END # // SKAMaster.test_Reset + + + # PROTECTED REGION ID(SKAMaster.test_elementLoggerAddress_decorators) ENABLED START # + # PROTECTED REGION END # // SKAMaster.test_elementLoggerAddress_decorators + def test_elementLoggerAddress(self, tango_context): """Test for elementLoggerAddress""" # PROTECTED REGION ID(SKAMaster.test_elementLoggerAddress) ENABLED START # - self.device.elementLoggerAddress + assert tango_context.device.elementLoggerAddress == '' # PROTECTED REGION END # // SKAMaster.test_elementLoggerAddress - def test_elementAlarmAddress(self): + # PROTECTED REGION ID(SKAMaster.test_elementAlarmAddress_decorators) ENABLED START # + # PROTECTED REGION END # // SKAMaster.test_elementAlarmAddress_decorators + def test_elementAlarmAddress(self, tango_context): """Test for elementAlarmAddress""" # PROTECTED REGION ID(SKAMaster.test_elementAlarmAddress) ENABLED START # - self.device.elementAlarmAddress + assert tango_context.device.elementAlarmAddress == '' # PROTECTED REGION END # // SKAMaster.test_elementAlarmAddress - def test_elementTelStateAddress(self): + # PROTECTED REGION ID(SKAMaster.test_elementTelStateAddress_decorators) ENABLED START # + # PROTECTED REGION END # // SKAMaster.test_elementTelStateAddress_decorators + def test_elementTelStateAddress(self, tango_context): """Test for elementTelStateAddress""" # PROTECTED REGION ID(SKAMaster.test_elementTelStateAddress) ENABLED START # - self.device.elementTelStateAddress + assert tango_context.device.elementTelStateAddress == '' # PROTECTED REGION END # // SKAMaster.test_elementTelStateAddress - def test_elementDatabaseAddress(self): + # PROTECTED REGION ID(SKAMaster.test_elementDatabaseAddress_decorators) ENABLED START # + # PROTECTED REGION END # // SKAMaster.test_elementDatabaseAddress_decorators + def test_elementDatabaseAddress(self, tango_context): """Test for elementDatabaseAddress""" # PROTECTED REGION ID(SKAMaster.test_elementDatabaseAddress) ENABLED START # - self.device.elementDatabaseAddress + assert tango_context.device.elementDatabaseAddress == '' # PROTECTED REGION END # // SKAMaster.test_elementDatabaseAddress - def test_buildState(self): + # PROTECTED REGION ID(SKAMaster.test_buildState_decorators) ENABLED START # + # PROTECTED REGION END # // SKAMaster.test_buildState_decorators + def test_buildState(self, tango_context): """Test for buildState""" # PROTECTED REGION ID(SKAMaster.test_buildState) ENABLED START # - self.device.buildState + assert tango_context.device.buildState == '' # PROTECTED REGION END # // SKAMaster.test_buildState - def test_versionId(self): + # PROTECTED REGION ID(SKAMaster.test_versionId_decorators) ENABLED START # + # PROTECTED REGION END # // SKAMaster.test_versionId_decorators + def test_versionId(self, tango_context): """Test for versionId""" # PROTECTED REGION ID(SKAMaster.test_versionId) ENABLED START # - self.device.versionId + assert tango_context.device.versionId == '' # PROTECTED REGION END # // SKAMaster.test_versionId - def test_centralLoggingLevel(self): + # PROTECTED REGION ID(SKAMaster.test_centralLoggingLevel_decorators) ENABLED START # + # PROTECTED REGION END # // SKAMaster.test_centralLoggingLevel_decorators + def test_centralLoggingLevel(self, tango_context): """Test for centralLoggingLevel""" # PROTECTED REGION ID(SKAMaster.test_centralLoggingLevel) ENABLED START # - self.device.centralLoggingLevel + assert tango_context.device.centralLoggingLevel == 0 # PROTECTED REGION END # // SKAMaster.test_centralLoggingLevel - def test_elementLoggingLevel(self): + # PROTECTED REGION ID(SKAMaster.test_elementLoggingLevel_decorators) ENABLED START # + # PROTECTED REGION END # // SKAMaster.test_elementLoggingLevel_decorators + def test_elementLoggingLevel(self, tango_context): """Test for elementLoggingLevel""" # PROTECTED REGION ID(SKAMaster.test_elementLoggingLevel) ENABLED START # - self.device.elementLoggingLevel + assert tango_context.device.elementLoggingLevel == 0 # PROTECTED REGION END # // SKAMaster.test_elementLoggingLevel - def test_storageLoggingLevel(self): + # PROTECTED REGION ID(SKAMaster.test_storageLoggingLevel_decorators) ENABLED START # + # PROTECTED REGION END # // SKAMaster.test_storageLoggingLevel_decorators + def test_storageLoggingLevel(self, tango_context): """Test for storageLoggingLevel""" # PROTECTED REGION ID(SKAMaster.test_storageLoggingLevel) ENABLED START # - self.device.storageLoggingLevel + assert tango_context.device.storageLoggingLevel == 0 # PROTECTED REGION END # // SKAMaster.test_storageLoggingLevel - def test_healthState(self): + # PROTECTED REGION ID(SKAMaster.test_healthState_decorators) ENABLED START # + # PROTECTED REGION END # // SKAMaster.test_healthState_decorators + def test_healthState(self, tango_context): """Test for healthState""" # PROTECTED REGION ID(SKAMaster.test_healthState) ENABLED START # - self.device.healthState + assert tango_context.device.healthState == 0 # PROTECTED REGION END # // SKAMaster.test_healthState - def test_adminMode(self): + # PROTECTED REGION ID(SKAMaster.test_adminMode_decorators) ENABLED START # + # PROTECTED REGION END # // SKAMaster.test_adminMode_decorators + def test_adminMode(self, tango_context): """Test for adminMode""" # PROTECTED REGION ID(SKAMaster.test_adminMode) ENABLED START # - self.device.adminMode + assert tango_context.device.adminMode == 0 # PROTECTED REGION END # // SKAMaster.test_adminMode - def test_controlMode(self): + # PROTECTED REGION ID(SKAMaster.test_controlMode_decorators) ENABLED START # + # PROTECTED REGION END # // SKAMaster.test_controlMode_decorators + def test_controlMode(self, tango_context): """Test for controlMode""" # PROTECTED REGION ID(SKAMaster.test_controlMode) ENABLED START # - self.device.controlMode + assert tango_context.device.controlMode == 0 # PROTECTED REGION END # // SKAMaster.test_controlMode - def test_simulationMode(self): + # PROTECTED REGION ID(SKAMaster.test_simulationMode_decorators) ENABLED START # + # PROTECTED REGION END # // SKAMaster.test_simulationMode_decorators + def test_simulationMode(self, tango_context): """Test for simulationMode""" # PROTECTED REGION ID(SKAMaster.test_simulationMode) ENABLED START # - self.device.simulationMode + assert tango_context.device.simulationMode == False # PROTECTED REGION END # // SKAMaster.test_simulationMode - def test_testMode(self): + # PROTECTED REGION ID(SKAMaster.test_testMode_decorators) ENABLED START # + # PROTECTED REGION END # // SKAMaster.test_testMode_decorators + def test_testMode(self, tango_context): """Test for testMode""" # PROTECTED REGION ID(SKAMaster.test_testMode) ENABLED START # - self.device.testMode + assert tango_context.device.testMode == '' # PROTECTED REGION END # // SKAMaster.test_testMode - def test_maxCapabilities(self): + # PROTECTED REGION ID(SKAMaster.test_maxCapabilities_decorators) ENABLED START # + # PROTECTED REGION END # // SKAMaster.test_maxCapabilities_decorators + def test_maxCapabilities(self, tango_context): """Test for maxCapabilities""" # PROTECTED REGION ID(SKAMaster.test_maxCapabilities) ENABLED START # - self.device.maxCapabilities + assert tango_context.device.maxCapabilities == ('',) # PROTECTED REGION END # // SKAMaster.test_maxCapabilities - def test_availableCapabilities(self): + # PROTECTED REGION ID(SKAMaster.test_availableCapabilities_decorators) ENABLED START # + # PROTECTED REGION END # // SKAMaster.test_availableCapabilities_decorators + def test_availableCapabilities(self, tango_context): """Test for availableCapabilities""" # PROTECTED REGION ID(SKAMaster.test_availableCapabilities) ENABLED START # - self.device.availableCapabilities + assert tango_context.device.availableCapabilities == ('',) # PROTECTED REGION END # // SKAMaster.test_availableCapabilities -# Main execution -if __name__ == "__main__": - main() diff --git a/skabase/SKAObsDevice/SKAObsDevice.xmi b/skabase/SKAObsDevice/SKAObsDevice.xmi index 32b9d742af1b9891858cc7d58d5b49d8c3deda7a..4573c2aa712cc630e6766c05ec595b7c34e4a15c 100644 --- a/skabase/SKAObsDevice/SKAObsDevice.xmi +++ b/skabase/SKAObsDevice/SKAObsDevice.xmi @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="ASCII"?> <pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl"> <classes name="SKAObsDevice" pogoRevision="9.6"> - <description description="A generic base device for Observations for SKA." title="SKAObsDevice" sourcePath="/home/tango-cs/src/levpro/skabase/SKAObsDevice" language="PythonHL" filestogenerate="XMI file,Code files,Python Package,Protected Regions" license="GPL" copyright="" hasMandatoryProperty="false" hasConcreteProperty="false" hasAbstractCommand="true" hasAbstractAttribute="false"> + <description description="A generic base device for Observations for SKA." title="SKAObsDevice" sourcePath="/home/pogo/src/levpro/skabase/SKAObsDevice" language="PythonHL" filestogenerate="XMI file,Code files,Python Package,Protected Regions" license="GPL" copyright="" hasMandatoryProperty="false" hasConcreteProperty="false" hasAbstractCommand="true" hasAbstractAttribute="false"> <inheritances classname="Device_Impl" sourcePath=""/> <inheritances classname="SKABaseDevice" sourcePath="../SKABaseDevice"/> <identification contact="at ska.ac.za - cam" author="cam" emailDomain="ska.ac.za" classFamily="OtherInstruments" siteSpecific="" platform="All Platforms" bus="Not Applicable" manufacturer="SKASA" reference="SKA-SKAObsDevice"/> @@ -44,15 +44,6 @@ </argout> <status abstract="true" inherited="false" concrete="false" concreteHere="false"/> </commands> - <commands name="Reset" description="Reset device to its default state" execMethod="reset" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> - <argin description=""> - <type xsi:type="pogoDsl:VoidType"/> - </argin> - <argout description=""> - <type xsi:type="pogoDsl:VoidType"/> - </argout> - <status abstract="false" inherited="true" concrete="true" concreteHere="true"/> - </commands> <commands name="State" description="This command gets the device state (stored in its device_state data member) and returns it to the caller." execMethod="dev_state" displayLevel="OPERATOR" polledPeriod="0"> <argin description="none"> <type xsi:type="pogoDsl:VoidType"/> @@ -98,10 +89,17 @@ </argout> <status abstract="false" inherited="true" concrete="true"/> </commands> + <commands name="Reset" description="Reset device to its default state" execMethod="reset" displayLevel="OPERATOR" polledPeriod="0"> + <argin description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argin> + <argout description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argout> + <status abstract="false" inherited="true" concrete="true"/> + </commands> <attributes name="obsState" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="1000" maxX="" maxY="" allocReadMember="true" isDynamic="false"> <dataType xsi:type="pogoDsl:EnumType"/> - <changeEvent fire="false" libCheckCriteria="false"/> - <archiveEvent fire="false" libCheckCriteria="false"/> <dataReadyEvent fire="false" libCheckCriteria="true"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> <properties description="Observing State" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> @@ -115,8 +113,6 @@ </attributes> <attributes name="obsMode" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="1000" maxX="" maxY="" allocReadMember="true" isDynamic="false"> <dataType xsi:type="pogoDsl:EnumType"/> - <changeEvent fire="false" libCheckCriteria="false"/> - <archiveEvent fire="false" libCheckCriteria="false"/> <dataReadyEvent fire="false" libCheckCriteria="true"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> <properties description="Observing Mode" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> @@ -132,87 +128,63 @@ </attributes> <attributes name="configurationProgress" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="1000" maxX="" maxY="" allocReadMember="true" isDynamic="false"> <dataType xsi:type="pogoDsl:UShortType"/> - <changeEvent fire="false" libCheckCriteria="false"/> - <archiveEvent fire="false" libCheckCriteria="false"/> <dataReadyEvent fire="false" libCheckCriteria="true"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> <properties description="Percentage configuration progress" label="" unit="%" standardUnit="" displayUnit="" format="" maxValue="100" minValue="0" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> </attributes> <attributes name="configurationDelayExpected" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="1000" maxX="" maxY="" allocReadMember="true" isDynamic="false"> <dataType xsi:type="pogoDsl:UShortType"/> - <changeEvent fire="false" libCheckCriteria="false"/> - <archiveEvent fire="false" libCheckCriteria="false"/> <dataReadyEvent fire="false" libCheckCriteria="true"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> <properties description="Configuration delay expected in seconds" label="" unit="seconds" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> </attributes> <attributes name="buildState" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="60000" maxX="" maxY="" allocReadMember="true"> <dataType xsi:type="pogoDsl:StringType"/> - <changeEvent fire="false" libCheckCriteria="false"/> - <archiveEvent fire="false" libCheckCriteria="false"/> <status abstract="false" inherited="true" concrete="true" concreteHere="false"/> <properties description="Build state of this device" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> </attributes> <attributes name="versionId" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="60000" maxX="" maxY="" allocReadMember="true"> <dataType xsi:type="pogoDsl:StringType"/> - <changeEvent fire="false" libCheckCriteria="false"/> - <archiveEvent fire="false" libCheckCriteria="false"/> <status abstract="false" inherited="true" concrete="true" concreteHere="false"/> <properties description="Build state of this device" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> </attributes> <attributes name="centralLoggingLevel" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="1000" maxX="" maxY="" allocReadMember="true"> <dataType xsi:type="pogoDsl:UShortType"/> - <changeEvent fire="false" libCheckCriteria="false"/> - <archiveEvent fire="false" libCheckCriteria="false"/> <status abstract="false" inherited="true" concrete="true" concreteHere="false"/> <properties description="Current logging level to Central logging target for this device - 
initialises to CentralLoggingLevelDefault on startup" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> </attributes> <attributes name="elementLoggingLevel" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="1000" maxX="" maxY="" allocReadMember="true"> <dataType xsi:type="pogoDsl:UShortType"/> - <changeEvent fire="false" libCheckCriteria="false"/> - <archiveEvent fire="false" libCheckCriteria="false"/> <status abstract="false" inherited="true" concrete="true" concreteHere="false"/> <properties description="Current logging level to Element logging target for this device - 
initialises to ElementLoggingLevelDefault on startup" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> </attributes> <attributes name="storageLoggingLevel" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="1000" maxX="" maxY="" memorized="true" allocReadMember="true"> <dataType xsi:type="pogoDsl:UShortType"/> - <changeEvent fire="false" libCheckCriteria="false"/> - <archiveEvent fire="false" libCheckCriteria="false"/> <status abstract="false" inherited="true" concrete="true" concreteHere="false"/> <properties description="Current logging level to Syslog for this device - 
initialises from StorageLoggingLevelDefault on first execution of device.
Needs to be READ_WRITE To make it memorized - but writing this attribute should 
do the same as command SetStorageLoggingLevel to ensure the targets and adjustments
are made correctly" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> </attributes> <attributes name="healthState" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="1000" maxX="" maxY="" allocReadMember="true"> <dataType xsi:type="pogoDsl:EnumType"/> - <changeEvent fire="false" libCheckCriteria="false"/> - <archiveEvent fire="false" libCheckCriteria="false"/> <status abstract="false" inherited="true" concrete="true" concreteHere="false"/> <properties description="The health state reported for this device. It interprets the current device condition 
and condition of all managed devices to set this. Most possibly an aggregate attribute." label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> </attributes> <attributes name="adminMode" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="1000" maxX="" maxY="" memorized="true" allocReadMember="true"> <dataType xsi:type="pogoDsl:EnumType"/> - <changeEvent fire="false" libCheckCriteria="false"/> - <archiveEvent fire="false" libCheckCriteria="false"/> <status abstract="false" inherited="true" concrete="true" concreteHere="false"/> <properties description="The admin mode reported for this device. It may interpret the current device condition 
and condition of all managed devices to set this. Most possibly an aggregate attribute." label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> </attributes> <attributes name="controlMode" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="1000" maxX="" maxY="" memorized="true" allocReadMember="true"> <dataType xsi:type="pogoDsl:EnumType"/> - <changeEvent fire="false" libCheckCriteria="false"/> - <archiveEvent fire="false" libCheckCriteria="false"/> <status abstract="false" inherited="true" concrete="true" concreteHere="false"/> <properties description="The control mode of the device. REMOTE, LOCAL
TANGO Device accepts only from a ‘local’ client and ignores commands and queries received from TM
or any other ‘remote’ clients. The Local clients has to release LOCAL control before REMOTE clients
can take control again." label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> </attributes> <attributes name="simulationMode" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="1000" maxX="" maxY="" memorized="true" allocReadMember="true"> <dataType xsi:type="pogoDsl:BooleanType"/> - <changeEvent fire="false" libCheckCriteria="false"/> - <archiveEvent fire="false" libCheckCriteria="false"/> <status abstract="false" inherited="true" concrete="true" concreteHere="false"/> <properties description="Reports the simulation mode of the device. Some devices may implement both modes,
while others will have simulators that set simulationMode to True while the real
devices always set simulationMode to False." label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> </attributes> <attributes name="testMode" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="1000" maxX="" maxY="" memorized="true" allocReadMember="true"> <dataType xsi:type="pogoDsl:StringType"/> - <changeEvent fire="false" libCheckCriteria="false"/> - <archiveEvent fire="false" libCheckCriteria="false"/> <status abstract="false" inherited="true" concrete="true" concreteHere="false"/> <properties description="The test mode of the device. 
Either no test mode (empty string) or an indication of the test mode." label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> </attributes> @@ -240,6 +212,6 @@ <states name="DISABLE" description="The device cannot be switched ON for an external reason. E.g. the power supply has its door open, the safety conditions are not satisfactory to allow the device to operate."> <status abstract="false" inherited="true" concrete="true"/> </states> - <preferences docHome="./doc_html" makefileHome="/usr/share/pogo/preferences"/> + <preferences docHome="./doc_html" makefileHome="$(TANGO_HOME)"/> </classes> </pogoDsl:PogoSystem> diff --git a/skabase/SKAObsDevice/SKAObsDevice/SKAObsDevice.py b/skabase/SKAObsDevice/SKAObsDevice/SKAObsDevice.py index 935f645076852302d61ca220cd8f21c02e9d7bcb..4bd03aa1c8a57453524bd2a9a22067bbf8825e40 100644 --- a/skabase/SKAObsDevice/SKAObsDevice/SKAObsDevice.py +++ b/skabase/SKAObsDevice/SKAObsDevice/SKAObsDevice.py @@ -144,14 +144,6 @@ class SKAObsDevice(SKABaseDevice): # Commands # -------- - @command( - ) - @DebugIt() - def Reset(self): - # PROTECTED REGION ID(SKAObsDevice.Reset) ENABLED START # - pass - # PROTECTED REGION END # // SKAObsDevice.Reset - # ---------- # Run server # ---------- diff --git a/skabase/SKAObsDevice/test/SKAObsDevice_test.py b/skabase/SKAObsDevice/test/SKAObsDevice_test.py index 4e4c4a445cff12d943c75df29dd2596650a91bbd..b231c4e711b8e6bd503ceb00ab8198e5e6180d75 100644 --- a/skabase/SKAObsDevice/test/SKAObsDevice_test.py +++ b/skabase/SKAObsDevice/test/SKAObsDevice_test.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +######################################################################################### # -*- coding: utf-8 -*- # # This file is part of the SKAObsDevice project @@ -7,6 +7,7 @@ # # Distributed under the terms of the GPL license. # See LICENSE.txt for more info. +######################################################################################### """Contain the tests for the SKAObsDevice.""" # Path @@ -16,32 +17,30 @@ path = os.path.join(os.path.dirname(__file__), os.pardir) sys.path.insert(0, os.path.abspath(path)) # Imports -from time import sleep +import pytest from mock import MagicMock -from PyTango import DevFailed, DevState -from devicetest import DeviceTestCase, main -from SKAObsDevice import SKAObsDevice -# Note: -# -# Since the device uses an inner thread, it is necessary to -# wait during the tests in order the let the device update itself. -# Hence, the sleep calls have to be secured enough not to produce -# any inconsistent behavior. However, the unittests need to run fast. -# Here, we use a factor 3 between the read period and the sleep calls. -# -# Look at devicetest examples for more advanced testing +from PyTango import DevState + +# PROTECTED REGION ID(SKAObsDevice.test_additional_imports) ENABLED START # +# PROTECTED REGION END # // SKAObsDevice.test_additional_imports # Device test case -class SKAObsDeviceDeviceTestCase(DeviceTestCase): +@pytest.mark.usefixtures("tango_context", "initialize_device") +# PROTECTED REGION ID(SKAObsDevice.test_SKAObsDevice_decorators) ENABLED START # +# PROTECTED REGION END # // SKAObsDevice.test_SKAObsDevice_decorators +class TestSKAObsDevice(object): """Test case for packet generation.""" - # PROTECTED REGION ID(SKAObsDevice.test_additionnal_import) ENABLED START # - # PROTECTED REGION END # // SKAObsDevice.test_additionnal_import - device = SKAObsDevice - properties = {'SkaLevel': '4', 'CentralLoggingTarget': '', 'ElementLoggingTarget': '', 'StorageLoggingTarget': 'localhost', 'MetricList': 'healthState', 'GroupDefinitions': '', - } - empty = None # Should be [] + + properties = { + 'SkaLevel': '4', + 'CentralLoggingTarget': '', + 'ElementLoggingTarget': '', + 'StorageLoggingTarget': 'localhost', + 'MetricList': 'healthState', + 'GroupDefinitions': '', + } @classmethod def mocking(cls): @@ -51,139 +50,179 @@ class SKAObsDeviceDeviceTestCase(DeviceTestCase): # PROTECTED REGION ID(SKAObsDevice.test_mocking) ENABLED START # # PROTECTED REGION END # // SKAObsDevice.test_mocking - def test_properties(self): - # test the properties + def test_properties(self, tango_context): + # Test the properties # PROTECTED REGION ID(SKAObsDevice.test_properties) ENABLED START # # PROTECTED REGION END # // SKAObsDevice.test_properties pass - def test_ObsState(self): + # PROTECTED REGION ID(SKAObsDevice.test_ObsState_decorators) ENABLED START # + # PROTECTED REGION END # // SKAObsDevice.test_ObsState_decorators + def test_ObsState(self, tango_context): """Test for ObsState""" # PROTECTED REGION ID(SKAObsDevice.test_ObsState) ENABLED START # - self.device.ObsState() + assert tango_context.device.ObsState() == "" # PROTECTED REGION END # // SKAObsDevice.test_ObsState - def test_Reset(self): - """Test for Reset""" - # PROTECTED REGION ID(SKAObsDevice.test_Reset) ENABLED START # - self.device.Reset() - # PROTECTED REGION END # // SKAObsDevice.test_Reset - - def test_State(self): + # PROTECTED REGION ID(SKAObsDevice.test_State_decorators) ENABLED START # + # PROTECTED REGION END # // SKAObsDevice.test_State_decorators + def test_State(self, tango_context): """Test for State""" # PROTECTED REGION ID(SKAObsDevice.test_State) ENABLED START # - self.device.State() + assert tango_context.device.State() == DevState.UNKNOWN # PROTECTED REGION END # // SKAObsDevice.test_State - def test_Status(self): + # PROTECTED REGION ID(SKAObsDevice.test_Status_decorators) ENABLED START # + # PROTECTED REGION END # // SKAObsDevice.test_Status_decorators + def test_Status(self, tango_context): """Test for Status""" # PROTECTED REGION ID(SKAObsDevice.test_Status) ENABLED START # - self.device.Status() + assert tango_context.device.Status() == "The device is in UNKNOWN state." # PROTECTED REGION END # // SKAObsDevice.test_Status - def test_GetMetrics(self): + # PROTECTED REGION ID(SKAObsDevice.test_GetMetrics_decorators) ENABLED START # + # PROTECTED REGION END # // SKAObsDevice.test_GetMetrics_decorators + def test_GetMetrics(self, tango_context): """Test for GetMetrics""" # PROTECTED REGION ID(SKAObsDevice.test_GetMetrics) ENABLED START # - self.device.GetMetrics() + assert tango_context.device.GetMetrics() == "" # PROTECTED REGION END # // SKAObsDevice.test_GetMetrics - def test_ToJson(self): + # PROTECTED REGION ID(SKAObsDevice.test_ToJson_decorators) ENABLED START # + # PROTECTED REGION END # // SKAObsDevice.test_ToJson_decorators + def test_ToJson(self, tango_context): """Test for ToJson""" # PROTECTED REGION ID(SKAObsDevice.test_ToJson) ENABLED START # - self.device.ToJson("") + assert tango_context.device.ToJson("") == "" # PROTECTED REGION END # // SKAObsDevice.test_ToJson - def test_GetVersionInfo(self): + # PROTECTED REGION ID(SKAObsDevice.test_GetVersionInfo_decorators) ENABLED START # + # PROTECTED REGION END # // SKAObsDevice.test_GetVersionInfo_decorators + def test_GetVersionInfo(self, tango_context): """Test for GetVersionInfo""" # PROTECTED REGION ID(SKAObsDevice.test_GetVersionInfo) ENABLED START # - self.device.GetVersionInfo() + assert tango_context.device.GetVersionInfo() == [""] # PROTECTED REGION END # // SKAObsDevice.test_GetVersionInfo - def test_obsState(self): + # PROTECTED REGION ID(SKAObsDevice.test_Reset_decorators) ENABLED START # + # PROTECTED REGION END # // SKAObsDevice.test_Reset_decorators + def test_Reset(self, tango_context): + """Test for Reset""" + # PROTECTED REGION ID(SKAObsDevice.test_Reset) ENABLED START # + assert tango_context.device.Reset() == None + # PROTECTED REGION END # // SKAObsDevice.test_Reset + + + # PROTECTED REGION ID(SKAObsDevice.test_obsState_decorators) ENABLED START # + # PROTECTED REGION END # // SKAObsDevice.test_obsState_decorators + def test_obsState(self, tango_context): """Test for obsState""" # PROTECTED REGION ID(SKAObsDevice.test_obsState) ENABLED START # - self.device.obsState + assert tango_context.device.obsState == 0 # PROTECTED REGION END # // SKAObsDevice.test_obsState - def test_obsMode(self): + # PROTECTED REGION ID(SKAObsDevice.test_obsMode_decorators) ENABLED START # + # PROTECTED REGION END # // SKAObsDevice.test_obsMode_decorators + def test_obsMode(self, tango_context): """Test for obsMode""" # PROTECTED REGION ID(SKAObsDevice.test_obsMode) ENABLED START # - self.device.obsMode + assert tango_context.device.obsMode == 0 # PROTECTED REGION END # // SKAObsDevice.test_obsMode - def test_configurationProgress(self): + # PROTECTED REGION ID(SKAObsDevice.test_configurationProgress_decorators) ENABLED START # + # PROTECTED REGION END # // SKAObsDevice.test_configurationProgress_decorators + def test_configurationProgress(self, tango_context): """Test for configurationProgress""" # PROTECTED REGION ID(SKAObsDevice.test_configurationProgress) ENABLED START # - self.device.configurationProgress + assert tango_context.device.configurationProgress == 0 # PROTECTED REGION END # // SKAObsDevice.test_configurationProgress - def test_configurationDelayExpected(self): + # PROTECTED REGION ID(SKAObsDevice.test_configurationDelayExpected_decorators) ENABLED START # + # PROTECTED REGION END # // SKAObsDevice.test_configurationDelayExpected_decorators + def test_configurationDelayExpected(self, tango_context): """Test for configurationDelayExpected""" # PROTECTED REGION ID(SKAObsDevice.test_configurationDelayExpected) ENABLED START # - self.device.configurationDelayExpected + assert tango_context.device.configurationDelayExpected == 0 # PROTECTED REGION END # // SKAObsDevice.test_configurationDelayExpected - def test_buildState(self): + # PROTECTED REGION ID(SKAObsDevice.test_buildState_decorators) ENABLED START # + # PROTECTED REGION END # // SKAObsDevice.test_buildState_decorators + def test_buildState(self, tango_context): """Test for buildState""" # PROTECTED REGION ID(SKAObsDevice.test_buildState) ENABLED START # - self.device.buildState + assert tango_context.device.buildState == '' # PROTECTED REGION END # // SKAObsDevice.test_buildState - def test_versionId(self): + # PROTECTED REGION ID(SKAObsDevice.test_versionId_decorators) ENABLED START # + # PROTECTED REGION END # // SKAObsDevice.test_versionId_decorators + def test_versionId(self, tango_context): """Test for versionId""" # PROTECTED REGION ID(SKAObsDevice.test_versionId) ENABLED START # - self.device.versionId + assert tango_context.device.versionId == '' # PROTECTED REGION END # // SKAObsDevice.test_versionId - def test_centralLoggingLevel(self): + # PROTECTED REGION ID(SKAObsDevice.test_centralLoggingLevel_decorators) ENABLED START # + # PROTECTED REGION END # // SKAObsDevice.test_centralLoggingLevel_decorators + def test_centralLoggingLevel(self, tango_context): """Test for centralLoggingLevel""" # PROTECTED REGION ID(SKAObsDevice.test_centralLoggingLevel) ENABLED START # - self.device.centralLoggingLevel + assert tango_context.device.centralLoggingLevel == 0 # PROTECTED REGION END # // SKAObsDevice.test_centralLoggingLevel - def test_elementLoggingLevel(self): + # PROTECTED REGION ID(SKAObsDevice.test_elementLoggingLevel_decorators) ENABLED START # + # PROTECTED REGION END # // SKAObsDevice.test_elementLoggingLevel_decorators + def test_elementLoggingLevel(self, tango_context): """Test for elementLoggingLevel""" # PROTECTED REGION ID(SKAObsDevice.test_elementLoggingLevel) ENABLED START # - self.device.elementLoggingLevel + assert tango_context.device.elementLoggingLevel == 0 # PROTECTED REGION END # // SKAObsDevice.test_elementLoggingLevel - def test_storageLoggingLevel(self): + # PROTECTED REGION ID(SKAObsDevice.test_storageLoggingLevel_decorators) ENABLED START # + # PROTECTED REGION END # // SKAObsDevice.test_storageLoggingLevel_decorators + def test_storageLoggingLevel(self, tango_context): """Test for storageLoggingLevel""" # PROTECTED REGION ID(SKAObsDevice.test_storageLoggingLevel) ENABLED START # - self.device.storageLoggingLevel + assert tango_context.device.storageLoggingLevel == 0 # PROTECTED REGION END # // SKAObsDevice.test_storageLoggingLevel - def test_healthState(self): + # PROTECTED REGION ID(SKAObsDevice.test_healthState_decorators) ENABLED START # + # PROTECTED REGION END # // SKAObsDevice.test_healthState_decorators + def test_healthState(self, tango_context): """Test for healthState""" # PROTECTED REGION ID(SKAObsDevice.test_healthState) ENABLED START # - self.device.healthState + assert tango_context.device.healthState == 0 # PROTECTED REGION END # // SKAObsDevice.test_healthState - def test_adminMode(self): + # PROTECTED REGION ID(SKAObsDevice.test_adminMode_decorators) ENABLED START # + # PROTECTED REGION END # // SKAObsDevice.test_adminMode_decorators + def test_adminMode(self, tango_context): """Test for adminMode""" # PROTECTED REGION ID(SKAObsDevice.test_adminMode) ENABLED START # - self.device.adminMode + assert tango_context.device.adminMode == 0 # PROTECTED REGION END # // SKAObsDevice.test_adminMode - def test_controlMode(self): + # PROTECTED REGION ID(SKAObsDevice.test_controlMode_decorators) ENABLED START # + # PROTECTED REGION END # // SKAObsDevice.test_controlMode_decorators + def test_controlMode(self, tango_context): """Test for controlMode""" # PROTECTED REGION ID(SKAObsDevice.test_controlMode) ENABLED START # - self.device.controlMode + assert tango_context.device.controlMode == 0 # PROTECTED REGION END # // SKAObsDevice.test_controlMode - def test_simulationMode(self): + # PROTECTED REGION ID(SKAObsDevice.test_simulationMode_decorators) ENABLED START # + # PROTECTED REGION END # // SKAObsDevice.test_simulationMode_decorators + def test_simulationMode(self, tango_context): """Test for simulationMode""" # PROTECTED REGION ID(SKAObsDevice.test_simulationMode) ENABLED START # - self.device.simulationMode + assert tango_context.device.simulationMode == False # PROTECTED REGION END # // SKAObsDevice.test_simulationMode - def test_testMode(self): + # PROTECTED REGION ID(SKAObsDevice.test_testMode_decorators) ENABLED START # + # PROTECTED REGION END # // SKAObsDevice.test_testMode_decorators + def test_testMode(self, tango_context): """Test for testMode""" # PROTECTED REGION ID(SKAObsDevice.test_testMode) ENABLED START # - self.device.testMode + assert tango_context.device.testMode == '' # PROTECTED REGION END # // SKAObsDevice.test_testMode -# Main execution -if __name__ == "__main__": - main() diff --git a/skabase/SKASubarray/SKASubarray.xmi b/skabase/SKASubarray/SKASubarray.xmi index 3db859db55bc6a3a9a73a172577bd36420a9a533..e14ede2055a8b7b7de2d586c26519b1b4e8cba7a 100644 --- a/skabase/SKASubarray/SKASubarray.xmi +++ b/skabase/SKASubarray/SKASubarray.xmi @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="ASCII"?> <pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl"> <classes name="SKASubarray" pogoRevision="9.6"> - <description description="SubArray handling device" title="SKASubarray" sourcePath="/home/kat/src/levpro/skabase/SKASubarray" language="PythonHL" filestogenerate="XMI file,Code files, Python Package, Protected Regions" license="GPL" copyright="" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> + <description description="SubArray handling device" title="SKASubarray" sourcePath="/home/pogo/src/levpro/skabase/SKASubarray" language="PythonHL" filestogenerate="XMI file,Code files,Python Package,Protected Regions" license="GPL" copyright="" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> <inheritances classname="Device_Impl" sourcePath=""/> <inheritances classname="SKAObsDevice" sourcePath="../SKAObsDevice"/> <identification contact="at ska.ac.za - cam" author="cam" emailDomain="ska.ac.za" classFamily="SkaBase" siteSpecific="" platform="All Platforms" bus="Not Applicable" manufacturer="none" reference=""/> @@ -18,14 +18,16 @@ <type xsi:type="pogoDsl:StringType"/> <status abstract="false" inherited="true" concrete="true"/> </deviceProperties> - <deviceProperties name="GroupDefinitions" description="List of grouped devices managed by a master. Each string in the array is a JSON 
document defining the ``groupname``, ``devices`` and ``groups`` in the group.
A proxy client will be opened for each of the managed devices.
A group will be instantiated for the managed devices per group.
Each entry in the array contains a JSON defining the group, like:
[ {``groupname``: ``group1``, 
 ``devices``: ``csv list of devices in group1``},
 {``groupname``: ``group2``, # a group with devices and a subgroup
 ``devices``: ``csv list of devices in group2``,
 ``groups`` : ``csv list of sub groups``},
 {``groupname``: ``group3``, 
 ``devices`` : ``csv list of devices in group3``}},
 {``groupname``: ``group4``, # a group with only subgroups
 ``groups`` : ``csv list of sub groups``}}]

e.g. for a hierarchy of racks, servers and switches
[{ ``groupname``: ``servers``, 
 ``devices``: ``elt/server/1,elt/server/2,elt/server/3,elt/server/4``},
 {``groupname``: ``switches``, 
 ``devices``: ``elt/switch/A,elt/switch/B``},
 {``groupname``: ``pdus``, 
 ``devices``: ``elt/pdu/rackA,elt/pdu/rackB``},
 {``groupname``:``rackA``, 
 ``devices``: ``elt/server/1,elt/server/2,elt/switch/A,elt/pdu/rackA``},
 {``groupname``:``rackB``,
 ``devices``: ``elt/server/3,elt/server/4,elt/switch/B,elt/pdu/rackB``},
 {``groupname``:``racks``,
 ``groups``: ``rackA,rackB``}]"> + <deviceProperties name="GroupDefinitions" description="Each string in the list is a JSON serialised dict defining the ``group_name``,
``devices`` and ``subgroups`` in the group. A TANGO Group object is created
for each item in the list, according to the hierarchy defined. This provides
easy access to the managed devices in bulk, or individually.

The general format of the list is as follows, with optional ``devices`` and
``subgroups`` keys:
 [ {``group_name``: ``<name>``,
 ``devices``: [``<dev name>``, ...]},
 {``group_name``: ``<name>``,
 ``devices``: [``<dev name>``, ``<dev name>``, ...],
 ``subgroups`` : [{<nested group>},
 {<nested group>}, ...]},
 ...
 ]

For example, a hierarchy of racks, servers and switches:
 [ {``group_name``: ``servers``,
 ``devices``: [``elt/server/1``, ``elt/server/2``,
 ``elt/server/3``, ``elt/server/4``]},
 {``group_name``: ``switches``,
 ``devices``: [``elt/switch/A``, ``elt/switch/B``]},
 {``group_name``: ``pdus``,
 ``devices``: [``elt/pdu/rackA``, ``elt/pdu/rackB``]},
 {``group_name``: ``racks``,
 ``subgroups``: [
 {``group_name``: ``rackA``,
 ``devices``: [``elt/server/1``, ``elt/server/2``,
 ``elt/switch/A``, ``elt/pdu/rackA``]},
 {``group_name``: ``rackB``,
 ``devices``: [``elt/server/3``, ``elt/server/4``,
 ``elt/switch/B``, ``elt/pdu/rackB``],
 ``subgroups``: []}
 ]} ]"> <type xsi:type="pogoDsl:StringVectorType"/> <status abstract="false" inherited="true" concrete="true"/> </deviceProperties> <deviceProperties name="MetricList" description="A subset of attributes we want to expose as metrics for this device."> - <type xsi:type="pogoDsl:StringType"/> + <type xsi:type="pogoDsl:StringVectorType"/> <status abstract="false" inherited="true" concrete="true"/> - <DefaultPropValue>healthState,adminMode,controlMode</DefaultPropValue> + <DefaultPropValue>healthState</DefaultPropValue> + <DefaultPropValue>adminMode</DefaultPropValue> + <DefaultPropValue>controlMode</DefaultPropValue> </deviceProperties> <deviceProperties name="SkaLevel" description="Indication of importance of the device in the SKA hierarchy 
to support drill-down navigation: 1..6, with 1 highest.
Default is 4, making provision for 
EltMaster, EltAlarms, EltTelState = 1
SubEltMaster = 2
Subarray, Capability = 2/3
Others = 4 (or 5 or 6)"> <type xsi:type="pogoDsl:ShortType"/> @@ -183,7 +185,7 @@ <argout description=""> <type xsi:type="pogoDsl:VoidType"/> </argout> - <status abstract="true" inherited="true" concrete="true" concreteHere="false"/> + <status abstract="false" inherited="true" concrete="true" concreteHere="false"/> </commands> <commands name="Resume" description="Resume scan." execMethod="resume" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> <argin description=""> @@ -230,7 +232,7 @@ <status abstract="false" inherited="true" concrete="true"/> <properties description="Build state of this device" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> </attributes> - <attributes name="centralLoggingLevel" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true"> + <attributes name="centralLoggingLevel" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true"> <dataType xsi:type="pogoDsl:UShortType"/> <status abstract="false" inherited="true" concrete="true"/> <properties description="Current logging level to Central logging target for this device - 
initialises to CentralLoggingLevelDefault on startup" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> @@ -250,7 +252,7 @@ <status abstract="false" inherited="true" concrete="true"/> <properties description="The control mode of the device. REMOTE, LOCAL
TANGO Device accepts only from a ‘local’ client and ignores commands and queries received from TM
or any other ‘remote’ clients. The Local clients has to release LOCAL control before REMOTE clients
can take control again." label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> </attributes> - <attributes name="elementLoggingLevel" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true"> + <attributes name="elementLoggingLevel" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true"> <dataType xsi:type="pogoDsl:UShortType"/> <status abstract="false" inherited="true" concrete="true"/> <properties description="Current logging level to Element logging target for this device - 
initialises to ElementLoggingLevelDefault on startup" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> @@ -330,7 +332,7 @@ <states name="DISABLE" description="The device cannot be switched ON for an external reason. E.g. the power supply has its door open, the safety conditions are not satisfactory to allow the device to operate."> <status abstract="false" inherited="true" concrete="true"/> </states> - <preferences docHome="./doc_html" makefileHome="/usr/share/pogo/preferences"/> + <preferences docHome="./doc_html" makefileHome="$(TANGO_HOME)"/> <overlodedPollPeriodObject name="adminMode" type="attribute" pollPeriod="0"/> <overlodedPollPeriodObject name="centralLoggingLevel" type="attribute" pollPeriod="0"/> <overlodedPollPeriodObject name="configurationDelayExpected" type="attribute" pollPeriod="0"/> diff --git a/skabase/SKASubarray/test/SKASubarray_test.py b/skabase/SKASubarray/test/SKASubarray_test.py index 0976bec7b14e52fca7336f322773d37dc2958291..defe63416e01805a92cd7d76d1d770fdc0c528c0 100644 --- a/skabase/SKASubarray/test/SKASubarray_test.py +++ b/skabase/SKASubarray/test/SKASubarray_test.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +######################################################################################### # -*- coding: utf-8 -*- # # This file is part of the SKASubarray project @@ -7,6 +7,7 @@ # # Distributed under the terms of the GPL license. # See LICENSE.txt for more info. +######################################################################################### """Contain the tests for the SKASubarray.""" # Path @@ -16,32 +17,32 @@ path = os.path.join(os.path.dirname(__file__), os.pardir) sys.path.insert(0, os.path.abspath(path)) # Imports -from time import sleep +import pytest from mock import MagicMock -from PyTango import DevFailed, DevState -from devicetest import DeviceTestCase, main -from SKASubarray import SKASubarray -# Note: -# -# Since the device uses an inner thread, it is necessary to -# wait during the tests in order the let the device update itself. -# Hence, the sleep calls have to be secured enough not to produce -# any inconsistent behavior. However, the unittests need to run fast. -# Here, we use a factor 3 between the read period and the sleep calls. -# -# Look at devicetest examples for more advanced testing +from PyTango import DevState + +# PROTECTED REGION ID(SKASubarray.test_additional_imports) ENABLED START # +# PROTECTED REGION END # // SKASubarray.test_additional_imports # Device test case -class SKASubarrayDeviceTestCase(DeviceTestCase): +@pytest.mark.usefixtures("tango_context", "initialize_device") +# PROTECTED REGION ID(SKASubarray.test_SKASubarray_decorators) ENABLED START # +# PROTECTED REGION END # // SKASubarray.test_SKASubarray_decorators +class TestSKASubarray(object): """Test case for packet generation.""" - # PROTECTED REGION ID(SKASubarray.test_additionnal_import) ENABLED START # - # PROTECTED REGION END # // SKASubarray.test_additionnal_import - device = SKASubarray - properties = {'CapabilityTypes': '', 'CentralLoggingTarget': '', 'ElementLoggingTarget': '', 'GroupDefinitions': '', 'MetricList': 'healthState,adminMode,controlMode', 'SkaLevel': '4', 'StorageLoggingTarget': 'localhost', 'SubID': '', - } - empty = None # Should be [] + + properties = { + 'CapabilityTypes': '', + 'CentralLoggingTarget': '', + 'ElementLoggingTarget': '', + 'GroupDefinitions': '', + 'MetricList': 'healthState', + 'SkaLevel': '4', + 'StorageLoggingTarget': 'localhost', + 'SubID': '', + } @classmethod def mocking(cls): @@ -51,229 +52,299 @@ class SKASubarrayDeviceTestCase(DeviceTestCase): # PROTECTED REGION ID(SKASubarray.test_mocking) ENABLED START # # PROTECTED REGION END # // SKASubarray.test_mocking - def test_properties(self): - # test the properties + def test_properties(self, tango_context): + # Test the properties # PROTECTED REGION ID(SKASubarray.test_properties) ENABLED START # # PROTECTED REGION END # // SKASubarray.test_properties pass - def test_Abort(self): + # PROTECTED REGION ID(SKASubarray.test_Abort_decorators) ENABLED START # + # PROTECTED REGION END # // SKASubarray.test_Abort_decorators + def test_Abort(self, tango_context): """Test for Abort""" # PROTECTED REGION ID(SKASubarray.test_Abort) ENABLED START # - self.device.Abort() + assert tango_context.device.Abort() == None # PROTECTED REGION END # // SKASubarray.test_Abort - def test_ConfigureCapability(self): + # PROTECTED REGION ID(SKASubarray.test_ConfigureCapability_decorators) ENABLED START # + # PROTECTED REGION END # // SKASubarray.test_ConfigureCapability_decorators + def test_ConfigureCapability(self, tango_context): """Test for ConfigureCapability""" # PROTECTED REGION ID(SKASubarray.test_ConfigureCapability) ENABLED START # - self.device.ConfigureCapability([""]) + assert tango_context.device.ConfigureCapability([[0], [""]]) == None # PROTECTED REGION END # // SKASubarray.test_ConfigureCapability - def test_DeconfigureAllCapabilities(self): + # PROTECTED REGION ID(SKASubarray.test_DeconfigureAllCapabilities_decorators) ENABLED START # + # PROTECTED REGION END # // SKASubarray.test_DeconfigureAllCapabilities_decorators + def test_DeconfigureAllCapabilities(self, tango_context): """Test for DeconfigureAllCapabilities""" # PROTECTED REGION ID(SKASubarray.test_DeconfigureAllCapabilities) ENABLED START # - self.device.DeconfigureAllCapabilities("") + assert tango_context.device.DeconfigureAllCapabilities("") == None # PROTECTED REGION END # // SKASubarray.test_DeconfigureAllCapabilities - def test_DeconfigureCapability(self): + # PROTECTED REGION ID(SKASubarray.test_DeconfigureCapability_decorators) ENABLED START # + # PROTECTED REGION END # // SKASubarray.test_DeconfigureCapability_decorators + def test_DeconfigureCapability(self, tango_context): """Test for DeconfigureCapability""" # PROTECTED REGION ID(SKASubarray.test_DeconfigureCapability) ENABLED START # - self.device.DeconfigureCapability([""]) + assert tango_context.device.DeconfigureCapability([[0], [""]]) == None # PROTECTED REGION END # // SKASubarray.test_DeconfigureCapability - def test_GetMetrics(self): + # PROTECTED REGION ID(SKASubarray.test_GetMetrics_decorators) ENABLED START # + # PROTECTED REGION END # // SKASubarray.test_GetMetrics_decorators + def test_GetMetrics(self, tango_context): """Test for GetMetrics""" # PROTECTED REGION ID(SKASubarray.test_GetMetrics) ENABLED START # - self.device.GetMetrics() + assert tango_context.device.GetMetrics() == "" # PROTECTED REGION END # // SKASubarray.test_GetMetrics - def test_GetVersionInfo(self): + # PROTECTED REGION ID(SKASubarray.test_GetVersionInfo_decorators) ENABLED START # + # PROTECTED REGION END # // SKASubarray.test_GetVersionInfo_decorators + def test_GetVersionInfo(self, tango_context): """Test for GetVersionInfo""" # PROTECTED REGION ID(SKASubarray.test_GetVersionInfo) ENABLED START # - self.device.GetVersionInfo() + assert tango_context.device.GetVersionInfo() == [""] # PROTECTED REGION END # // SKASubarray.test_GetVersionInfo - def test_Status(self): + # PROTECTED REGION ID(SKASubarray.test_Status_decorators) ENABLED START # + # PROTECTED REGION END # // SKASubarray.test_Status_decorators + def test_Status(self, tango_context): """Test for Status""" # PROTECTED REGION ID(SKASubarray.test_Status) ENABLED START # - self.device.Status() + assert tango_context.device.Status() == "The device is in DISABLE state." # PROTECTED REGION END # // SKASubarray.test_Status - def test_State(self): + # PROTECTED REGION ID(SKASubarray.test_State_decorators) ENABLED START # + # PROTECTED REGION END # // SKASubarray.test_State_decorators + def test_State(self, tango_context): """Test for State""" # PROTECTED REGION ID(SKASubarray.test_State) ENABLED START # - self.device.State() + assert tango_context.device.State() == DevState.DISABLE # PROTECTED REGION END # // SKASubarray.test_State - def test_AssignResources(self): + # PROTECTED REGION ID(SKASubarray.test_AssignResources_decorators) ENABLED START # + # PROTECTED REGION END # // SKASubarray.test_AssignResources_decorators + def test_AssignResources(self, tango_context): """Test for AssignResources""" # PROTECTED REGION ID(SKASubarray.test_AssignResources) ENABLED START # - self.device.AssignResources([""]) + assert tango_context.device.AssignResources([""]) == [""] # PROTECTED REGION END # // SKASubarray.test_AssignResources - def test_EndSB(self): + # PROTECTED REGION ID(SKASubarray.test_EndSB_decorators) ENABLED START # + # PROTECTED REGION END # // SKASubarray.test_EndSB_decorators + def test_EndSB(self, tango_context): """Test for EndSB""" # PROTECTED REGION ID(SKASubarray.test_EndSB) ENABLED START # - self.device.EndSB() + assert tango_context.device.EndSB() == None # PROTECTED REGION END # // SKASubarray.test_EndSB - def test_EndScan(self): + # PROTECTED REGION ID(SKASubarray.test_EndScan_decorators) ENABLED START # + # PROTECTED REGION END # // SKASubarray.test_EndScan_decorators + def test_EndScan(self, tango_context): """Test for EndScan""" # PROTECTED REGION ID(SKASubarray.test_EndScan) ENABLED START # - self.device.EndScan() + assert tango_context.device.EndScan() == None # PROTECTED REGION END # // SKASubarray.test_EndScan - def test_ObsState(self): + # PROTECTED REGION ID(SKASubarray.test_ObsState_decorators) ENABLED START # + # PROTECTED REGION END # // SKASubarray.test_ObsState_decorators + def test_ObsState(self, tango_context): """Test for ObsState""" # PROTECTED REGION ID(SKASubarray.test_ObsState) ENABLED START # - self.device.ObsState() + assert tango_context.device.ObsState() == "" # PROTECTED REGION END # // SKASubarray.test_ObsState - def test_Pause(self): + # PROTECTED REGION ID(SKASubarray.test_Pause_decorators) ENABLED START # + # PROTECTED REGION END # // SKASubarray.test_Pause_decorators + def test_Pause(self, tango_context): """Test for Pause""" # PROTECTED REGION ID(SKASubarray.test_Pause) ENABLED START # - self.device.Pause() + assert tango_context.device.Pause() == None # PROTECTED REGION END # // SKASubarray.test_Pause - def test_ReleaseAllResources(self): + # PROTECTED REGION ID(SKASubarray.test_ReleaseAllResources_decorators) ENABLED START # + # PROTECTED REGION END # // SKASubarray.test_ReleaseAllResources_decorators + def test_ReleaseAllResources(self, tango_context): """Test for ReleaseAllResources""" # PROTECTED REGION ID(SKASubarray.test_ReleaseAllResources) ENABLED START # - self.device.ReleaseAllResources() + assert tango_context.device.ReleaseAllResources() == [""] # PROTECTED REGION END # // SKASubarray.test_ReleaseAllResources - def test_ReleaseResources(self): + # PROTECTED REGION ID(SKASubarray.test_ReleaseResources_decorators) ENABLED START # + # PROTECTED REGION END # // SKASubarray.test_ReleaseResources_decorators + def test_ReleaseResources(self, tango_context): """Test for ReleaseResources""" # PROTECTED REGION ID(SKASubarray.test_ReleaseResources) ENABLED START # - self.device.ReleaseResources([""]) + assert tango_context.device.ReleaseResources([""]) == [""] # PROTECTED REGION END # // SKASubarray.test_ReleaseResources - def test_Reset(self): + # PROTECTED REGION ID(SKASubarray.test_Reset_decorators) ENABLED START # + # PROTECTED REGION END # // SKASubarray.test_Reset_decorators + def test_Reset(self, tango_context): """Test for Reset""" # PROTECTED REGION ID(SKASubarray.test_Reset) ENABLED START # - self.device.Reset() + assert tango_context.device.Reset() == None # PROTECTED REGION END # // SKASubarray.test_Reset - def test_Resume(self): + # PROTECTED REGION ID(SKASubarray.test_Resume_decorators) ENABLED START # + # PROTECTED REGION END # // SKASubarray.test_Resume_decorators + def test_Resume(self, tango_context): """Test for Resume""" # PROTECTED REGION ID(SKASubarray.test_Resume) ENABLED START # - self.device.Resume() + assert tango_context.device.Resume() == None # PROTECTED REGION END # // SKASubarray.test_Resume - def test_Scan(self): + # PROTECTED REGION ID(SKASubarray.test_Scan_decorators) ENABLED START # + # PROTECTED REGION END # // SKASubarray.test_Scan_decorators + def test_Scan(self, tango_context): """Test for Scan""" # PROTECTED REGION ID(SKASubarray.test_Scan) ENABLED START # - self.device.Scan([""]) + assert tango_context.device.Scan([""]) == None # PROTECTED REGION END # // SKASubarray.test_Scan - def test_ToJson(self): + # PROTECTED REGION ID(SKASubarray.test_ToJson_decorators) ENABLED START # + # PROTECTED REGION END # // SKASubarray.test_ToJson_decorators + def test_ToJson(self, tango_context): """Test for ToJson""" # PROTECTED REGION ID(SKASubarray.test_ToJson) ENABLED START # - self.device.ToJson("") + assert tango_context.device.ToJson("") == "" # PROTECTED REGION END # // SKASubarray.test_ToJson - def test_activationTime(self): + + # PROTECTED REGION ID(SKASubarray.test_activationTime_decorators) ENABLED START # + # PROTECTED REGION END # // SKASubarray.test_activationTime_decorators + def test_activationTime(self, tango_context): """Test for activationTime""" # PROTECTED REGION ID(SKASubarray.test_activationTime) ENABLED START # - self.device.activationTime + assert tango_context.device.activationTime == 0.0 # PROTECTED REGION END # // SKASubarray.test_activationTime - def test_adminMode(self): + # PROTECTED REGION ID(SKASubarray.test_adminMode_decorators) ENABLED START # + # PROTECTED REGION END # // SKASubarray.test_adminMode_decorators + def test_adminMode(self, tango_context): """Test for adminMode""" # PROTECTED REGION ID(SKASubarray.test_adminMode) ENABLED START # - self.device.adminMode + assert tango_context.device.adminMode == 0 # PROTECTED REGION END # // SKASubarray.test_adminMode - def test_buildState(self): + # PROTECTED REGION ID(SKASubarray.test_buildState_decorators) ENABLED START # + # PROTECTED REGION END # // SKASubarray.test_buildState_decorators + def test_buildState(self, tango_context): """Test for buildState""" # PROTECTED REGION ID(SKASubarray.test_buildState) ENABLED START # - self.device.buildState + assert tango_context.device.buildState == '' # PROTECTED REGION END # // SKASubarray.test_buildState - def test_centralLoggingLevel(self): + # PROTECTED REGION ID(SKASubarray.test_centralLoggingLevel_decorators) ENABLED START # + # PROTECTED REGION END # // SKASubarray.test_centralLoggingLevel_decorators + def test_centralLoggingLevel(self, tango_context): """Test for centralLoggingLevel""" # PROTECTED REGION ID(SKASubarray.test_centralLoggingLevel) ENABLED START # - self.device.centralLoggingLevel + assert tango_context.device.centralLoggingLevel == 0 # PROTECTED REGION END # // SKASubarray.test_centralLoggingLevel - def test_configurationDelayExpected(self): + # PROTECTED REGION ID(SKASubarray.test_configurationDelayExpected_decorators) ENABLED START # + # PROTECTED REGION END # // SKASubarray.test_configurationDelayExpected_decorators + def test_configurationDelayExpected(self, tango_context): """Test for configurationDelayExpected""" # PROTECTED REGION ID(SKASubarray.test_configurationDelayExpected) ENABLED START # - self.device.configurationDelayExpected + assert tango_context.device.configurationDelayExpected == 0 # PROTECTED REGION END # // SKASubarray.test_configurationDelayExpected - def test_configurationProgress(self): + # PROTECTED REGION ID(SKASubarray.test_configurationProgress_decorators) ENABLED START # + # PROTECTED REGION END # // SKASubarray.test_configurationProgress_decorators + def test_configurationProgress(self, tango_context): """Test for configurationProgress""" # PROTECTED REGION ID(SKASubarray.test_configurationProgress) ENABLED START # - self.device.configurationProgress + assert tango_context.device.configurationProgress == 0 # PROTECTED REGION END # // SKASubarray.test_configurationProgress - def test_controlMode(self): + # PROTECTED REGION ID(SKASubarray.test_controlMode_decorators) ENABLED START # + # PROTECTED REGION END # // SKASubarray.test_controlMode_decorators + def test_controlMode(self, tango_context): """Test for controlMode""" # PROTECTED REGION ID(SKASubarray.test_controlMode) ENABLED START # - self.device.controlMode + assert tango_context.device.controlMode == 0 # PROTECTED REGION END # // SKASubarray.test_controlMode - def test_elementLoggingLevel(self): + # PROTECTED REGION ID(SKASubarray.test_elementLoggingLevel_decorators) ENABLED START # + # PROTECTED REGION END # // SKASubarray.test_elementLoggingLevel_decorators + def test_elementLoggingLevel(self, tango_context): """Test for elementLoggingLevel""" # PROTECTED REGION ID(SKASubarray.test_elementLoggingLevel) ENABLED START # - self.device.elementLoggingLevel + assert tango_context.device.elementLoggingLevel == 0 # PROTECTED REGION END # // SKASubarray.test_elementLoggingLevel - def test_healthState(self): + # PROTECTED REGION ID(SKASubarray.test_healthState_decorators) ENABLED START # + # PROTECTED REGION END # // SKASubarray.test_healthState_decorators + def test_healthState(self, tango_context): """Test for healthState""" # PROTECTED REGION ID(SKASubarray.test_healthState) ENABLED START # - self.device.healthState + assert tango_context.device.healthState == 0 # PROTECTED REGION END # // SKASubarray.test_healthState - def test_obsMode(self): + # PROTECTED REGION ID(SKASubarray.test_obsMode_decorators) ENABLED START # + # PROTECTED REGION END # // SKASubarray.test_obsMode_decorators + def test_obsMode(self, tango_context): """Test for obsMode""" # PROTECTED REGION ID(SKASubarray.test_obsMode) ENABLED START # - self.device.obsMode + assert tango_context.device.obsMode == 0 # PROTECTED REGION END # // SKASubarray.test_obsMode - def test_obsState(self): + # PROTECTED REGION ID(SKASubarray.test_obsState_decorators) ENABLED START # + # PROTECTED REGION END # // SKASubarray.test_obsState_decorators + def test_obsState(self, tango_context): """Test for obsState""" # PROTECTED REGION ID(SKASubarray.test_obsState) ENABLED START # - self.device.obsState + assert tango_context.device.obsState == 0 # PROTECTED REGION END # // SKASubarray.test_obsState - def test_simulationMode(self): + # PROTECTED REGION ID(SKASubarray.test_simulationMode_decorators) ENABLED START # + # PROTECTED REGION END # // SKASubarray.test_simulationMode_decorators + def test_simulationMode(self, tango_context): """Test for simulationMode""" # PROTECTED REGION ID(SKASubarray.test_simulationMode) ENABLED START # - self.device.simulationMode + assert tango_context.device.simulationMode == False # PROTECTED REGION END # // SKASubarray.test_simulationMode - def test_storageLoggingLevel(self): + # PROTECTED REGION ID(SKASubarray.test_storageLoggingLevel_decorators) ENABLED START # + # PROTECTED REGION END # // SKASubarray.test_storageLoggingLevel_decorators + def test_storageLoggingLevel(self, tango_context): """Test for storageLoggingLevel""" # PROTECTED REGION ID(SKASubarray.test_storageLoggingLevel) ENABLED START # - self.device.storageLoggingLevel + assert tango_context.device.storageLoggingLevel == 0 # PROTECTED REGION END # // SKASubarray.test_storageLoggingLevel - def test_testMode(self): + # PROTECTED REGION ID(SKASubarray.test_testMode_decorators) ENABLED START # + # PROTECTED REGION END # // SKASubarray.test_testMode_decorators + def test_testMode(self, tango_context): """Test for testMode""" # PROTECTED REGION ID(SKASubarray.test_testMode) ENABLED START # - self.device.testMode + assert tango_context.device.testMode == '' # PROTECTED REGION END # // SKASubarray.test_testMode - def test_versionId(self): + # PROTECTED REGION ID(SKASubarray.test_versionId_decorators) ENABLED START # + # PROTECTED REGION END # // SKASubarray.test_versionId_decorators + def test_versionId(self, tango_context): """Test for versionId""" # PROTECTED REGION ID(SKASubarray.test_versionId) ENABLED START # - self.device.versionId + assert tango_context.device.versionId == '' # PROTECTED REGION END # // SKASubarray.test_versionId - def test_assignedResources(self): + # PROTECTED REGION ID(SKASubarray.test_assignedResources_decorators) ENABLED START # + # PROTECTED REGION END # // SKASubarray.test_assignedResources_decorators + def test_assignedResources(self, tango_context): """Test for assignedResources""" # PROTECTED REGION ID(SKASubarray.test_assignedResources) ENABLED START # - self.device.assignedResources + assert tango_context.device.assignedResources == ('',) # PROTECTED REGION END # // SKASubarray.test_assignedResources - def test_configuredCapabilities(self): + # PROTECTED REGION ID(SKASubarray.test_configuredCapabilities_decorators) ENABLED START # + # PROTECTED REGION END # // SKASubarray.test_configuredCapabilities_decorators + def test_configuredCapabilities(self, tango_context): """Test for configuredCapabilities""" # PROTECTED REGION ID(SKASubarray.test_configuredCapabilities) ENABLED START # - self.device.configuredCapabilities + assert tango_context.device.configuredCapabilities == None # PROTECTED REGION END # // SKASubarray.test_configuredCapabilities -# Main execution -if __name__ == "__main__": - main() diff --git a/skabase/SKATelState/SKATelState.xmi b/skabase/SKATelState/SKATelState.xmi index 5fdc510491bee5142f43df3bb49f84d473e4afbe..c2965b90917b16e97dd5051938e9ae6b9cf8dc1c 100644 --- a/skabase/SKATelState/SKATelState.xmi +++ b/skabase/SKATelState/SKATelState.xmi @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="ASCII"?> <pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl"> <classes name="SKATelState" pogoRevision="9.6"> - <description description="A generic base device for Telescope State for SKA." title="SKATelState" sourcePath="/home/kat/src/levpro/skabase/SKATelState" language="PythonHL" filestogenerate="XMI file,Code files, Python Package, Protected Regions" license="GPL" copyright="" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> + <description description="A generic base device for Telescope State for SKA." title="SKATelState" sourcePath="/home/pogo/src/levpro/skabase/SKATelState" language="PythonHL" filestogenerate="XMI file,Code files,Python Package,Protected Regions" license="GPL" copyright="" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> <inheritances classname="Device_Impl" sourcePath=""/> <inheritances classname="SKABaseDevice" sourcePath="../SKABaseDevice"/> <identification contact="at ska.ac.za - cam" author="cam" emailDomain="ska.ac.za" classFamily="OtherInstruments" siteSpecific="" platform="All Platforms" bus="Not Applicable" manufacturer="SKASA" reference="SKA-SKATelState"/> @@ -16,11 +16,13 @@ <DefaultPropValue>4</DefaultPropValue> </deviceProperties> <deviceProperties name="MetricList" description="A subset of attributes we want to expose as metrics for this device."> - <type xsi:type="pogoDsl:StringType"/> + <type xsi:type="pogoDsl:StringVectorType"/> <status abstract="false" inherited="true" concrete="true"/> - <DefaultPropValue>healthState,adminMode,controlMode</DefaultPropValue> + <DefaultPropValue>healthState</DefaultPropValue> + <DefaultPropValue>adminMode</DefaultPropValue> + <DefaultPropValue>controlMode</DefaultPropValue> </deviceProperties> - <deviceProperties name="GroupDefinitions" description="List of grouped devices managed by a master. Each string in the array is a JSON 
document defining the ``groupname``, ``devices`` and ``groups`` in the group.
A proxy client will be opened for each of the managed devices.
A group will be instantiated for the managed devices per group.
Each entry in the array contains a JSON defining the group, like:
[ {``groupname``: ``group1``, 
 ``devices``: ``csv list of devices in group1``},
 {``groupname``: ``group2``, # a group with devices and a subgroup
 ``devices``: ``csv list of devices in group2``,
 ``groups`` : ``csv list of sub groups``},
 {``groupname``: ``group3``, 
 ``devices`` : ``csv list of devices in group3``}},
 {``groupname``: ``group4``, # a group with only subgroups
 ``groups`` : ``csv list of sub groups``}}]

e.g. for a hierarchy of racks, servers and switches
[{ ``groupname``: ``servers``, 
 ``devices``: ``elt/server/1,elt/server/2,elt/server/3,elt/server/4``},
 {``groupname``: ``switches``, 
 ``devices``: ``elt/switch/A,elt/switch/B``},
 {``groupname``: ``pdus``, 
 ``devices``: ``elt/pdu/rackA,elt/pdu/rackB``},
 {``groupname``:``rackA``, 
 ``devices``: ``elt/server/1,elt/server/2,elt/switch/A,elt/pdu/rackA``},
 {``groupname``:``rackB``,
 ``devices``: ``elt/server/3,elt/server/4,elt/switch/B,elt/pdu/rackB``},
 {``groupname``:``racks``,
 ``groups``: ``rackA,rackB``}]"> + <deviceProperties name="GroupDefinitions" description="Each string in the list is a JSON serialised dict defining the ``group_name``,
``devices`` and ``subgroups`` in the group. A TANGO Group object is created
for each item in the list, according to the hierarchy defined. This provides
easy access to the managed devices in bulk, or individually.

The general format of the list is as follows, with optional ``devices`` and
``subgroups`` keys:
 [ {``group_name``: ``<name>``,
 ``devices``: [``<dev name>``, ...]},
 {``group_name``: ``<name>``,
 ``devices``: [``<dev name>``, ``<dev name>``, ...],
 ``subgroups`` : [{<nested group>},
 {<nested group>}, ...]},
 ...
 ]

For example, a hierarchy of racks, servers and switches:
 [ {``group_name``: ``servers``,
 ``devices``: [``elt/server/1``, ``elt/server/2``,
 ``elt/server/3``, ``elt/server/4``]},
 {``group_name``: ``switches``,
 ``devices``: [``elt/switch/A``, ``elt/switch/B``]},
 {``group_name``: ``pdus``,
 ``devices``: [``elt/pdu/rackA``, ``elt/pdu/rackB``]},
 {``group_name``: ``racks``,
 ``subgroups``: [
 {``group_name``: ``rackA``,
 ``devices``: [``elt/server/1``, ``elt/server/2``,
 ``elt/switch/A``, ``elt/pdu/rackA``]},
 {``group_name``: ``rackB``,
 ``devices``: [``elt/server/3``, ``elt/server/4``,
 ``elt/switch/B``, ``elt/pdu/rackB``],
 ``subgroups``: []}
 ]} ]"> <type xsi:type="pogoDsl:StringVectorType"/> <status abstract="false" inherited="true" concrete="true"/> </deviceProperties> @@ -55,15 +57,6 @@ </argout> <status abstract="true" inherited="true" concrete="true"/> </commands> - <commands name="Reset" description="Refresh the device to startup state - re-loading config file" execMethod="reset" displayLevel="OPERATOR" polledPeriod="0"> - <argin description=""> - <type xsi:type="pogoDsl:VoidType"/> - </argin> - <argout description=""> - <type xsi:type="pogoDsl:VoidType"/> - </argout> - <status abstract="true" inherited="true" concrete="true" concreteHere="true"/> - </commands> <commands name="GetMetrics" description="Gets list of attributes marked as metrics, with their values, 
for device" execMethod="get_metrics" displayLevel="OPERATOR" polledPeriod="0"> <argin description=""> <type xsi:type="pogoDsl:VoidType"/> @@ -91,6 +84,15 @@ </argout> <status abstract="false" inherited="true" concrete="true"/> </commands> + <commands name="Reset" description="Reset device to its default state" execMethod="reset" displayLevel="OPERATOR" polledPeriod="0"> + <argin description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argin> + <argout description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argout> + <status abstract="false" inherited="true" concrete="true"/> + </commands> <attributes name="buildState" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="60000" maxX="" maxY="" allocReadMember="true"> <dataType xsi:type="pogoDsl:StringType"/> <status abstract="false" inherited="true" concrete="true"/> @@ -165,6 +167,6 @@ <states name="DISABLE" description="The device cannot be switched ON for an external reason. E.g. the power supply has its door open, the safety conditions are not satisfactory to allow the device to operate."> <status abstract="false" inherited="true" concrete="true"/> </states> - <preferences docHome="./doc_html" makefileHome="/usr/share/pogo/preferences"/> + <preferences docHome="./doc_html" makefileHome="$(TANGO_HOME)"/> </classes> </pogoDsl:PogoSystem> diff --git a/skabase/SKATelState/SKATelState/SKATelState.py b/skabase/SKATelState/SKATelState/SKATelState.py index a74f336b7e1cf7eb5a9af4ececeb861d87d9c581..1b5dbea93ee1bf124f921a3a9fc71c9b1fba882a 100644 --- a/skabase/SKATelState/SKATelState/SKATelState.py +++ b/skabase/SKATelState/SKATelState/SKATelState.py @@ -93,14 +93,6 @@ class SKATelState(SKABaseDevice): # Commands # -------- - @command( - ) - @DebugIt() - def Reset(self): - # PROTECTED REGION ID(SKATelState.Reset) ENABLED START # - pass - # PROTECTED REGION END # // SKATelState.Reset - # ---------- # Run server # ---------- diff --git a/skabase/SKATelState/test/SKATelState_test.py b/skabase/SKATelState/test/SKATelState_test.py index 89bd694a2f4ac1f92e8200caaea02c219f039e7f..802c8351e23e7ef11a1d29561a65c9e59065e26f 100644 --- a/skabase/SKATelState/test/SKATelState_test.py +++ b/skabase/SKATelState/test/SKATelState_test.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +######################################################################################### # -*- coding: utf-8 -*- # # This file is part of the SKATelState project @@ -7,6 +7,7 @@ # # Distributed under the terms of the GPL license. # See LICENSE.txt for more info. +######################################################################################### """Contain the tests for the SKATelState.""" # Path @@ -16,32 +17,31 @@ path = os.path.join(os.path.dirname(__file__), os.pardir) sys.path.insert(0, os.path.abspath(path)) # Imports -from time import sleep +import pytest from mock import MagicMock -from PyTango import DevFailed, DevState -from devicetest import DeviceTestCase, main -from SKATelState import SKATelState -# Note: -# -# Since the device uses an inner thread, it is necessary to -# wait during the tests in order the let the device update itself. -# Hence, the sleep calls have to be secured enough not to produce -# any inconsistent behavior. However, the unittests need to run fast. -# Here, we use a factor 3 between the read period and the sleep calls. -# -# Look at devicetest examples for more advanced testing +from PyTango import DevState + +# PROTECTED REGION ID(SKATelState.test_additional_imports) ENABLED START # +# PROTECTED REGION END # // SKATelState.test_additional_imports # Device test case -class SKATelStateDeviceTestCase(DeviceTestCase): +@pytest.mark.usefixtures("tango_context", "initialize_device") +# PROTECTED REGION ID(SKATelState.test_SKATelState_decorators) ENABLED START # +# PROTECTED REGION END # // SKATelState.test_SKATelState_decorators +class TestSKATelState(object): """Test case for packet generation.""" - # PROTECTED REGION ID(SKATelState.test_additionnal_import) ENABLED START # - # PROTECTED REGION END # // SKATelState.test_additionnal_import - device = SKATelState - properties = {'TelStateConfigFile': '', 'SkaLevel': '4', 'MetricList': 'healthState,adminMode,controlMode', 'GroupDefinitions': '', 'CentralLoggingTarget': '', 'ElementLoggingTarget': '', 'StorageLoggingTarget': 'localhost', - } - empty = None # Should be [] + + properties = { + 'TelStateConfigFile': '', + 'SkaLevel': '4', + 'MetricList': 'healthState', + 'GroupDefinitions': '', + 'CentralLoggingTarget': '', + 'ElementLoggingTarget': '', + 'StorageLoggingTarget': 'localhost', + } @classmethod def mocking(cls): @@ -51,109 +51,139 @@ class SKATelStateDeviceTestCase(DeviceTestCase): # PROTECTED REGION ID(SKATelState.test_mocking) ENABLED START # # PROTECTED REGION END # // SKATelState.test_mocking - def test_properties(self): - # test the properties + def test_properties(self, tango_context): + # Test the properties # PROTECTED REGION ID(SKATelState.test_properties) ENABLED START # # PROTECTED REGION END # // SKATelState.test_properties pass - def test_State(self): + # PROTECTED REGION ID(SKATelState.test_State_decorators) ENABLED START # + # PROTECTED REGION END # // SKATelState.test_State_decorators + def test_State(self, tango_context): """Test for State""" # PROTECTED REGION ID(SKATelState.test_State) ENABLED START # - self.device.State() + assert tango_context.device.State() == DevState.UNKNOWN # PROTECTED REGION END # // SKATelState.test_State - def test_Status(self): + # PROTECTED REGION ID(SKATelState.test_Status_decorators) ENABLED START # + # PROTECTED REGION END # // SKATelState.test_Status_decorators + def test_Status(self, tango_context): """Test for Status""" # PROTECTED REGION ID(SKATelState.test_Status) ENABLED START # - self.device.Status() + assert tango_context.device.Status() == "The device is in UNKNOWN state." # PROTECTED REGION END # // SKATelState.test_Status - def test_Reset(self): - """Test for Reset""" - # PROTECTED REGION ID(SKATelState.test_Reset) ENABLED START # - self.device.Reset() - # PROTECTED REGION END # // SKATelState.test_Reset - - def test_GetMetrics(self): + # PROTECTED REGION ID(SKATelState.test_GetMetrics_decorators) ENABLED START # + # PROTECTED REGION END # // SKATelState.test_GetMetrics_decorators + def test_GetMetrics(self, tango_context): """Test for GetMetrics""" # PROTECTED REGION ID(SKATelState.test_GetMetrics) ENABLED START # - self.device.GetMetrics() + assert tango_context.device.GetMetrics() == "" # PROTECTED REGION END # // SKATelState.test_GetMetrics - def test_ToJson(self): + # PROTECTED REGION ID(SKATelState.test_ToJson_decorators) ENABLED START # + # PROTECTED REGION END # // SKATelState.test_ToJson_decorators + def test_ToJson(self, tango_context): """Test for ToJson""" # PROTECTED REGION ID(SKATelState.test_ToJson) ENABLED START # - self.device.ToJson("") + assert tango_context.device.ToJson("") == "" # PROTECTED REGION END # // SKATelState.test_ToJson - def test_GetVersionInfo(self): + # PROTECTED REGION ID(SKATelState.test_GetVersionInfo_decorators) ENABLED START # + # PROTECTED REGION END # // SKATelState.test_GetVersionInfo_decorators + def test_GetVersionInfo(self, tango_context): """Test for GetVersionInfo""" # PROTECTED REGION ID(SKATelState.test_GetVersionInfo) ENABLED START # - self.device.GetVersionInfo() + assert tango_context.device.GetVersionInfo() == [""] # PROTECTED REGION END # // SKATelState.test_GetVersionInfo - def test_buildState(self): + # PROTECTED REGION ID(SKATelState.test_Reset_decorators) ENABLED START # + # PROTECTED REGION END # // SKATelState.test_Reset_decorators + def test_Reset(self, tango_context): + """Test for Reset""" + # PROTECTED REGION ID(SKATelState.test_Reset) ENABLED START # + assert tango_context.device.Reset() == None + # PROTECTED REGION END # // SKATelState.test_Reset + + + # PROTECTED REGION ID(SKATelState.test_buildState_decorators) ENABLED START # + # PROTECTED REGION END # // SKATelState.test_buildState_decorators + def test_buildState(self, tango_context): """Test for buildState""" # PROTECTED REGION ID(SKATelState.test_buildState) ENABLED START # - self.device.buildState + assert tango_context.device.buildState == '' # PROTECTED REGION END # // SKATelState.test_buildState - def test_versionId(self): + # PROTECTED REGION ID(SKATelState.test_versionId_decorators) ENABLED START # + # PROTECTED REGION END # // SKATelState.test_versionId_decorators + def test_versionId(self, tango_context): """Test for versionId""" # PROTECTED REGION ID(SKATelState.test_versionId) ENABLED START # - self.device.versionId + assert tango_context.device.versionId == '' # PROTECTED REGION END # // SKATelState.test_versionId - def test_centralLoggingLevel(self): + # PROTECTED REGION ID(SKATelState.test_centralLoggingLevel_decorators) ENABLED START # + # PROTECTED REGION END # // SKATelState.test_centralLoggingLevel_decorators + def test_centralLoggingLevel(self, tango_context): """Test for centralLoggingLevel""" # PROTECTED REGION ID(SKATelState.test_centralLoggingLevel) ENABLED START # - self.device.centralLoggingLevel + assert tango_context.device.centralLoggingLevel == 0 # PROTECTED REGION END # // SKATelState.test_centralLoggingLevel - def test_elementLoggingLevel(self): + # PROTECTED REGION ID(SKATelState.test_elementLoggingLevel_decorators) ENABLED START # + # PROTECTED REGION END # // SKATelState.test_elementLoggingLevel_decorators + def test_elementLoggingLevel(self, tango_context): """Test for elementLoggingLevel""" # PROTECTED REGION ID(SKATelState.test_elementLoggingLevel) ENABLED START # - self.device.elementLoggingLevel + assert tango_context.device.elementLoggingLevel == 0 # PROTECTED REGION END # // SKATelState.test_elementLoggingLevel - def test_storageLoggingLevel(self): + # PROTECTED REGION ID(SKATelState.test_storageLoggingLevel_decorators) ENABLED START # + # PROTECTED REGION END # // SKATelState.test_storageLoggingLevel_decorators + def test_storageLoggingLevel(self, tango_context): """Test for storageLoggingLevel""" # PROTECTED REGION ID(SKATelState.test_storageLoggingLevel) ENABLED START # - self.device.storageLoggingLevel + assert tango_context.device.storageLoggingLevel == 0 # PROTECTED REGION END # // SKATelState.test_storageLoggingLevel - def test_healthState(self): + # PROTECTED REGION ID(SKATelState.test_healthState_decorators) ENABLED START # + # PROTECTED REGION END # // SKATelState.test_healthState_decorators + def test_healthState(self, tango_context): """Test for healthState""" # PROTECTED REGION ID(SKATelState.test_healthState) ENABLED START # - self.device.healthState + assert tango_context.device.healthState == 0 # PROTECTED REGION END # // SKATelState.test_healthState - def test_adminMode(self): + # PROTECTED REGION ID(SKATelState.test_adminMode_decorators) ENABLED START # + # PROTECTED REGION END # // SKATelState.test_adminMode_decorators + def test_adminMode(self, tango_context): """Test for adminMode""" # PROTECTED REGION ID(SKATelState.test_adminMode) ENABLED START # - self.device.adminMode + assert tango_context.device.adminMode == 0 # PROTECTED REGION END # // SKATelState.test_adminMode - def test_controlMode(self): + # PROTECTED REGION ID(SKATelState.test_controlMode_decorators) ENABLED START # + # PROTECTED REGION END # // SKATelState.test_controlMode_decorators + def test_controlMode(self, tango_context): """Test for controlMode""" # PROTECTED REGION ID(SKATelState.test_controlMode) ENABLED START # - self.device.controlMode + assert tango_context.device.controlMode == 0 # PROTECTED REGION END # // SKATelState.test_controlMode - def test_simulationMode(self): + # PROTECTED REGION ID(SKATelState.test_simulationMode_decorators) ENABLED START # + # PROTECTED REGION END # // SKATelState.test_simulationMode_decorators + def test_simulationMode(self, tango_context): """Test for simulationMode""" # PROTECTED REGION ID(SKATelState.test_simulationMode) ENABLED START # - self.device.simulationMode + assert tango_context.device.simulationMode == False # PROTECTED REGION END # // SKATelState.test_simulationMode - def test_testMode(self): + # PROTECTED REGION ID(SKATelState.test_testMode_decorators) ENABLED START # + # PROTECTED REGION END # // SKATelState.test_testMode_decorators + def test_testMode(self, tango_context): """Test for testMode""" # PROTECTED REGION ID(SKATelState.test_testMode) ENABLED START # - self.device.testMode + assert tango_context.device.testMode == '' # PROTECTED REGION END # // SKATelState.test_testMode -# Main execution -if __name__ == "__main__": - main() diff --git a/skabase/SKATestDevice/SKATestDevice.xmi b/skabase/SKATestDevice/SKATestDevice.xmi index a8bad68521e94392e77a562832e6ef316a66412a..24007f53c7625d702a162660af07d9e5a730715c 100644 --- a/skabase/SKATestDevice/SKATestDevice.xmi +++ b/skabase/SKATestDevice/SKATestDevice.xmi @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="ASCII"?> <pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl"> <classes name="SKATestDevice" pogoRevision="9.6"> - <description description="A generic Test device for testing SKA base class functionalites." title="SKATestDevice" sourcePath="/home/tango-cs/src/levpro/skabase/SKATestDevice" language="PythonHL" filestogenerate="XMI file,Code files,Python Package,Protected Regions" license="GPL" copyright="" hasMandatoryProperty="false" hasConcreteProperty="false" hasAbstractCommand="false" hasAbstractAttribute="false"> + <description description="A generic Test device for testing SKA base class functionalites." title="SKATestDevice" sourcePath="/home/pogo/src/levpro/skabase/SKATestDevice" language="PythonHL" filestogenerate="XMI file,Code files,Python Package,Protected Regions" license="GPL" copyright="" hasMandatoryProperty="false" hasConcreteProperty="false" hasAbstractCommand="false" hasAbstractAttribute="false"> <inheritances classname="Device_Impl" sourcePath=""/> <inheritances classname="SKABaseDevice" sourcePath="../SKABaseDevice"/> <identification contact="at ska.ac.za - cam" author="cam" emailDomain="ska.ac.za" classFamily="OtherInstruments" siteSpecific="" platform="All Platforms" bus="Not Applicable" manufacturer="SKASA" reference="SKA-SKATestDevice"/> @@ -51,15 +51,6 @@ <type xsi:type="pogoDsl:UShortType"/> <status abstract="false" inherited="true" concrete="true"/> </deviceProperties> - <commands name="Reset" description="Reset device to its default state" execMethod="reset" displayLevel="OPERATOR" polledPeriod="0"> - <argin description=""> - <type xsi:type="pogoDsl:VoidType"/> - </argin> - <argout description=""> - <type xsi:type="pogoDsl:VoidType"/> - </argout> - <status abstract="false" inherited="true" concrete="true" concreteHere="true"/> - </commands> <commands name="GetMetrics" description="Gets list of attributes marked as metrics, with their values, 
for device" execMethod="get_metrics" displayLevel="OPERATOR" polledPeriod="0"> <argin description=""> <type xsi:type="pogoDsl:VoidType"/> @@ -114,6 +105,15 @@ </argout> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </commands> + <commands name="Reset" description="Reset device to its default state" execMethod="reset" displayLevel="OPERATOR" polledPeriod="0"> + <argin description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argin> + <argout description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argout> + <status abstract="false" inherited="true" concrete="true"/> + </commands> <attributes name="obsState" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false"> <dataType xsi:type="pogoDsl:EnumType"/> <dataReadyEvent fire="false" libCheckCriteria="true"/> @@ -228,7 +228,7 @@ <states name="DISABLE" description="The device cannot be switched ON for an external reason. E.g. the power supply has its door open, the safety conditions are not satisfactory to allow the device to operate."> <status abstract="false" inherited="true" concrete="true"/> </states> - <preferences docHome="./doc_html" makefileHome="/usr/share/pogo/preferences"/> + <preferences docHome="./doc_html" makefileHome="$(TANGO_HOME)"/> <overlodedPollPeriodObject name="centralLoggingLevel" type="attribute" pollPeriod="0"/> <overlodedPollPeriodObject name="elementLoggingLevel" type="attribute" pollPeriod="0"/> <overlodedPollPeriodObject name="storageLoggingLevel" type="attribute" pollPeriod="0"/> diff --git a/skabase/SKATestDevice/SKATestDevice/SKATestDevice.py b/skabase/SKATestDevice/SKATestDevice/SKATestDevice.py index 8e6eee116a8464eae39c5edf3a5dfb9ac39548de..b10d71a0d1a5033878db5c49b2f4a40c56d6c70f 100644 --- a/skabase/SKATestDevice/SKATestDevice/SKATestDevice.py +++ b/skabase/SKATestDevice/SKATestDevice/SKATestDevice.py @@ -142,14 +142,6 @@ class SKATestDevice(SKABaseDevice): # Commands # -------- - @command( - ) - @DebugIt() - def Reset(self): - # PROTECTED REGION ID(SKATestDevice.Reset) ENABLED START # - pass - # PROTECTED REGION END # // SKATestDevice.Reset - @command( dtype_in='str', doc_in="JSON encoded dict with this format\n{``group``: str, # name of existing group\n ``command``: str, # name of command to run\n ``arg_type``: str, # data type of command input argument\n ``arg_value``: str, # value for command input argument\n ``forward``: bool # True if command should be forwarded to all subgroups (default)\n}", diff --git a/skabase/SKATestDevice/test/SKATestDevice_test.py b/skabase/SKATestDevice/test/SKATestDevice_test.py index f57f8236e3f2e5346a7df95f3327eeec1eda63af..a6b12e8fc3ef1f826b4bbcec2351b4310827884a 100644 --- a/skabase/SKATestDevice/test/SKATestDevice_test.py +++ b/skabase/SKATestDevice/test/SKATestDevice_test.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +######################################################################################### # -*- coding: utf-8 -*- # # This file is part of the SKATestDevice project @@ -7,6 +7,7 @@ # # Distributed under the terms of the GPL license. # See LICENSE.txt for more info. +######################################################################################### """Contain the tests for the SKATestDevice.""" # Path @@ -16,32 +17,34 @@ path = os.path.join(os.path.dirname(__file__), os.pardir) sys.path.insert(0, os.path.abspath(path)) # Imports -from time import sleep +import pytest from mock import MagicMock -from PyTango import DevFailed, DevState -from devicetest import DeviceTestCase, main -from SKATestDevice import SKATestDevice -# Note: -# -# Since the device uses an inner thread, it is necessary to -# wait during the tests in order the let the device update itself. -# Hence, the sleep calls have to be secured enough not to produce -# any inconsistent behavior. However, the unittests need to run fast. -# Here, we use a factor 3 between the read period and the sleep calls. -# -# Look at devicetest examples for more advanced testing +from PyTango import DevState + +# PROTECTED REGION ID(SKATestDevice.test_additional_imports) ENABLED START # +# PROTECTED REGION END # // SKATestDevice.test_additional_imports # Device test case -class SKATestDeviceDeviceTestCase(DeviceTestCase): +@pytest.mark.usefixtures("tango_context", "initialize_device") +# PROTECTED REGION ID(SKATestDevice.test_SKATestDevice_decorators) ENABLED START # +# PROTECTED REGION END # // SKATestDevice.test_SKATestDevice_decorators +class TestSKATestDevice(object): """Test case for packet generation.""" - # PROTECTED REGION ID(SKATestDevice.test_additionnal_import) ENABLED START # - # PROTECTED REGION END # // SKATestDevice.test_additionnal_import - device = SKATestDevice - properties = {'SkaLevel': '4', 'CentralLoggingTarget': '', 'ElementLoggingTarget': '', 'StorageLoggingTarget': 'localhost', 'CentralLoggingLevelDefault': '', 'ElementLoggingLevelDefault': '', 'StorageLoggingLevelStorage': '', 'MetricList': 'healthState', 'GroupDefinitions': '', 'StorageLoggingLevelDefault': '', - } - empty = None # Should be [] + + properties = { + 'SkaLevel': '4', + 'CentralLoggingTarget': '', + 'ElementLoggingTarget': '', + 'StorageLoggingTarget': 'localhost', + 'CentralLoggingLevelDefault': '', + 'ElementLoggingLevelDefault': '', + 'StorageLoggingLevelStorage': '', + 'MetricList': 'healthState', + 'GroupDefinitions': '', + 'StorageLoggingLevelDefault': '', + } @classmethod def mocking(cls): @@ -51,139 +54,179 @@ class SKATestDeviceDeviceTestCase(DeviceTestCase): # PROTECTED REGION ID(SKATestDevice.test_mocking) ENABLED START # # PROTECTED REGION END # // SKATestDevice.test_mocking - def test_properties(self): - # test the properties + def test_properties(self, tango_context): + # Test the properties # PROTECTED REGION ID(SKATestDevice.test_properties) ENABLED START # # PROTECTED REGION END # // SKATestDevice.test_properties pass - def test_Reset(self): - """Test for Reset""" - # PROTECTED REGION ID(SKATestDevice.test_Reset) ENABLED START # - self.device.Reset() - # PROTECTED REGION END # // SKATestDevice.test_Reset - - def test_GetMetrics(self): + # PROTECTED REGION ID(SKATestDevice.test_GetMetrics_decorators) ENABLED START # + # PROTECTED REGION END # // SKATestDevice.test_GetMetrics_decorators + def test_GetMetrics(self, tango_context): """Test for GetMetrics""" # PROTECTED REGION ID(SKATestDevice.test_GetMetrics) ENABLED START # - self.device.GetMetrics() + assert tango_context.device.GetMetrics() == "" # PROTECTED REGION END # // SKATestDevice.test_GetMetrics - def test_ToJson(self): + # PROTECTED REGION ID(SKATestDevice.test_ToJson_decorators) ENABLED START # + # PROTECTED REGION END # // SKATestDevice.test_ToJson_decorators + def test_ToJson(self, tango_context): """Test for ToJson""" # PROTECTED REGION ID(SKATestDevice.test_ToJson) ENABLED START # - self.device.ToJson("") + assert tango_context.device.ToJson("") == "" # PROTECTED REGION END # // SKATestDevice.test_ToJson - def test_GetVersionInfo(self): + # PROTECTED REGION ID(SKATestDevice.test_GetVersionInfo_decorators) ENABLED START # + # PROTECTED REGION END # // SKATestDevice.test_GetVersionInfo_decorators + def test_GetVersionInfo(self, tango_context): """Test for GetVersionInfo""" # PROTECTED REGION ID(SKATestDevice.test_GetVersionInfo) ENABLED START # - self.device.GetVersionInfo() + assert tango_context.device.GetVersionInfo() == [""] # PROTECTED REGION END # // SKATestDevice.test_GetVersionInfo - def test_State(self): + # PROTECTED REGION ID(SKATestDevice.test_State_decorators) ENABLED START # + # PROTECTED REGION END # // SKATestDevice.test_State_decorators + def test_State(self, tango_context): """Test for State""" # PROTECTED REGION ID(SKATestDevice.test_State) ENABLED START # - self.device.State() + assert tango_context.device.State() == DevState.UNKNOWN # PROTECTED REGION END # // SKATestDevice.test_State - def test_Status(self): + # PROTECTED REGION ID(SKATestDevice.test_Status_decorators) ENABLED START # + # PROTECTED REGION END # // SKATestDevice.test_Status_decorators + def test_Status(self, tango_context): """Test for Status""" # PROTECTED REGION ID(SKATestDevice.test_Status) ENABLED START # - self.device.Status() + assert tango_context.device.Status() == "The device is in UNKNOWN state." # PROTECTED REGION END # // SKATestDevice.test_Status - def test_RunGroupCommand(self): + # PROTECTED REGION ID(SKATestDevice.test_RunGroupCommand_decorators) ENABLED START # + # PROTECTED REGION END # // SKATestDevice.test_RunGroupCommand_decorators + def test_RunGroupCommand(self, tango_context): """Test for RunGroupCommand""" # PROTECTED REGION ID(SKATestDevice.test_RunGroupCommand) ENABLED START # - self.device.RunGroupCommand("") + assert tango_context.device.RunGroupCommand("") == "" # PROTECTED REGION END # // SKATestDevice.test_RunGroupCommand - def test_obsState(self): + # PROTECTED REGION ID(SKATestDevice.test_Reset_decorators) ENABLED START # + # PROTECTED REGION END # // SKATestDevice.test_Reset_decorators + def test_Reset(self, tango_context): + """Test for Reset""" + # PROTECTED REGION ID(SKATestDevice.test_Reset) ENABLED START # + assert tango_context.device.Reset() == None + # PROTECTED REGION END # // SKATestDevice.test_Reset + + + # PROTECTED REGION ID(SKATestDevice.test_obsState_decorators) ENABLED START # + # PROTECTED REGION END # // SKATestDevice.test_obsState_decorators + def test_obsState(self, tango_context): """Test for obsState""" # PROTECTED REGION ID(SKATestDevice.test_obsState) ENABLED START # - self.device.obsState + assert tango_context.device.obsState == 0 # PROTECTED REGION END # // SKATestDevice.test_obsState - def test_obsMode(self): + # PROTECTED REGION ID(SKATestDevice.test_obsMode_decorators) ENABLED START # + # PROTECTED REGION END # // SKATestDevice.test_obsMode_decorators + def test_obsMode(self, tango_context): """Test for obsMode""" # PROTECTED REGION ID(SKATestDevice.test_obsMode) ENABLED START # - self.device.obsMode + assert tango_context.device.obsMode == 0 # PROTECTED REGION END # // SKATestDevice.test_obsMode - def test_configurationProgress(self): + # PROTECTED REGION ID(SKATestDevice.test_configurationProgress_decorators) ENABLED START # + # PROTECTED REGION END # // SKATestDevice.test_configurationProgress_decorators + def test_configurationProgress(self, tango_context): """Test for configurationProgress""" # PROTECTED REGION ID(SKATestDevice.test_configurationProgress) ENABLED START # - self.device.configurationProgress + assert tango_context.device.configurationProgress == 0 # PROTECTED REGION END # // SKATestDevice.test_configurationProgress - def test_configurationDelayExpected(self): + # PROTECTED REGION ID(SKATestDevice.test_configurationDelayExpected_decorators) ENABLED START # + # PROTECTED REGION END # // SKATestDevice.test_configurationDelayExpected_decorators + def test_configurationDelayExpected(self, tango_context): """Test for configurationDelayExpected""" # PROTECTED REGION ID(SKATestDevice.test_configurationDelayExpected) ENABLED START # - self.device.configurationDelayExpected + assert tango_context.device.configurationDelayExpected == 0 # PROTECTED REGION END # // SKATestDevice.test_configurationDelayExpected - def test_buildState(self): + # PROTECTED REGION ID(SKATestDevice.test_buildState_decorators) ENABLED START # + # PROTECTED REGION END # // SKATestDevice.test_buildState_decorators + def test_buildState(self, tango_context): """Test for buildState""" # PROTECTED REGION ID(SKATestDevice.test_buildState) ENABLED START # - self.device.buildState + assert tango_context.device.buildState == '' # PROTECTED REGION END # // SKATestDevice.test_buildState - def test_versionId(self): + # PROTECTED REGION ID(SKATestDevice.test_versionId_decorators) ENABLED START # + # PROTECTED REGION END # // SKATestDevice.test_versionId_decorators + def test_versionId(self, tango_context): """Test for versionId""" # PROTECTED REGION ID(SKATestDevice.test_versionId) ENABLED START # - self.device.versionId + assert tango_context.device.versionId == '' # PROTECTED REGION END # // SKATestDevice.test_versionId - def test_centralLoggingLevel(self): + # PROTECTED REGION ID(SKATestDevice.test_centralLoggingLevel_decorators) ENABLED START # + # PROTECTED REGION END # // SKATestDevice.test_centralLoggingLevel_decorators + def test_centralLoggingLevel(self, tango_context): """Test for centralLoggingLevel""" # PROTECTED REGION ID(SKATestDevice.test_centralLoggingLevel) ENABLED START # - self.device.centralLoggingLevel + assert tango_context.device.centralLoggingLevel == 0 # PROTECTED REGION END # // SKATestDevice.test_centralLoggingLevel - def test_elementLoggingLevel(self): + # PROTECTED REGION ID(SKATestDevice.test_elementLoggingLevel_decorators) ENABLED START # + # PROTECTED REGION END # // SKATestDevice.test_elementLoggingLevel_decorators + def test_elementLoggingLevel(self, tango_context): """Test for elementLoggingLevel""" # PROTECTED REGION ID(SKATestDevice.test_elementLoggingLevel) ENABLED START # - self.device.elementLoggingLevel + assert tango_context.device.elementLoggingLevel == 0 # PROTECTED REGION END # // SKATestDevice.test_elementLoggingLevel - def test_storageLoggingLevel(self): + # PROTECTED REGION ID(SKATestDevice.test_storageLoggingLevel_decorators) ENABLED START # + # PROTECTED REGION END # // SKATestDevice.test_storageLoggingLevel_decorators + def test_storageLoggingLevel(self, tango_context): """Test for storageLoggingLevel""" # PROTECTED REGION ID(SKATestDevice.test_storageLoggingLevel) ENABLED START # - self.device.storageLoggingLevel + assert tango_context.device.storageLoggingLevel == 0 # PROTECTED REGION END # // SKATestDevice.test_storageLoggingLevel - def test_healthState(self): + # PROTECTED REGION ID(SKATestDevice.test_healthState_decorators) ENABLED START # + # PROTECTED REGION END # // SKATestDevice.test_healthState_decorators + def test_healthState(self, tango_context): """Test for healthState""" # PROTECTED REGION ID(SKATestDevice.test_healthState) ENABLED START # - self.device.healthState + assert tango_context.device.healthState == 0 # PROTECTED REGION END # // SKATestDevice.test_healthState - def test_adminMode(self): + # PROTECTED REGION ID(SKATestDevice.test_adminMode_decorators) ENABLED START # + # PROTECTED REGION END # // SKATestDevice.test_adminMode_decorators + def test_adminMode(self, tango_context): """Test for adminMode""" # PROTECTED REGION ID(SKATestDevice.test_adminMode) ENABLED START # - self.device.adminMode + assert tango_context.device.adminMode == 0 # PROTECTED REGION END # // SKATestDevice.test_adminMode - def test_controlMode(self): + # PROTECTED REGION ID(SKATestDevice.test_controlMode_decorators) ENABLED START # + # PROTECTED REGION END # // SKATestDevice.test_controlMode_decorators + def test_controlMode(self, tango_context): """Test for controlMode""" # PROTECTED REGION ID(SKATestDevice.test_controlMode) ENABLED START # - self.device.controlMode + assert tango_context.device.controlMode == 0 # PROTECTED REGION END # // SKATestDevice.test_controlMode - def test_simulationMode(self): + # PROTECTED REGION ID(SKATestDevice.test_simulationMode_decorators) ENABLED START # + # PROTECTED REGION END # // SKATestDevice.test_simulationMode_decorators + def test_simulationMode(self, tango_context): """Test for simulationMode""" # PROTECTED REGION ID(SKATestDevice.test_simulationMode) ENABLED START # - self.device.simulationMode + assert tango_context.device.simulationMode == False # PROTECTED REGION END # // SKATestDevice.test_simulationMode - def test_testMode(self): + # PROTECTED REGION ID(SKATestDevice.test_testMode_decorators) ENABLED START # + # PROTECTED REGION END # // SKATestDevice.test_testMode_decorators + def test_testMode(self, tango_context): """Test for testMode""" # PROTECTED REGION ID(SKATestDevice.test_testMode) ENABLED START # - self.device.testMode + assert tango_context.device.testMode == '' # PROTECTED REGION END # // SKATestDevice.test_testMode -# Main execution -if __name__ == "__main__": - main()