Skip to content
Snippets Groups Projects
Commit c6484ead authored by Aditya Dange's avatar Aditya Dange
Browse files

Unit test cases for SKA Base class updated as per review comments in pull...

Unit test cases for SKA Base class updated as per review comments in pull request 81. ToJson and GetMatrics functions commented for now. Will be removed later.
parent b43cf92f
No related branches found
No related tags found
No related merge requests found
......@@ -22,7 +22,7 @@ from PyTango import AttrWriteType, PipeWriteType
# Additional import
# PROTECTED REGION ID(SKABaseDevice.additionnal_import) ENABLED START #
import logging
import json
from PyTango import DeviceProxy, DevFailed
from skabase.utils import (get_dp_command, exception_manager,
......@@ -416,17 +416,17 @@ class SKABaseDevice(Device):
dtype_out='str',
)
@DebugIt()
def GetMetrics(self):
# PROTECTED REGION ID(SKABaseDevice.GetMetrics) ENABLED START #
### TBD - read the value of each of the attributes in the MetricList
with exception_manager(self):
args_dict = {'with_value': True, 'with_commands': False,
'with_metrics': True, 'with_attributes': False}
device_dict = self._get_device_json(args_dict)
argout = json.dumps(device_dict)
return argout
# PROTECTED REGION END # // SKABaseDevice.GetMetrics
# def GetMetrics(self):
# # PROTECTED REGION ID(SKABaseDevice.GetMetrics) ENABLED START #
# ### TBD - read the value of each of the attributes in the MetricList
# with exception_manager(self):
# args_dict = {'with_value': True, 'with_commands': False,
# 'with_metrics': True, 'with_attributes': False}
# device_dict = self._get_device_json(args_dict)
# argout = json.dumps(device_dict)
# return argout
# # PROTECTED REGION END # // SKABaseDevice.GetMetrics
@command(
dtype_in='str',
......@@ -435,18 +435,18 @@ class SKABaseDevice(Device):
doc_out="The JSON string representing this device, \nfiltered as per the input argument flags",
)
@DebugIt()
def ToJson(self, argin):
# PROTECTED REGION ID(SKABaseDevice.ToJson) ENABLED START #
# def ToJson(self, argin):
# # PROTECTED REGION ID(SKABaseDevice.ToJson) ENABLED START #
# TBD - see how to use fandango's export_device_to_dict
with exception_manager(self):
defaults = {'with_value': False, 'with_commands': True,
'with_metrics': True, 'with_attributes': False}
args_dict = self._parse_argin(argin, defaults=defaults)
device_dict = self._get_device_json(args_dict)
argout = json.dumps(device_dict)
return argout
# PROTECTED REGION END # // SKABaseDevice.ToJson
# with exception_manager(self):
# defaults = {'with_value': False, 'with_commands': True,
# 'with_metrics': True, 'with_attributes': False}
# args_dict = self._parse_argin(argin, defaults=defaults)
# device_dict = self._get_device_json(args_dict)
# argout = json.dumps(device_dict)
# return argout
# # PROTECTED REGION END # // SKABaseDevice.ToJson
@command(
dtype_out=('str',),
......
......@@ -19,6 +19,7 @@ import pytest
from mock import MagicMock
from PyTango import DevState
import re
# PROTECTED REGION ID(SKABaseDevice.test_additional_imports) ENABLED START #
# PROTECTED REGION END # // SKABaseDevice.test_additional_imports
......@@ -72,26 +73,29 @@ class TestSKABaseDevice(object):
# 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 #
assert tango_context.device.GetMetrics() == ""
# PROTECTED REGION END # // SKABaseDevice.test_GetMetrics
# def test_GetMetrics(self, tango_context):
# """Test for GetMetrics"""
# # PROTECTED REGION ID(SKABaseDevice.test_GetMetrics) ENABLED START #
# 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 #
assert tango_context.device.ToJson("") == ""
# PROTECTED REGION END # // SKABaseDevice.test_ToJson
# def test_ToJson(self, tango_context):
# """Test for ToJson"""
# # PROTECTED REGION ID(SKABaseDevice.test_ToJson) ENABLED START #
# 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 #
assert tango_context.device.GetVersionInfo() == [""]
versionPattern = re.compile(
r'SKABaseDevice, tangods-skabasedevice, [0-9].[0-9].[0-9], A generic base device for SKA')
versionInfo = tango_context.device.GetVersionInfo()
assert(re.match(versionPattern, versionInfo[0])) != None
# PROTECTED REGION END # // SKABaseDevice.test_GetVersionInfo
# PROTECTED REGION ID(SKABaseDevice.test_Reset_decorators) ENABLED START #
......@@ -108,7 +112,9 @@ class TestSKABaseDevice(object):
def test_buildState(self, tango_context):
"""Test for buildState"""
# PROTECTED REGION ID(SKABaseDevice.test_buildState) ENABLED START #
assert tango_context.device.buildState == ''
buildPattern = re.compile(
r'tangods-skabasedevice, [0-9].[0-9].[0-9], A generic base device for SKA')
assert (re.match(buildPattern, tango_context.device.buildState)) != None
# PROTECTED REGION END # // SKABaseDevice.test_buildState
# PROTECTED REGION ID(SKABaseDevice.test_versionId_decorators) ENABLED START #
......@@ -116,7 +122,8 @@ class TestSKABaseDevice(object):
def test_versionId(self, tango_context):
"""Test for versionId"""
# PROTECTED REGION ID(SKABaseDevice.test_versionId) ENABLED START #
assert tango_context.device.versionId == ''
versionIdPattern = re.compile(r'[0-9].[0-9].[0-9]')
assert (re.match(versionIdPattern, tango_context.device.versionId)) != None
# PROTECTED REGION END # // SKABaseDevice.test_versionId
# PROTECTED REGION ID(SKABaseDevice.test_centralLoggingLevel_decorators) ENABLED START #
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment