summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPicca Frédéric-Emmanuel <picca@debian.org>2013-05-20 22:04:46 +0200
committerPicca Frédéric-Emmanuel <picca@debian.org>2013-05-20 22:04:46 +0200
commitb96f04ea7d01c3c7195b55f3a8c5a3d992e6f6fd (patch)
treed2659e69d4c76d9ae0ceef2a8b98f0b4f65b4cb5 /tests
parenteff074ad76667283496d4a8c3b110fa72736d44c (diff)
Imported Upstream version 8.0.3
Diffstat (limited to 'tests')
-rw-r--r--tests/DevTest.py133
-rw-r--r--tests/README20
-rw-r--r--tests/TangoRunner.py27
-rw-r--r--tests/TestSuite.py296
-rw-r--r--tests/TestSuiteTemplate.py47
-rwxr-xr-xtests/ci/ALBA/build.sh100
-rwxr-xr-xtests/ci/build.sh20
7 files changed, 547 insertions, 96 deletions
diff --git a/tests/DevTest.py b/tests/DevTest.py
index 0dfedad..057afd3 100644
--- a/tests/DevTest.py
+++ b/tests/DevTest.py
@@ -88,7 +88,7 @@ class DevTest(PyTango.Device_4Impl):
self.slow_actua = 0
self.slow_actua_write = 0
- self.enc_attr_data = bytearray([97,98,99,100])
+ self.enc_attr_data = bytes(bytearray([97,98,99,100]))
self.enc_attr = ['Which format?', self.enc_attr_data] #''.join(chr(i) for i in self.enc_attr_data).encode('utf-8')]
self.enc_format_toggle = False
self.encoded_cmd_ctr = 0
@@ -2189,47 +2189,41 @@ class DevTest(PyTango.Device_4Impl):
def write_Short_attr_w(self,the_att):
- data = []
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
#------------------------------------------------------------------
def write_Long_attr_w(self,the_att):
print "In write_Long_attr_w for attribute",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
print "Attribute value = ",data
#------------------------------------------------------------------
def write_Float_attr_w(self,the_att):
print "In write_Float_attr_w for attribute",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
print "Attribute value = ",data
#------------------------------------------------------------------
def write_UShort_attr_w(self,the_att):
print "In write_UShort_attr_w for attribute ",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
print "Attribute value = ",data;
#------------------------------------------------------------------
def write_UChar_attr_w(self,the_att):
print "In write_UChar_attr_w for attribute ",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
print "Attribute value = ",data
#------------------------------------------------------------------
def write_Short_attr_rw(self,the_att):
print "In write_Short_attr_rw for attribute ",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
self.attr_short_rw = data[0]
#------------------------------------------------------------------
@@ -2241,16 +2235,14 @@ class DevTest(PyTango.Device_4Impl):
def write_Long_attr_with_w2(self,the_att):
print "In write_Long_attr_with_w for attribute ",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
self.attr_long_rw2 = data[0]
#------------------------------------------------------------------
def write_Short_attr_w2(self,the_att):
print "In write_Short_attr_w2 for attribute ",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
print "Attribute value = ",data
#------------------------------------------------------------------
@@ -2258,111 +2250,98 @@ class DevTest(PyTango.Device_4Impl):
def write_Double_attr_w(self,the_att):
print "In write_Double_attr_w for attribute ",the_att.get_name()
data=[];
- the_att.get_write_value(data)
+ the_att.get_write_value()
print "Attribute value = ",data
#------------------------------------------------------------------
def write_String_attr_w2(self,the_att):
print "In write_String_attr_w2 for attribute ",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
print "Attribute value = ",data
#------------------------------------------------------------------
def write_String_attr_w(self,the_att):
print "In write_String_attr_w for attribute ",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
print "Attribute value = ",data
#------------------------------------------------------------------
def write_Boolean_attr_w(self,the_att):
print "In write_Boolean_attr_w for attribute ",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
print "Attribute value = ",data
#------------------------------------------------------------------
def write_Short_spec_attr_w(self,the_att):
print "In write_Short_spec_attr_w for attribute ",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
print "Attribute value = ",data
#------------------------------------------------------------------
def write_Short_ima_attr_w(self,the_att):
print "In write_Short_ima_attr_w for attribute ",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
print "Attribute value = ",data
#------------------------------------------------------------------
def write_Long_spec_attr_w(self,the_att):
print "In write_Long_spec_attr_w for attribute ",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
print "Attribute value = ",data
#------------------------------------------------------------------
def write_Double_spec_attr_w(self,the_att):
print "In write_Double_spec_attr_w for attribute ",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
print "Attribute value = ",data
#------------------------------------------------------------------
def write_String_spec_attr_w(self,the_att):
print "In write_String_spec_attr_w for attribute ",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
print "Attribute value = ",data
#------------------------------------------------------------------
def write_Float_spec_attr_w(self,the_att):
print "In write_Float_spec_attr_w for attribute ",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
print "Attribute value = ",data
#------------------------------------------------------------------
def write_Boolean_spec_attr_w(self,the_att):
print "In write_Boolean_spec_attr_w for attribute ",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
print "Attribute value = ",data
#------------------------------------------------------------------
def write_UShort_spec_attr_w(self,the_att):
print "In write_UShort_spec_attr_w for attribute ",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
print "Attribute value = ",data
#------------------------------------------------------------------
def write_UChar_spec_attr_w(self,the_att):
print "In write_UChar_spec_attr_w for attribute ",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
print "Attribute value = ",data
#------------------------------------------------------------------
def write_String_ima_attr_w(self,the_att):
print "In write_String_ima_attr_w for attribute ",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
print "Attribute value = ",data
#------------------------------------------------------------------
@@ -2372,88 +2351,77 @@ class DevTest(PyTango.Device_4Impl):
def write_Float_ima_attr_w(self,the_att):
print "In write_Float_ima_attr_w for attribute ",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
print "Attribute value = ",data
#------------------------------------------------------------------
def write_UShort_ima_attr_w(self,the_att):
print "In write_UShort_ima_attr_w for attribute ",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
print "Attribute value = ",data
#------------------------------------------------------------------
def write_Short_spec_attr_rw(self,the_att):
print "In write_Short_spec_attr_rw for attribute ",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
print "Attribute value = ",data
#------------------------------------------------------------------
def write_String_spec_attr_rw(self,the_att):
print "In write_String_spec_attr_rw for attribute ",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
print "Attribute value = ",data
#------------------------------------------------------------------
def write_Float_spec_attr_rw(self,the_att):
print "In write_Float_spec_attr_rw for attribute ",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
print "Attribute value = ",data
#------------------------------------------------------------------
def write_UChar_spec_attr_rw(self,the_att):
print "In write_UChar_spec_attr_rw for attribute ",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
print "Attribute value = ",data
#------------------------------------------------------------------
def write_Short_ima_attr_rw(self,the_att):
print "In write_Short_ima_attr_rw for attribute ",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
print "Attribute value = ",data
#------------------------------------------------------------------
def write_String_ima_attr_rw(self,the_att):
print "In write_String_ima_attr_rw for attribute ",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
print "Attribute value = ",data
#------------------------------------------------------------------
def write_Boolean_ima_attr_rw(self,the_att):
print "In write_Boolean_ima_attr_rw for attribute ",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
print "Attribute value = ",data
#------------------------------------------------------------------
def write_UShort_ima_attr_rw(self,the_att):
print "In write_UShort_ima_attr_rw for attribute ",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
print "Attribute value = ",data
#------------------------------------------------------------------
def write_attr_asyn_write(self,the_att):
print "In write_attr_asyn_write for attribute ",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
print "Attribute value = ",data
time.sleep(2)
@@ -2461,8 +2429,7 @@ class DevTest(PyTango.Device_4Impl):
def write_attr_asyn_write_to(self,the_att):
print "In write_attr_asyn_write_to for attribute ",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
print "Attribute value = ",data
time.sleep(4)
@@ -2470,8 +2437,7 @@ class DevTest(PyTango.Device_4Impl):
def write_attr_asyn_write_except(self,the_att):
print "In write_attr_asyn_write_except for attribute ",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
print "Attribute value = ",data
time.sleep(2)
PyTango.Except.throw_exception("aaa","This is a test ","DevTest::write_attr_hardware")
@@ -2480,8 +2446,7 @@ class DevTest(PyTango.Device_4Impl):
def write_slow_actuator(self,the_att):
print "In write_slow_actuator for attribute ",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
self.slow_actua = data[0]
self.slow_actua_write = time.time()
the_att.set_value(self.slow_actua)
@@ -2491,8 +2456,7 @@ class DevTest(PyTango.Device_4Impl):
def write_fast_actuator(self,the_att):
print "In write_fast_actuator for attribute ",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
self.fast_actua = data[0]
the_att.set_value(self.fast_actua)
the_att.set_quality(PyTango.AttrQuality.ATTR_CHANGING)
@@ -2502,54 +2466,47 @@ class DevTest(PyTango.Device_4Impl):
def write_Long64_attr_w(self,the_att):
print "In write_Long64_attr_w for attribute ",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
print "Attribute value = ",data
#------------------------------------------------------------------
def write_Long64_spec_attr_w(self,the_att):
print "In write_Long64_spec_attr_w for attribute ",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
print "Attribute value = ",data
#------------------------------------------------------------------
def write_Long64_ima_attr_w(self,the_att):
print "In write_Long64_ima_attr_w for attribute ",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
print "Attribute value = ",data
#------------------------------------------------------------------
def write_Long64_attr_rw(self,the_att):
print "In write_Long64_attr_rw for attribute ",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
print "Attribute value = ",data
#------------------------------------------------------------------
def write_Long64_spec_attr_rw(self,the_att):
print "In write_Long64_spec_attr_rw for attribute ",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
print "Attribute value = ",data
#------------------------------------------------------------------
def write_Long64_ima_attr_rw(self,the_att):
print "In write_Long64_ima_attr_rw for attribute ",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
print "Attribute value = ",data
def write_Long_spec_attr_rw(self,the_att):
print "In write_Long_spec_attr_rw for attribute ",the_att.get_name()
- data=[]
- the_att.get_write_value(data)
+ data = the_att.get_write_value()
self.Long_spec_attr_rw = data
print "Attribute value = ",data
diff --git a/tests/README b/tests/README
new file mode 100644
index 0000000..c6526b9
--- /dev/null
+++ b/tests/README
@@ -0,0 +1,20 @@
+Brief introduction to PyTango Test Suite
+----------------------------------------
+
+The test sutite consists of:
+- DevTest.py - the testing device
+- TangoRunner.py - the file to be imported in order to get a proper Tango-tailored formatting of the tests output
+- TestSuite.py - the actual test suite.
+
+Please acquaint yourself with the exemplary Test Case in the TestSuite.py file to understand how to create Test Cases, define command line parameters (to provide test cases with user input) set restore points, etc.
+
+To execute the test suite:
+1. Define a test device in the database.
+2. Run the device (DevTest.py)
+3. Execute the test suite (TestSuite.py) providing required parameters in the command line (e.g. the device name).
+
+The PyTango test suite framework is supposed to mimic the functionality of the C++ test suite. Therefore its features and behaviour is similar to the C++ one.
+For more explanation on the Test Suite Framework and its use, please read through the README file in the C++ test suite repository:
+
+http://tango-cs.svn.sourceforge.net/viewvc/tango-cs/api/cpp/cpp_test_suite/trunk/
+
diff --git a/tests/TangoRunner.py b/tests/TangoRunner.py
index e140ead..63cb9e2 100644
--- a/tests/TangoRunner.py
+++ b/tests/TangoRunner.py
@@ -9,6 +9,7 @@ from unittest.signals import registerResult
from unittest import TestCase, TestSuite, suite, util
from copy import deepcopy
+
__unittest = True
# loop parameters
@@ -22,15 +23,23 @@ def _printDict(obj):
print("\t" + str(key) + " : " + str(value))
def _hasFailed(result):
- '''Checks if any failure occured'''
+ '''Checks if any failure occurred'''
if result.__class__.__name__ == 'TangoTestResult' and (len(result.errors) != 0 or len(result.failures) != 0):
return True
return False
+def formatName(name):
+ newName = ''
+ for letter in name:
+ if letter.isupper():
+ newName += ' '
+ newName += letter
+ return newName
+
class TangoTestSuite(TestSuite):
'''Tango-tailored Test Suite class'''
- def __init__(self):
- super(TangoTestSuite, self).__init__()
+ def __init__(self, tests=()):
+ super(TangoTestSuite, self).__init__(tests)
def __call__(self, *args, **kwds):
if len(args) > 0:
@@ -47,7 +56,7 @@ class TangoTestSuite(TestSuite):
if suiteClass != None.__class__ and all(isinstance(test, TangoTestCase) and test.__class__ == suiteClass for test in self):
# print test suite name (only once), truncate the '__loop' suffix and show number of iterations
if self.loop == _loopSuite:
- suiteName = className
+ suiteName = formatName(className)
if suiteName.endswith(_loopSuffix):
suiteName = suiteName[:-len(_loopSuffix)]
if _loopSuite > 1:
@@ -71,8 +80,8 @@ class TangoTestSuite(TestSuite):
class TangoTestCase(TestCase):
'''Tango-tailored Test Case class'''
- def __init__(self):
- super(TangoTestCase, self).__init__()
+ def __init__(self, methodName='runTest'):
+ super(TangoTestCase, self).__init__(methodName)
def __call__(self, *args, **kwds):
if len(args) > 0:
@@ -83,7 +92,7 @@ class TangoTestCase(TestCase):
result.loop = 0
# print test case name (only once), truncate the '__loop' suffix and show number of iterations
if self.loop == _loop and result.loopSuiteDone:
- caseName = self._testMethodName
+ caseName = formatName(self._testMethodName)
if caseName.startswith('test_'):
caseName = caseName[len('test_'):]
if caseName.endswith(_loopSuffix):
@@ -108,7 +117,6 @@ class TangoTestCase(TestCase):
result.stream.writeln(" --> OK")
return returnResult
-
class _WritelnDecorator(object):
"""Used to decorate file-like objects with a handy 'writeln' method"""
def __init__(self,stream):
@@ -140,6 +148,8 @@ class TangoTestResult(result.TestResult):
self.dots = verbosity == 2
self.tangoPrint = verbosity == 1
self.descriptions = descriptions
+ self.loop = 0
+ self.loopSuite = 0
def getDescription(self, test):
testString = str(test).split(' ')
@@ -227,6 +237,7 @@ class TangoTestResult(result.TestResult):
def printErrorList(self, flavour, errors):
for test, err in errors:
+ self.stream.writeln()
self.stream.writeln(self.separator1)
self.stream.writeln("%s: %s" % (flavour,self.getDescription(test)))
self.stream.writeln(self.separator2)
diff --git a/tests/TestSuite.py b/tests/TestSuite.py
new file mode 100644
index 0000000..cf4f6aa
--- /dev/null
+++ b/tests/TestSuite.py
@@ -0,0 +1,296 @@
+import sys
+import inspect
+import unittest
+import TangoRunner
+import PyTango
+from sets import Set
+import types
+import os
+
+
+# =====================================================================================================================
+# Test suites ---------------------------------------------------------------------------------------------------------
+
+# Test Case example ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+# this is a Test Case which aggregates Test Units of a similar domain
+# append a '__loop' suffix to the Test Case name to execute it multiple times - this will only be done if
+# a '--loopSuite=' command line parameter is defined and has a numeric value
+class TestCaseExample__loop(TangoRunner.TangoTestCase):
+ @classmethod
+ def setUpClass(self):
+ # get command line parameters
+ # parameters are defined by name, e.g. 'myparam' and provided in the command line as '--myparam=myparamvalue'
+ # you can provide description of the parameter but it is optional
+ # values of the parameters are returned as strings
+ # get_param() defines and returns value of a Mandatory Parameter which has to be provided in the command line,
+ # otherwise the execution terminates
+ #self.myparam = get_param('myparam','description of what myparam is')
+ # get_param_opt() defines and returns value of an Optional Parameter which may but does not have to be provided
+ # in the command line
+ #self.myparamopt = get_param_opt('loop','number of times the Unit Test suffixed with "__loop" will be executed')
+ # to correctly process command line parameters always append this line
+ validate_args()
+
+ @classmethod
+ def tearDownClass(self):
+ if is_restore_set(self, 'my_restore_point'):
+ # fix here what your unit test could break upon unpredicted termination
+ pass
+ # this is a Unit Test, to make the framework interpret a method as a Unit Test append the 'test_' suffix to its name
+ def test_MyUnitTest(self):
+ # set a restore point if you modify the configuration of the device on which the Test Suite is executed
+ # even if the Unit Test terminates unexpectedly, the configuration will be restored if you use
+ # is_restore_set() method in tearDownClass()
+ restore_set(self, 'my_restore_point')
+ # write your test here
+ # to get more information about available assertions refer to unittest tutorial
+ assert(1 == 1)
+ self.assertRegexpMatches('string to contain a word','word')
+ # if you bring all the device configuration to defaults, unset the restore point
+ restore_unset(self, 'my_restore_point')
+
+ # this Unit Test will be executed several times in a loop if the '--loop=' parameter is defined and has a numeric
+ # value; to declare a Unit Test to be executed in a loop append the '__looop' suffix to its name
+ def test_MyUnitTest1__loop(self):
+ assert(True)
+
+# Attr Misc Test Case ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+class AttrMisc(TangoRunner.TangoTestCase):
+ @classmethod
+ def setUpClass(self):
+ # get parameters
+ self.device1_name = get_param('device1','device on which the Test Suite executes')
+ validate_args()
+
+ self.device1 = PyTango.DeviceProxy(self.device1_name)
+
+ @classmethod
+ def tearDownClass(self):
+ if is_restore_set(self, 'Float_spec_attr_rw'):
+ ai = self.device1.get_attribute_config('Float_spec_attr_rw')
+ ai.min_value = 'NaN'
+ ai.max_value = 'NaN'
+ ai.alarms.min_alarm = 'NaN'
+ ai.alarms.max_alarm = 'NaN'
+ self.device1.set_attribute_config(ai)
+
+ def test_GetAttributeConfig(self):
+ ai = self.device1.get_attribute_config('Float_spec_attr_rw')
+ old_ai = PyTango.AttributeInfoEx(ai)
+ assert(ai.min_value == 'Not specified')
+ assert(ai.max_value == 'Not specified')
+ assert(ai.alarms.min_alarm == 'Not specified')
+ assert(ai.alarms.max_alarm == 'Not specified')
+
+ ai.min_value = '3.5'
+ ai.max_value = '15.5'
+ ai.alarms.min_alarm = '4.2'
+ ai.alarms.max_alarm = '13.5'
+ self.device1.set_attribute_config(ai)
+ restore_set(self, 'Float_spec_attr_rw')
+
+ new_ai = self.device1.get_attribute_config('Float_spec_attr_rw')
+ assert(new_ai.name == ai.name)
+ assert(new_ai.data_type == ai.data_type)
+ assert(new_ai.data_format == ai.data_format)
+ assert(new_ai.max_dim_x == ai.max_dim_x)
+ assert(new_ai.max_dim_y == ai.max_dim_y)
+ assert(new_ai.writable == ai.writable)
+ assert(new_ai.label == ai.label)
+ assert(new_ai.description == ai.description)
+ assert(new_ai.alarms.min_alarm == ai.alarms.min_alarm)
+ assert(new_ai.alarms.max_alarm == ai.alarms.max_alarm)
+ assert(new_ai.min_value == ai.min_value)
+ assert(new_ai.max_value == ai.max_value)
+
+ ai.min_value = 'NaN'
+ ai.max_value = 'NaN'
+ ai.alarms.min_alarm = 'NaN'
+ ai.alarms.max_alarm = 'NaN'
+ self.device1.set_attribute_config(ai)
+ restore_unset(self, 'Float_spec_attr_rw')
+
+ new_ai = self.device1.get_attribute_config('Float_spec_attr_rw')
+ assert(new_ai.name == old_ai.name)
+ assert(new_ai.data_type == old_ai.data_type)
+ assert(new_ai.data_format == old_ai.data_format)
+ assert(new_ai.max_dim_x == old_ai.max_dim_x)
+ assert(new_ai.max_dim_y == old_ai.max_dim_y)
+ assert(new_ai.writable == old_ai.writable)
+ assert(new_ai.label == old_ai.label)
+ assert(new_ai.description == old_ai.description)
+ assert(new_ai.alarms.min_alarm == old_ai.alarms.min_alarm)
+ assert(new_ai.alarms.max_alarm == old_ai.alarms.max_alarm)
+ assert(new_ai.min_value == old_ai.min_value)
+ assert(new_ai.max_value == old_ai.max_value)
+
+ new_ai.min_value = '3.5'
+ new_ai.max_value = '15.5'
+ self.device1.set_attribute_config(new_ai)
+ restore_set(self, 'Float_spec_attr_rw')
+
+ # TODO: choose one variant
+ # variant 1
+ with self.assertRaises(PyTango.DevFailed) as cm:
+ self.device1.write_attribute('Float_spec_attr_rw',[3.6,3.3,3.7])
+ assert(cm.exception.args[0].reason == 'API_WAttrOutsideLimit')
+ # variant 2
+ self.assertRaisesRegexp(PyTango.DevFailed,'reason = API_WAttrOutsideLimit',self.device1.write_attribute,'Float_spec_attr_rw',[3.6,3.3,3.7])
+
+ self.assertRaisesRegexp(PyTango.DevFailed,'reason = API_WAttrOutsideLimit',self.device1.write_attribute,'Float_spec_attr_rw',[17.6])
+
+ new_ai.min_value = 'NaN'
+ new_ai.max_value = 'NaN'
+ new_ai.alarms.min_alarm = '6.0'
+ self.device1.set_attribute_config(new_ai)
+
+ state = self.device1.state()
+ assert(state == PyTango.DevState.ALARM)
+ status = self.device1.status()
+ self.assertRegexpMatches(status,'ALARM')
+ self.assertRegexpMatches(status,'Float_spec_attr_rw')
+
+ da = self.device1.read_attribute('Float_spec_attr_rw')
+ assert(da.quality == PyTango.AttrQuality.ATTR_ALARM)
+
+ new_ai.alarms.min_alarm = 'NaN'
+ self.device1.set_attribute_config(new_ai)
+
+ state = self.device1.state()
+ assert(state == PyTango.DevState.ON)
+
+ da = self.device1.read_attribute('Float_spec_attr_rw')
+ assert(da.quality == PyTango.AttrQuality.ATTR_VALID)
+
+# End of Test suites --------------------------------------------------------------------------------------------------
+# =====================================================================================================================
+
+
+
+# =====================================================================================================================
+# Restore points internal functions -----------------------------------------------------------------------------------
+
+_restore_points = Set()
+
+def restore_hash(cls, name):
+ if isinstance(cls, (type, types.ClassType)):
+ # the tearDownClass method case
+ return cls.__name__ + name
+ else:
+ # the test methods case
+ return cls.__class__.__name__ + name
+
+def restore_set(cls, name):
+ _restore_points.add(restore_hash(cls, name))
+
+def restore_unset(cls, name):
+ # TODO: consider catching exceptions for silent execution
+ _restore_points.remove(restore_hash(cls, name))
+
+def is_restore_set(cls, name):
+ return restore_hash(cls, name) in _restore_points
+
+# End of Restore points internal functions ----------------------------------------------------------------------------
+# =====================================================================================================================
+
+
+
+# =====================================================================================================================
+# Arguments parsing ---------------------------------------------------------------------------------------------------
+
+params = {}
+params_opt = {}
+args_valid = True
+
+def get_param(param,desc='user defined mandatory parameter'):
+ '''Get mandatory parameters'''
+ if param not in params:
+ params[param] = desc
+ return find_param(param)
+
+def get_param_opt(param,desc='user defined mandatory parameter'):
+ '''Get mandatory parameters'''
+ if param not in params:
+ params_opt[param] = desc
+ return find_param(param)
+
+def validate_args():
+ '''Validate parameters'''
+ global args_valid
+ if args_valid == False:
+ usage = 'Usage: ' + os.path.basename(__file__) + ' '
+ params_str = 'Mandatory Parameters:\n'
+ params_opt_str = 'Optional Parameters:\n'
+ for param in params:
+ usage += '--' + param + '= '
+ params_str += '\t--' + param + '= - ' + params[param] + '\n'
+ for param in params_opt:
+ usage += '[--' + param + '=] '
+ params_opt_str += '\t--' + param + '= - ' + params_opt[param] + '\n'
+ print(usage + '\n')
+ if len(params) != 0:
+ print(params_str)
+ if len(params_opt) != 0:
+ print(params_opt_str)
+ sys.exit(1)
+
+def find_param(param):
+ param_full = '--' + param + '='
+ for arg in sys.argv:
+ if arg[:len(param_full)] == param_full:
+ return arg[len(param_full):]
+ global args_valid
+ args_valid = False
+ return ''
+
+def get_param_if_registered(param):
+ if param in params:
+ return get_param(param)
+ elif param in params_opt:
+ return get_opt_param(param)
+ else:
+ return ''
+
+
+# End of Arguments parsing --------------------------------------------------------------------------------------------
+# =====================================================================================================================
+
+
+
+# =====================================================================================================================
+# Test suite execution ------------------------------------------------------------------------------------------------
+if __name__ == '__main__':
+ # automatically detect tests (alphabetical order)
+ suites = []
+ testClasses = inspect.getmembers(sys.modules[__name__], inspect.isclass)
+ for name, test in testClasses:
+ if issubclass(test,TangoRunner.TangoTestCase):
+ suites.append(unittest.TestLoader().loadTestsFromTestCase(test))
+
+# # alternatively add test suite names here
+# tests = [MyTest__loop]
+# for test in tests:
+# suites.append(unittest.TestLoader().loadTestsFromTestCase(test))
+
+ # check loop parameters
+ def get_loop(param):
+ param_full = '--' + param + '='
+ for arg in sys.argv:
+ if arg[:len(param_full)] == param_full:
+ try:
+ loop_value = int(arg[len(param_full):])
+ except:
+ loop_value = 1
+ return loop_value
+ return 1
+
+ loopSuite_param = get_loop('loopSuite')
+ loop_param = get_loop('loop')
+
+ # execute the Test Suite
+ suite = TangoRunner.TangoTestSuite(suites)
+ TangoRunner.TangoTestRunner(loopSuite=loopSuite_param, loop=loop_param).run(suite)
+
+# End of Test suite execution -----------------------------------------------------------------------------------------
+# ===================================================================================================================== \ No newline at end of file
diff --git a/tests/TestSuiteTemplate.py b/tests/TestSuiteTemplate.py
new file mode 100644
index 0000000..32522ff
--- /dev/null
+++ b/tests/TestSuiteTemplate.py
@@ -0,0 +1,47 @@
+import sys
+import inspect
+import unittest
+import TangoRunner
+
+class MyTestSuite1(TangoRunner.TangoTestCase):
+ @classmethod
+ def setUpClass(self):
+ pass
+
+ @classmethod
+ def tearDownClass(cls):
+ pass
+
+ def setUp(self):
+ pass
+
+ def tearDown(self):
+ pass
+
+ def testMyTestCase1(self):
+ pass
+
+ def testMyTestCase2__loop(self):
+ pass
+
+
+class MyTestSuite2__loop(TangoRunner.TangoTestCase):
+ def testMyTestCase3(self):
+ pass
+
+
+if __name__ == '__main__':
+ # automatically detect tests (alphabetical order)
+ suites = []
+ testClasses = inspect.getmembers(sys.modules[__name__], inspect.isclass)
+ for name, test in testClasses:
+ if issubclass(test,TangoRunner.TangoTestCase):
+ suites.append(unittest.TestLoader().loadTestsFromTestCase(test))
+
+# # alternatively add test suite names here
+# tests = [MyTest__loop]
+# for test in tests:
+# suites.append(unittest.TestLoader().loadTestsFromTestCase(test))
+
+ suite = TangoRunner.TangoTestSuite(suites)
+ TangoRunner.TangoTestRunner().run(suite) \ No newline at end of file
diff --git a/tests/ci/ALBA/build.sh b/tests/ci/ALBA/build.sh
new file mode 100755
index 0000000..1f63bca
--- /dev/null
+++ b/tests/ci/ALBA/build.sh
@@ -0,0 +1,100 @@
+#!/bin/bash
+
+export PYTHONPATH=/tmp/jenkins/jobs/PyTango
+
+cd ../..
+
+python DevTest.py pytomasz &
+
+if [ $? != 0 ]
+then
+ exit $?
+fi
+
+python TestSuite.py --device1=dev/pytomasz/1
+
+expor EX = $?
+
+ps -ef | grep DevTest.py | awk '{print $2}' | xargs kill -9
+
+exit $EX
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+echo LOG4TANGO_ROOT
+echo $LOG4TANGO_ROOT
+echo OMNI_ROOT
+echo $OMNI_ROOT
+echo BOOST_ROOT
+echo $BOOST_ROOT
+echo ZMQ_ROOT
+echo $ZMQ_ROOT
+
+echo C_INCLUDE_PATH
+echo $C_INCLUDE_PATH
+
+echo CPLUS_INCLUDE_PATH
+echo $CPLUS_INCLUDE_PATH
+
+echo CPATH
+echo $CPATH
+
+export CPATH=/tmp/jenkins/jobs/TangoLib/include
+export C_INCLUDE_PATH=/tmp/jenkins/jobs/TangoLib/include:$C_INCLUDE_PATH
+export CPLUS_INCLUDE_PATH=/tmp/jenkins/jobs/TangoLib/include:$CPLUS_INCLUDE_PATH
+
+export TANGO_ROOT=/tmp/jenkins/jobs/TangoLib
+
+
+export LD_LIBRARY_PATH=/tmp/jenkins/jobs/TangoLib/lib:$LD_LIBRARY_PATH
+
+
+echo $LD_LIBRARY_PATH
+echo $CPLUS_INCLUDE_PATH
+
+
+cd ../..
+
+pwd
+
+make user=1 prefix=/tmp/jenkins/jobs install
+
+make user=1 prefix=/tmp/jenkins/jobs install
+
+export PYTHONPATH=/tmp/jenkins/jobs/PyTango:$PYTHONPATH
+
+echo $PYTHONPATH
+
+python tests/DevTest.py pytomasz &
+
+python tests/TestSuite.py
+
+ps -ef | awk '/DevTest.py/ {print$2}' | xargs kill -9
diff --git a/tests/ci/build.sh b/tests/ci/build.sh
new file mode 100755
index 0000000..9ea91e1
--- /dev/null
+++ b/tests/ci/build.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+if [ ! -z "$INSTITUTE" -a -d "$INSTITUTE" -a -f "$INSTITUTE/build.sh" ]
+then
+ echo "Executing build.sh for $INSTITUTE"
+ cd "$INSTITUTE"
+ ./build.sh
+ exit $?
+else
+ if [ ! -z "$INSTITUTE" ]
+ then
+ echo "Failed to execute ci/$INSTITUTE/build.sh !"
+ echo "Make sure ci/$INSTITUTE/build.sh exists"
+ else
+ echo "Mr Jenkins needs additional configuration!"
+ echo "Go to Jenkins dashboard -> Manage Jenkins -> Global Properties, tick Environment Variables and add a key-value pair: name - INSTITUTE, value - YourInstituteName."
+ echo "Check out the project. Go to the 'ci' directory and create a 'YourInstituteName' subdirectory. In the 'YourInstituteName' subdirectory create a 'build.sh' file which will contain the recipe how to build your project. Make the 'build.sh' file executable. Commit changes."
+ fi
+ exit 1
+fi