[SCM] Control pipeline recipes from the European Southern Observatory branch, debian, updated. upstream/0.3.5.1-55-g3bec5ce
Ole Streicher
debian at liska.ath.cx
Thu Mar 28 16:51:26 UTC 2013
The following commit has been merged in the debian branch:
commit 3bec5ceb75d9c6b8460dc8e434510db8ffac407f
Author: Ole Streicher <debian at liska.ath.cx>
Date: Thu Mar 28 17:51:18 2013 +0100
Update to new test release 0.5
diff --git a/test/TestRecipe.py b/test/TestRecipe.py
index 16f84f9..ef3a62a 100644
--- a/test/TestRecipe.py
+++ b/test/TestRecipe.py
@@ -267,8 +267,8 @@ class RecipeCalib(RecipeTestCase):
'''[TAB] completition.
This requires to have the __dir__() method working.
'''
- self.assertEqual(self.recipe.calib.__dir__(),
- [ f.tag for f in self.recipe.calib ])
+ self.assertEqual(set(self.recipe.calib.__dir__()),
+ set(f.tag for f in self.recipe.calib))
class RecipeExec(RecipeTestCase):
def setUp(self):
@@ -286,6 +286,7 @@ class RecipeExec(RecipeTestCase):
self.assertTrue(isinstance(res.THE_PRO_CATG_VALUE, pyfits.HDUList))
self.assertTrue(abs(self.raw_frame[0].data
- res.THE_PRO_CATG_VALUE[0].data).max() == 0)
+ res.THE_PRO_CATG_VALUE.close()
def test_frames_keyword_calib(self):
'''Raw frame specified as keyword, calibration frame set in recipe'''
@@ -294,6 +295,7 @@ class RecipeExec(RecipeTestCase):
res = self.recipe({'RRRECIPE_DOCATG_RAW':self.raw_frame})
self.assertTrue(isinstance(res, cpl.Result))
self.assertTrue(isinstance(res.THE_PRO_CATG_VALUE, pyfits.HDUList))
+ res.THE_PRO_CATG_VALUE.close()
def test_frames_tag_keyword(self):
'''The 'tag' parameter'''
@@ -302,6 +304,7 @@ class RecipeExec(RecipeTestCase):
res = self.recipe(self.raw_frame, tag = raw_tag)
self.assertTrue(isinstance(res, cpl.Result))
self.assertTrue(isinstance(res.THE_PRO_CATG_VALUE, pyfits.HDUList))
+ res.THE_PRO_CATG_VALUE.close()
def test_frames_tag_attribute(self):
'''The 'tag' attribute'''
@@ -309,6 +312,7 @@ class RecipeExec(RecipeTestCase):
res = self.recipe(self.raw_frame)
self.assertTrue(isinstance(res, cpl.Result))
self.assertTrue(isinstance(res.THE_PRO_CATG_VALUE, pyfits.HDUList))
+ res.THE_PRO_CATG_VALUE.close()
def test_frames_one_element_input_list(self):
'''Use 1-element list as input'''
@@ -317,6 +321,7 @@ class RecipeExec(RecipeTestCase):
self.assertTrue(isinstance(res, cpl.Result))
self.assertFalse(isinstance(res.THE_PRO_CATG_VALUE, pyfits.HDUList))
self.assertTrue(isinstance(res.THE_PRO_CATG_VALUE, list))
+ res.THE_PRO_CATG_VALUE[0].close()
def test_frames_many_element_input_list(self):
'''Use multiple files as input'''
@@ -325,6 +330,7 @@ class RecipeExec(RecipeTestCase):
res = self.recipe([self.raw_frame, self.raw_frame])
self.assertTrue(isinstance(res, cpl.Result))
self.assertTrue(isinstance(res.THE_PRO_CATG_VALUE, pyfits.HDUList))
+ res.THE_PRO_CATG_VALUE.close()
def test_output_dir_attribute(self):
'''Write an output dir specified as attribute'''
@@ -339,6 +345,7 @@ class RecipeExec(RecipeTestCase):
self.assertTrue(os.path.isfile(res.THE_PRO_CATG_VALUE))
hdu = pyfits.open(res.THE_PRO_CATG_VALUE)
self.assertTrue(isinstance(hdu, pyfits.HDUList))
+ hdu.close()
def test_output_dir_keyword(self):
'''Write an output dir specified as call keyword arg'''
@@ -354,12 +361,31 @@ class RecipeExec(RecipeTestCase):
self.assertTrue(os.path.isfile(res.THE_PRO_CATG_VALUE))
hdu = pyfits.open(res.THE_PRO_CATG_VALUE)
self.assertTrue(isinstance(hdu, pyfits.HDUList))
+ hdu.close()
+
+ def test_param_default(self):
+ '''Test default parameter settings'''
+ res = self.recipe(self.raw_frame).THE_PRO_CATG_VALUE
+ self.assertEqual(res[0].header['HIERARCH ESO QC STROPT'].strip(),
+ self.recipe.param.stropt.default or '')
+ self.assertEqual(res[0].header['HIERARCH ESO QC BOOLOPT'],
+ self.recipe.param.boolopt.default)
+ self.assertEqual(res[0].header['HIERARCH ESO QC INTOPT'],
+ self.recipe.param.intopt.default)
+ self.assertEqual(res[0].header['HIERARCH ESO QC FLOATOPT'],
+ self.recipe.param.floatopt.default)
+ self.assertEqual(res[0].header['HIERARCH ESO QC ENUMOPT'],
+ self.recipe.param.enumopt.default)
+ self.assertEqual(res[0].header['HIERARCH ESO QC RANGEOPT'],
+ self.recipe.param.rangeopt.default)
+ res.close()
def test_param_keyword_dict(self):
'''Parameter handling via keyword dict'''
res = self.recipe(self.raw_frame,
param = { 'stropt':'more' }).THE_PRO_CATG_VALUE
self.assertEqual(res[0].header['HIERARCH ESO QC STROPT'], 'more')
+ res.close()
def test_param_keyword_dict_wrong(self):
'''Parameter handling via keyword dict'''
@@ -371,14 +397,17 @@ class RecipeExec(RecipeTestCase):
self.recipe.param.stropt = 'more'
res = self.recipe(self.raw_frame).THE_PRO_CATG_VALUE
self.assertEqual(res[0].header['HIERARCH ESO QC STROPT'], 'more')
+ res.close()
def test_param_delete(self):
'''Delete a parameter in a second run after setting it'''
self.recipe.param.intopt = 123
res = self.recipe(self.raw_frame).THE_PRO_CATG_VALUE
+ res.close()
del self.recipe.param.intopt
res = self.recipe(self.raw_frame).THE_PRO_CATG_VALUE
self.assertEqual(res[0].header['HIERARCH ESO QC INTOPT'], 2)
+ res.close()
def test_param_overwrite(self):
'''Overwrite the recipe setting param via via keyword arg'''
@@ -401,18 +430,21 @@ class RecipeExec(RecipeTestCase):
self.assertEqual(res[0].header['HIERARCH ESO QC FLOATOPT'], -0.25)
self.assertEqual(res[0].header['HIERARCH ESO QC ENUMOPT'], 'third')
self.assertEqual(res[0].header['HIERARCH ESO QC RANGEOPT'], 0.125)
+ res.close()
def test_environment_setting(self):
'''Additional environment parameter via recipe setting'''
self.recipe.env['TESTENV'] = 'unkk'
res = self.recipe(self.raw_frame).THE_PRO_CATG_VALUE
self.assertEqual(res[0].header['HIERARCH ESO QC TESTENV'], 'unkk')
+ res.close()
def test_environment_keyword(self):
'''Additional environment parameter via recipe call keyword'''
res = self.recipe(self.raw_frame,
env = {'TESTENV':'kknu'}).THE_PRO_CATG_VALUE
self.assertEqual(res[0].header['HIERARCH ESO QC TESTENV'], 'kknu')
+ res.close()
def test_error(self):
'''Error handling'''
@@ -443,6 +475,7 @@ class RecipeExec(RecipeTestCase):
# check that the data were moved correctly
self.assertTrue(abs(self.raw_frame[0].data
- res.THE_PRO_CATG_VALUE[0].data).max() < 1e-6)
+ res.THE_PRO_CATG_VALUE.close()
def test_error_parallel(self):
'''Error handling in parallel execution'''
@@ -458,6 +491,7 @@ class RecipeExec(RecipeTestCase):
res = self.recipe(self.raw_frame)
key = 'DATAMD5'
md5sum = res.THE_PRO_CATG_VALUE[0].header[key]
+ res.THE_PRO_CATG_VALUE.close()
self.assertNotEqual(md5sum, 'Not computed')
self.assertEqual(len(md5sum),
len('9d123996fa9a7bda315d07e063043454'))
@@ -469,6 +503,7 @@ class RecipeExec(RecipeTestCase):
res = self.recipe(self.raw_frame)
key = 'HIERARCH ESO PRO REC1 CAL1 DATAMD5'
md5sum = res.THE_PRO_CATG_VALUE[0].header[key]
+ res.THE_PRO_CATG_VALUE.close()
self.assertNotEqual(md5sum, 'Not computed')
self.assertEqual(len(md5sum),
len('9d123996fa9a7bda315d07e063043454'))
@@ -498,6 +533,9 @@ class RecipeRes(RecipeTestCase):
RecipeTestCase.setUp(self)
self.res = self.recipe(self.raw_frame)
+ def tearDown(self):
+ self.res.THE_PRO_CATG_VALUE.close()
+
def test_attribute(self):
'''The result as an attribute'''
self.assertTrue(isinstance(self.res.THE_PRO_CATG_VALUE,
@@ -579,10 +617,31 @@ class RecipeEsorex(CplTestCase):
filename = os.path.join(dirname, filename)
logging.getLogger('cpl').info(log_msg)
self.assertTrue(os.path.exists(filename))
- log_content = open(filename).read()
+ logfile = open(filename)
+ log_content = logfile.read()
+ logfile.close()
self.assertTrue(log_msg in log_content)
self.assertTrue('INFO' in log_content)
+ def test_esorex_log_off(self):
+ '''Switch the logfile off after writing something'''
+ dirname = os.path.join(self.temp_dir, 'log')
+ filename = 'python-cpl_off.log'
+ log_msg = 'Esorex convienence log'
+ os.mkdir(dirname)
+ cpl.esorex.log.dir = dirname
+ cpl.esorex.log.filename = 'python-cpl_debug.log'
+ cpl.esorex.log.level = 'debug'
+ logging.getLogger('cpl').debug(log_msg)
+ cpl.esorex.log.filename = filename
+ cpl.esorex.log.level = 'off'
+ logging.getLogger('cpl').debug(log_msg)
+ filename = os.path.join(dirname, filename)
+ logfile = open(filename)
+ log_content = logfile.read()
+ logfile.close()
+ self.assertEqual(len(log_content), 0)
+
class RecipeLog(RecipeTestCase):
def setUp(self):
RecipeTestCase.setUp(self)
@@ -611,7 +670,8 @@ class RecipeLog(RecipeTestCase):
'''Injection of CPL messages into the python logging system'''
self.handler.clear()
logging.getLogger().setLevel(logging.DEBUG)
- self.recipe(self.raw_frame)
+ res = self.recipe(self.raw_frame)
+ res.THE_PRO_CATG_VALUE.close()
# check that the logs are not empty
self.assertNotEqual(len(self.handler.logs), 0)
@@ -634,7 +694,9 @@ class RecipeLog(RecipeTestCase):
'''Filtering INFO messages'''
self.handler.clear()
logging.getLogger('cpl.rtest').setLevel(logging.INFO)
- self.recipe(self.raw_frame)
+ res = self.recipe(self.raw_frame)
+ res.THE_PRO_CATG_VALUE.close()
+
# check that the logs are not empty
self.assertNotEqual(len(self.handler.logs), 0)
@@ -642,7 +704,9 @@ class RecipeLog(RecipeTestCase):
'''Filtering WARN messages'''
self.handler.clear()
logging.getLogger('cpl.rtest').setLevel(logging.WARN)
- self.recipe(self.raw_frame)
+ res = self.recipe(self.raw_frame)
+ res.THE_PRO_CATG_VALUE.close()
+
# check that the logs are not empty
self.assertNotEqual(len(self.handler.logs), 0)
@@ -651,21 +715,24 @@ class RecipeLog(RecipeTestCase):
# There is no error msg written by the recipe, so it should be empty.
self.handler.clear()
logging.getLogger('cpl.rtest').setLevel(logging.ERROR)
- self.recipe(self.raw_frame)
+ res = self.recipe(self.raw_frame)
+ res.THE_PRO_CATG_VALUE.close()
self.assertEqual(len(self.handler.logs), 0)
def test_logging_common(self):
'''Log name specification on recipe call'''
self.handler.clear()
self.other_handler.clear()
- self.recipe(self.raw_frame, logname = 'othername')
+ res = self.recipe(self.raw_frame, logname = 'othername')
+ res.THE_PRO_CATG_VALUE.close()
self.assertNotEqual(len(self.other_handler.logs), 0)
def test_logging_multiline(self):
'''Multiple lines in messages'''
self.handler.clear()
logging.getLogger('cpl.rtest').setLevel(logging.INFO)
- self.recipe(self.raw_frame)
+ res = self.recipe(self.raw_frame)
+ res.THE_PRO_CATG_VALUE.close()
# check that the multi line log sequence appears
multiline = 0
tag = 'multiline#'
@@ -696,6 +763,7 @@ class RecipeLog(RecipeTestCase):
self.assertTrue(isinstance(res.log.warning[0], str))
# Check that there were no error messages
self.assertEqual(len(res.log.error), 0)
+ res.THE_PRO_CATG_VALUE.close()
def test_error(self):
'''"log" attribute of the CplError object'''
@@ -736,6 +804,9 @@ class ProcessingInfo(RecipeTestCase):
self.res = self.recipe(self.raw_frame).THE_PRO_CATG_VALUE
self.pinfo = cpl.dfs.ProcessingInfo(self.res)
+ def tearDown(self):
+ self.res.close()
+
def test_param(self):
'''Parameter information'''
self.assertEqual(len(self.pinfo.param), len(self.recipe.param))
--
Control pipeline recipes from the European Southern Observatory
More information about the debian-science-commits
mailing list