Skip to content
Snippets Groups Projects
Commit bcc15ccc authored by toor's avatar toor
Browse files

CT-123: Added is_XXX_allowed() method for the implemented TANGO commands.

Implemented tests and documentation for CspSubElmentMaster.
parent 08acea23
No related branches found
No related tags found
No related merge requests found
.. LMC Base Classes documentation master file, created by
sphinx-quickstart on Fri Jan 11 10:03:42 2019.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
SKA CspSubElementMaster
============================================
.. toctree::
:maxdepth: 2
.. automodule:: ska.base.csp_subelement_master
.. autoclass:: ska.base.CspSubElementMaster
:members:
:undoc-members:
...@@ -20,6 +20,8 @@ Welcome to LMC Base Classes documentation! ...@@ -20,6 +20,8 @@ Welcome to LMC Base Classes documentation!
Device: SKA Capability<SKACapability> Device: SKA Capability<SKACapability>
Device: SKA Subarray<SKASubarray> Device: SKA Subarray<SKASubarray>
Device: SKA CspSubElementMaster>CspSubElementMaster>
SKA Control Model<Control_Model> SKA Control Model<Control_Model>
SKA Commands<Commands> SKA Commands<Commands>
SKA State Machine<State_Machine> SKA State Machine<State_Machine>
......
...@@ -48,6 +48,7 @@ setuptools.setup( ...@@ -48,6 +48,7 @@ setuptools.setup(
"SKAObsDevice=ska.base.obs_device:main", "SKAObsDevice=ska.base.obs_device:main",
"SKASubarray=ska.base.subarray_device:main", "SKASubarray=ska.base.subarray_device:main",
"SKATelState=ska.base.tel_state_device:main", "SKATelState=ska.base.tel_state_device:main",
"CspSubelementMaster=ska.base.csp_subelement_master:main",
] ]
}, },
keywords="lmc base classes ska", keywords="lmc base classes ska",
......
...@@ -13,6 +13,7 @@ __all__ = ( ...@@ -13,6 +13,7 @@ __all__ = (
"SKASubarrayStateModel", "SKASubarrayStateModel",
"SKASubarrayResourceManager", "SKASubarrayResourceManager",
"SKATelState", "SKATelState",
"CspSubElementMaster",
) )
# Note: order of imports is important - start with lowest in the hierarchy # Note: order of imports is important - start with lowest in the hierarchy
...@@ -32,3 +33,5 @@ from .subarray_device import ( ...@@ -32,3 +33,5 @@ from .subarray_device import (
SKASubarrayStateModel, SKASubarrayStateModel,
SKASubarrayResourceManager, SKASubarrayResourceManager,
) )
# CspSubElement classes
from .csp_subelement_master import CspSubElementMaster
...@@ -23,6 +23,8 @@ from tango.server import run, attribute, command, device_property ...@@ -23,6 +23,8 @@ from tango.server import run, attribute, command, device_property
from ska.base import SKAMaster from ska.base import SKAMaster
from ska.base.commands import ResultCode, ResponseCommand from ska.base.commands import ResultCode, ResponseCommand
from ska.base.control_model import AdminMode
from ska.base.faults import CommandError
# PROTECTED REGION END # // CspSubElementMaster.additionnal_import # PROTECTED REGION END # // CspSubElementMaster.additionnal_import
__all__ = ["CspSubElementMaster", "main"] __all__ = ["CspSubElementMaster", "main"]
...@@ -412,10 +414,12 @@ class CspSubElementMaster(SKAMaster): ...@@ -412,10 +414,12 @@ class CspSubElementMaster(SKAMaster):
information purpose only. information purpose only.
:rtype: (ResultCode, str) :rtype: (ResultCode, str)
""" """
self.logger.info("type(argin): {}".format(type(argin))) message = "LoadFirmware command completed OK"
list_of_devices = argin[1]. split(',') return (ResultCode.OK, message)
self.logger.info(list_of_devices)
return (ResultCode.OK, "Command suceeded") def check_allowed(self):
return self.state_model.op_state == tango.DevState.OFF and \
self.state_model.admin_mode == AdminMode.MAINTENANCE
class PowerOnDevicesCommand(ResponseCommand): class PowerOnDevicesCommand(ResponseCommand):
""" """
...@@ -430,7 +434,11 @@ class CspSubElementMaster(SKAMaster): ...@@ -430,7 +434,11 @@ class CspSubElementMaster(SKAMaster):
information purpose only. information purpose only.
:rtype: (ResultCode, str) :rtype: (ResultCode, str)
""" """
return (ResultCode.OK, "Command suceeded") message = "PowerOnDevices command completed OK"
return (ResultCode.OK, message)
def check_allowed(self):
return self.state_model.op_state == tango.DevState.ON
class PowerOffDevicesCommand(ResponseCommand): class PowerOffDevicesCommand(ResponseCommand):
""" """
...@@ -445,7 +453,11 @@ class CspSubElementMaster(SKAMaster): ...@@ -445,7 +453,11 @@ class CspSubElementMaster(SKAMaster):
information purpose only. information purpose only.
:rtype: (ResultCode, str) :rtype: (ResultCode, str)
""" """
return (ResultCode.OK, "Command suceeded") message = "PowerOffDevices command completed OK"
return (ResultCode.OK, message)
def check_allowed(self):
return self.state_model.op_state == tango.DevState.ON
class ReInitDevicesCommand(ResponseCommand): class ReInitDevicesCommand(ResponseCommand):
""" """
...@@ -460,7 +472,25 @@ class CspSubElementMaster(SKAMaster): ...@@ -460,7 +472,25 @@ class CspSubElementMaster(SKAMaster):
information purpose only. information purpose only.
:rtype: (ResultCode, str) :rtype: (ResultCode, str)
""" """
return (ResultCode.OK, "Command suceeded") message = "ReInitDevices command completed OK"
return (ResultCode.OK, message)
def check_allowed(self):
return self.state_model.op_state == tango.DevState.ON
def is_LoadFirmware_allowed(self):
"""
Check if the LodFirmware command is allowed in the current
state.
:raises ``CommandError`` if command not allowed
:return ``True`` if command is allowed
:rtype: boolean
"""
command = self.get_command_object("LoadFirmware")
if not command.check_allowed():
raise CommandError(f"{command.name} not allowed in {self.state_model.op_state}/{AdminMode(self.state_model.admin_mode).name}.")
return True
@command( @command(
dtype_in='DevVarStringArray', dtype_in='DevVarStringArray',
...@@ -482,7 +512,8 @@ class CspSubElementMaster(SKAMaster): ...@@ -482,7 +512,8 @@ class CspSubElementMaster(SKAMaster):
- The file name or a pointer to the filename specifed as URL. - The file name or a pointer to the filename specifed as URL.
- the list of components that use software or firmware package (file), - the list of components that use software or firmware package (file),
- checksum or signing - checksum or signing
Ex: ['file://firmware.txt','test/dev/1, test/dev/2, test/dev/3', '918698a7fea3fa9da5996db001d33628'] Ex: ['file://firmware.txt','test/dev/1, test/dev/2, test/dev/3',
'918698a7fea3fa9da5996db001d33628']
:type argin: 'DevVarStringArray' :type argin: 'DevVarStringArray'
:return: A tuple containing a return code and a string :return: A tuple containing a return code and a string
...@@ -495,6 +526,20 @@ class CspSubElementMaster(SKAMaster): ...@@ -495,6 +526,20 @@ class CspSubElementMaster(SKAMaster):
return [[return_code], [message]] return [[return_code], [message]]
# PROTECTED REGION END # // CspSubElementMaster.LoadFirmware # PROTECTED REGION END # // CspSubElementMaster.LoadFirmware
def is_PowerOnDevices_allowed(self):
"""
Check if the LodFirmware command is allowed in the current
state.
:raises ``CommandError`` if command not allowed
:return ``True`` if command is allowed
:rtype: boolean
"""
command = self.get_command_object("PowerOnDevices")
if not command.check_allowed():
raise CommandError(f'{command.name}: not allowed in {self.state_model.op_state}.')
return True
@command( @command(
dtype_in='DevVarStringArray', dtype_in='DevVarStringArray',
doc_in="The list of FQDNs to power-up", doc_in="The list of FQDNs to power-up",
...@@ -520,6 +565,20 @@ class CspSubElementMaster(SKAMaster): ...@@ -520,6 +565,20 @@ class CspSubElementMaster(SKAMaster):
return [[return_code], [message]] return [[return_code], [message]]
# PROTECTED REGION END # // CspSubElementMaster.PowerOnDevices # PROTECTED REGION END # // CspSubElementMaster.PowerOnDevices
def is_PowerOffDevices_allowed(self):
"""
Check if the PowerOffDevices command is allowed in the current
state.
:raises ``CommandError`` if command not allowed
:return ``True`` if command is allowed
:rtype: boolean
"""
command = self.get_command_object("PowerOffDevices")
if not command.check_allowed():
raise CommandError(f'{command.name} not allowed in {self.state_model.op_state}.')
return True
@command( @command(
dtype_in='DevVarStringArray', dtype_in='DevVarStringArray',
doc_in="List of FQDNs to power-off", doc_in="List of FQDNs to power-off",
...@@ -546,6 +605,20 @@ class CspSubElementMaster(SKAMaster): ...@@ -546,6 +605,20 @@ class CspSubElementMaster(SKAMaster):
# PROTECTED REGION END # // CspSubElementMaster.PowerOffDevices # PROTECTED REGION END # // CspSubElementMaster.PowerOffDevices
def is_ReInitDevices_allowed(self):
"""
Check if the ReInitDevices command is allowed in the current
state.
:raises ``CommandError`` if command not allowed
:return ``True`` if command is allowed
:rtype: boolean
"""
command = self.get_command_object("ReInitDevices")
if not command.check_allowed():
raise CommandError(f'{command.name} not allowed in {self.state_model.op_state}.')
return True
@command( @command(
dtype_in='DevVarStringArray', dtype_in='DevVarStringArray',
doc_in="List of devices to re-initialize", doc_in="List of devices to re-initialize",
...@@ -578,7 +651,6 @@ class CspSubElementMaster(SKAMaster): ...@@ -578,7 +651,6 @@ class CspSubElementMaster(SKAMaster):
return [[return_code], [message]] return [[return_code], [message]]
# PROTECTED REGION END # // CspSubElementMaster.ReInitDevices # PROTECTED REGION END # // CspSubElementMaster.ReInitDevices
# ---------- # ----------
# Run server # Run server
# ---------- # ----------
......
...@@ -305,6 +305,10 @@ def tango_context(request): ...@@ -305,6 +305,10 @@ def tango_context(request):
'SkaLevel': '4', 'SkaLevel': '4',
'SubID': '1', 'SubID': '1',
}, },
'CspSubElementMaster': {
'PowerDelayStandbyOn': '1500',
'PowerDelayStandbyOff': '1000',
},
} }
# This fixture is used to decorate classes like "TestSKABaseDevice" or # This fixture is used to decorate classes like "TestSKABaseDevice" or
......
#########################################################################################
# -*- coding: utf-8 -*-
#
# This file is part of the CspSubelementMaster project
#
#
#
#########################################################################################
"""Contain the tests for the CspSubelementMaster."""
# Imports
import re
import pytest
from tango import DevState, DevFailed
from tango.test_context import MultiDeviceTestContext
# PROTECTED REGION ID(CspSubelementMaster.test_additional_imports) ENABLED START #
from ska.base import SKAMaster, CspSubElementMaster
from ska.base.commands import ResultCode
from ska.base.faults import CommandError
from ska.base.control_model import (
AdminMode, ControlMode, HealthState, SimulationMode, TestMode
)
# PROTECTED REGION END # // CspSubElementMaster.test_additional_imports
# Device test case
# PROTECTED REGION ID(CspSubElementMaster.test_CspSubelementMaster_decorators) ENABLED START #
@pytest.mark.usefixtures("tango_context", "initialize_device")
# PROTECTED REGION END # // CspSubelementMaster.test_CspSubelementMaster_decorators
class TestCspSubElementMaster(object):
"""Test case for packet generation."""
properties = {
'SkaLevel': '4',
'LoggingTargetsDefault': '',
'GroupDefinitions': '',
'PowerDelayStandbyOn': 1500,
'PowerDelayStandbyOff': 1000,
}
@classmethod
def mocking(cls):
"""Mock external libraries."""
# Example : Mock numpy
# cls.numpy = CspSubelementMaster.numpy = MagicMock()
# PROTECTED REGION ID(CspSubelementMaster.test_mocking) ENABLED START #
# PROTECTED REGION END # // CspSubelementMaster.test_mocking
def test_properties(self, tango_context):
# Test the properties
# PROTECTED REGION ID(CspSubelementMaster.test_properties) ENABLED START #
# PROTECTED REGION END # // CspSubelementMaster.test_properties
pass
# PROTECTED REGION ID(CspSubelementMaster.test_State_decorators) ENABLED START #
# PROTECTED REGION END # // CspSubelementMaster.test_State_decorators
def test_State(self, tango_context):
"""Test for State"""
# PROTECTED REGION ID(CspSubelementMaster.test_State) ENABLED START #
assert tango_context.device.State() == DevState.OFF
# PROTECTED REGION END # // CspSubelementMaster.test_State
# PROTECTED REGION ID(CspSubelementMaster.test_Status_decorators) ENABLED START #
# PROTECTED REGION END # // CspSubelementMaster.test_Status_decorators
def test_Status(self, tango_context):
"""Test for Status"""
# PROTECTED REGION ID(CspSubelementMaster.test_Status) ENABLED START #
assert tango_context.device.Status() == "The device is in OFF state."
# PROTECTED REGION END # // CspSubelementMaster.test_Status
# PROTECTED REGION ID(CspSubelementMaster.test_GetVersionInfo_decorators) ENABLED START #
# PROTECTED REGION END # // CspSubelementMaster.test_GetVersionInfo_decorators
def test_GetVersionInfo(self, tango_context):
"""Test for GetVersionInfo"""
# PROTECTED REGION ID(CspSubelementMaster.test_GetVersionInfo) ENABLED START #
versionPattern = re.compile(
r'CspSubElementMaster, lmcbaseclasses, [0-9].[0-9].[0-9], '
r'A set of generic base devices for SKA Telescope.')
versionInfo = tango_context.device.GetVersionInfo()
assert (re.match(versionPattern, versionInfo[0])) is not None
# PROTECTED REGION END # // CspSubelementMaster.test_GetVersionInfo
# PROTECTED REGION ID(CspSubelementMaster.test_configurationProgress_decorators) ENABLED START #
def test_buildState(self, tango_context):
"""Test for buildState"""
# PROTECTED REGION ID(CspSubelementMaster.test_buildState) ENABLED START #
buildPattern = re.compile(
r'lmcbaseclasses, [0-9].[0-9].[0-9], '
r'A set of generic base devices for SKA Telescope')
assert (re.match(buildPattern, tango_context.device.buildState)) is not None
# PROTECTED REGION END # // CspSubelementMaster.test_buildState
# PROTECTED REGION ID(CspSubelementMaster.test_versionId_decorators) ENABLED START #
# PROTECTED REGION END # // CspSubelementMaster.test_versionId_decorators
def test_versionId(self, tango_context):
"""Test for versionId"""
# PROTECTED REGION ID(CspSubelementMaster.test_versionId) ENABLED START #
versionIdPattern = re.compile(r'[0-9].[0-9].[0-9]')
assert (re.match(versionIdPattern, tango_context.device.versionId)) is not None
# PROTECTED REGION END # // CspSubelementMaster.test_versionId
# PROTECTED REGION ID(CspSubelementMaster.test_healthState_decorators) ENABLED START #
# PROTECTED REGION END # // CspSubelementMaster.test_healthState_decorators
def test_healthState(self, tango_context):
"""Test for healthState"""
# PROTECTED REGION ID(CspSubelementMaster.test_healthState) ENABLED START #
assert tango_context.device.healthState == HealthState.OK
# PROTECTED REGION END # // CspSubelementMaster.test_healthState
# PROTECTED REGION ID(CspSubelementMaster.test_adminMode_decorators) ENABLED START #
# PROTECTED REGION END # // CspSubelementMaster.test_adminMode_decorators
def test_adminMode(self, tango_context):
"""Test for adminMode"""
# PROTECTED REGION ID(CspSubelementMaster.test_adminMode) ENABLED START #
assert tango_context.device.adminMode == AdminMode.MAINTENANCE
# PROTECTED REGION END # // CspSubelementMaster.test_adminMode
# PROTECTED REGION ID(CspSubelementMaster.test_controlMode_decorators) ENABLED START #
# PROTECTED REGION END # // CspSubelementMaster.test_controlMode_decorators
def test_controlMode(self, tango_context):
"""Test for controlMode"""
# PROTECTED REGION ID(CspSubelementMaster.test_controlMode) ENABLED START #
assert tango_context.device.controlMode == ControlMode.REMOTE
# PROTECTED REGION END # // CspSubelementMaster.test_controlMode
# PROTECTED REGION ID(CspSubelementMaster.test_simulationMode_decorators) ENABLED START #
# PROTECTED REGION END # // CspSubelementMaster.test_simulationMode_decorators
def test_simulationMode(self, tango_context):
"""Test for simulationMode"""
# PROTECTED REGION ID(CspSubelementMaster.test_simulationMode) ENABLED START #
assert tango_context.device.simulationMode == SimulationMode.FALSE
# PROTECTED REGION END # // CspSubelementMaster.test_simulationMode
# PROTECTED REGION ID(CspSubelementMaster.test_testMode_decorators) ENABLED START #
# PROTECTED REGION END # // CspSubelementMaster.test_testMode_decorators
def test_testMode(self, tango_context):
"""Test for testMode"""
# PROTECTED REGION ID(CspSubelementMaster.test_testMode) ENABLED START #
assert tango_context.device.testMode == TestMode.NONE
# PROTECTED REGION END # // CspSubelementMaster.test_testMode
# PROTECTED REGION ID(CspSubelementMaster.test_powerDelayStandbyOn_decorators) ENABLED START #
# PROTECTED REGION END # // CspSubelementMaster.test_powerDelayStandbyOn_decorators
def test_powerDelayStandbyOn(self, tango_context):
"""Test for powerDelayStandbyOn"""
# PROTECTED REGION ID(CspSubelementMaster.test_testMode) ENABLED START #
assert tango_context.device.powerDelayStandbyOn == self.properties['PowerDelayStandbyOn']
# PROTECTED REGION END # // CspSubelementMaster.test_powerDelayStandbyOn
# PROTECTED REGION ID(CspSubelementMaster.test_powerDelayStandbyOff_decorators) ENABLED START #
# PROTECTED REGION END # // CspSubelementMaster.test_powerDelayStandbyOff_decorators
def test_powerDelayStandbyOff(self, tango_context):
"""Test for powerDelayStandbyOff"""
# PROTECTED REGION ID(CspSubelementMaster.test_testMode) ENABLED START #
assert tango_context.device.powerDelayStandbyOff == self.properties['PowerDelayStandbyOff']
# PROTECTED REGION END # // CspSubelementMaster.test_powerDelayStandbyOff
# PROTECTED REGION ID(CspSubelementMaster.test_onProgress_decorators) ENABLED START #
# PROTECTED REGION END # // CspSubelementMaster.test_onProgress_decorators
def test_onProgress(self, tango_context):
"""Test for onProgress"""
# PROTECTED REGION ID(CspSubelementMaster.test_onProgress) ENABLED START #
assert tango_context.device.onProgress == 0
# PROTECTED REGION END # // CspSubelementMaster.test_onProgress
# PROTECTED REGION ID(CspSubelementMaster.test_onMaximumDuration_decorators) ENABLED START #
# PROTECTED REGION END # // CspSubelementMaster.test_onMaximumDuration_decorators
def test_onMaximumDuration(self, tango_context):
"""Test for onMaximumDuration"""
# PROTECTED REGION ID(CspSubelementMaster.test_onMaximumDuration) ENABLED START #
tango_context.device.onMaximumDuration = 5
assert tango_context.device.onMaximumDuration == 5
# PROTECTED REGION END # // CspSubelementMaster.test_onMaximumDuration
# PROTECTED REGION ID(CspSubelementMaster.test_onMeasuredDuration_decorators) ENABLED START #
# PROTECTED REGION END # // CspSubelementMaster.test_onMeasuredDuration_decorators
def test_onMeasuredDuration(self, tango_context):
"""Test for onMeasuredDuration"""
# PROTECTED REGION ID(CspSubelementMaster.test_onMeasuredDuration) ENABLED START #
assert tango_context.device.onMeasuredDuration == 0
# PROTECTED REGION END # // CspSubelementMaster.test_onMeasuredDuration
# PROTECTED REGION ID(CspSubelementMaster.test_standbyProgress_decorators) ENABLED START #
# PROTECTED REGION END # // CspSubelementMaster.test_standbyProgress_decorators
def test_standbyProgress(self, tango_context):
"""Test for standbyProgress"""
# PROTECTED REGION ID(CspSubelementMaster.test_standbyProgress) ENABLED START #
assert tango_context.device.standbyProgress == 0
# PROTECTED REGION END # // CspSubelementMaster.test_standbyProgress
# PROTECTED REGION ID(CspSubelementMaster.test_standbyMaximumDuration_decorators) ENABLED START #
# PROTECTED REGION END # // CspSubelementMaster.test_standbyMaximumDuration_decorators
def test_standbyMaximumDuration(self, tango_context):
"""Test for standbyMaximumDuration"""
# PROTECTED REGION ID(CspSubelementMaster.test_standbyMaximumDuration) ENABLED START #
tango_context.device.standbyMaximumDuration = 5
assert tango_context.device.standbyMaximumDuration == 5
# PROTECTED REGION END # // CspSubelementMaster.test_standbyMaximumDuration
# PROTECTED REGION ID(CspSubelementMaster.test_standbyMeasuredDuration_decorators) ENABLED START #
# PROTECTED REGION END # // CspSubelementMaster.test_standbyMeasuredDuration_decorators
def test_standbyMeasuredDuration(self, tango_context):
"""Test for standbyMeasuredDuration"""
# PROTECTED REGION ID(CspSubelementMaster.test_standbyMeasuredDuration) ENABLED START #
assert tango_context.device.standbyMeasuredDuration == 0
# PROTECTED REGION END # // CspSubelementMaster.test_standbyMeasuredDuration
# PROTECTED REGION ID(CspSubelementMaster.test_offProgress_decorators) ENABLED START #
# PROTECTED REGION END # // CspSubelementMaster.test_offProgress_decorators
def test_offProgress(self, tango_context):
"""Test for offProgress"""
# PROTECTED REGION ID(CspSubelementMaster.test_offProgress) ENABLED START #
assert tango_context.device.offProgress == 0
# PROTECTED REGION END # // CspSubelementMaster.test_offProgress
# PROTECTED REGION ID(CspSubelementMaster.test_offMaximumDuration_decorators) ENABLED START #
# PROTECTED REGION END # // CspSubelementMaster.test_offMaximumDuration_decorators
def test_offMaximumDuration(self, tango_context):
"""Test for offMaximumDuration"""
# PROTECTED REGION ID(CspSubelementMaster.test_offMaximumDuration) ENABLED START #
tango_context.device.offMaximumDuration = 5
assert tango_context.device.offMaximumDuration == 5
# PROTECTED REGION END # // CspSubelementMaster.test_offMaximumDuration
# PROTECTED REGION ID(CspSubelementMaster.test_offMeasuredDuration_decorators) ENABLED START #
# PROTECTED REGION END # // CspSubelementMaster.test_offMeasuredDuration_decorators
def test_offMeasuredDuration(self, tango_context):
"""Test for offMeasuredDuration"""
# PROTECTED REGION ID(CspSubelementMaster.test_offMeasuredDuration) ENABLED START #
assert tango_context.device.offMeasuredDuration == 0
# PROTECTED REGION END # // CspSubelementMaster.test_offMeasuredDuration
# PROTECTED REGION ID(CspSubelementMaster.test_loadFirmwareProgress_decorators) ENABLED START #
# PROTECTED REGION END # // CspSubelementMaster.test_loadFirmwareProgress_decorators
def test_loadFirmwareProgress(self, tango_context):
"""Test for loadFirmwareProgress"""
# PROTECTED REGION ID(CspSubelementMaster.test_loadFirmwareProgress) ENABLED START #
assert tango_context.device.loadFirmwareProgress == 0
# PROTECTED REGION END # // CspSubelementMaster.test_loadFirmwareProgress
# PROTECTED REGION ID(CspSubelementMaster.test_loadFirmwareMaximumDuration_decorators) ENABLED START #
# PROTECTED REGION END # // CspSubelementMaster.test_loadFirmwareMaximumDuration_decorators
def test_loadFirmwareMaximumDuration(self, tango_context):
"""Test for loadFirmwareMaximumDuration"""
# PROTECTED REGION ID(CspSubelementMaster.test_loadFirmwareMaximumDuration) ENABLED START #
tango_context.device.loadFirmwareMaximumDuration = 5
assert tango_context.device.loadFirmwareMaximumDuration == 5
# PROTECTED REGION END # // CspSubelementMaster.test_loadFirmwareMaximumDuration
# PROTECTED REGION ID(CspSubelementMaster.test_loadFirmwareMeasuredDuration_decorators) ENABLED START #
# PROTECTED REGION END # // CspSubelementMaster.test_loadFirmwareMeasuredDuration_decorators
def test_loadFirmwareMeasuredDuration(self, tango_context):
"""Test for loadFirmwareMeasuredDuration"""
# PROTECTED REGION ID(CspSubelementMaster.test_loadFirmwareMeasuredDuration) ENABLED START #
assert tango_context.device.loadFirmwareMeasuredDuration == 0
# PROTECTED REGION END # // CspSubelementMaster.test_loadFirmwareMeasuredDuration
# PROTECTED REGION ID(CspSubelementMaster.test_LoadFirmware_decorators) ENABLED START #
# PROTECTED REGION END # // CspSubelementMaster.test_LoadFirmware_decorators
def test_LoadFirmware(self, tango_context):
"""Test for LoadFirmware"""
# PROTECTED REGION ID(CspSubelementMaster.test_LoadFirmware) ENABLED START #
assert tango_context.device.state() == DevState.OFF
assert tango_context.device.adminMode == AdminMode.MAINTENANCE
assert tango_context.device.LoadFirmware(['file', 'test/dev/b','918698a7fea3']) == [
[ResultCode.OK], ["LoadFirmware command completed OK"]
]
# PROTECTED REGION END # // CspSubelementMaster.test_LoadFirmware
# PROTECTED REGION ID(CspSubelementMaster.test_LoadFirmware_WHEN_in_wrong_state_decorators) ENABLED START #
# PROTECTED REGION END # // CspSubelementMaster.test_LoadFirmware_wrong_state_decorators
def test_LoadFirmware_WHEN_in_wrong_state(self, tango_context):
"""Test for LoadFirmware when the device is in wrong state"""
# PROTECTED REGION ID(CspSubelementMaster.test_LoadFirmware_WHEN_in_wrong_state) ENABLED START #
assert tango_context.device.state() == DevState.OFF
# Set the device in ON/ONLINE state
tango_context.device.Disable()
assert tango_context.device.state() == DevState.DISABLE
tango_context.device.adminMode = AdminMode.ONLINE
assert tango_context.device.adminMode == AdminMode.ONLINE
tango_context.device.Off()
assert tango_context.device.state() == DevState.OFF
tango_context.device.On()
assert tango_context.device.state() == DevState.ON
with pytest.raises(DevFailed) as df:
tango_context.device.LoadFirmware(['file', 'test/dev/b','918698a7fea3'])
assert "LoadFirmwareCommand not allowed" in str(df.value.args[0].desc)
# PROTECTED REGION END # // CspSubelementMaster.test_LoadFirmware_WHEN_in_wrong_state
# PROTECTED REGION ID(CspSubelementMaster.test_PowerOnDevices_decorators) ENABLED START #
# PROTECTED REGION END # // CspSubelementMaster.test_PowerOnDevices_decorators
def test_PowerOnDevices(self, tango_context):
"""Test for PowerOnDevices"""
# PROTECTED REGION ID(CspSubelementMaster.test_PowerOnDevices) ENABLED START #
assert tango_context.device.state() == DevState.OFF
# put it in ON state
tango_context.device.On()
assert tango_context.device.state() == DevState.ON
assert tango_context.device.PowerOnDevices(['test/dev/1', 'test/dev/2']) == [
[ResultCode.OK], ["PowerOnDevices command completed OK"]
]
# PROTECTED REGION END # // CspSubelementMaster.test_PowerOnDevices
# PROTECTED REGION ID(CspSubelementMaster.test_PowerOffDevices_decorators) ENABLED START #
# PROTECTED REGION END # // CspSubelementMaster.test_PowerOffDevices_decorators
def test_PowerOffDevices(self, tango_context):
"""Test for PowerOffDEvices"""
# PROTECTED REGION ID(CspSubelementMaster.test_PowerOffDevices) ENABLED START #
assert tango_context.device.state() == DevState.OFF
# put it in ON state
tango_context.device.On()
assert tango_context.device.state() == DevState.ON
assert tango_context.device.PowerOffDevices(['test/dev/1', 'test/dev/2']) == [
[ResultCode.OK], ["PowerOffDevices command completed OK"]
]
# PROTECTED REGION END # // CspSubelementMaster.test_PowerOffDevices
# PROTECTED REGION ID(CspSubelementMaster.test_ReInitDevices_decorators) ENABLED START #
# PROTECTED REGION END # // CspSubelementMaster.test_ReInitDevices_decorators
def test_ReInitDevices(self, tango_context):
"""Test for ReInitDevices"""
# PROTECTED REGION ID(CspSubelementMaster.test_ReInitDevices) ENABLED START #
assert tango_context.device.state() == DevState.OFF
# put it in ON state
tango_context.device.On()
assert tango_context.device.state() == DevState.ON
assert tango_context.device.ReInitDevices(['test/dev/1', 'test/dev/2']) == [
[ResultCode.OK], ["ReInitDevices command completed OK"]
]
# PROTECTED REGION END # // CspSubelementMaster.test_ReInitDevices
def test_multiple_devices_in_same_process():
# The order here is important - base class last, so that we can
# test that the subclass isn't breaking anything.
devices_info = (
{"class": CspSubElementMaster, "devices": [{"name": "test/se/1"}]},
{"class": SKAMaster, "devices": [{"name": "test/master/1"}]},
)
with MultiDeviceTestContext(devices_info, process=False) as context:
proxy1 = context.get_device("test/se/1")
proxy2 = context.get_device("test/master/1")
assert proxy1.State() == DevState.OFF
assert proxy2.State() == DevState.OFF
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment