from casatools import ctsys
from casatestutils.stakeholder import almastktestutils
class Test_almastkutils(unittest.TestCase):
''' common input data '''
cls.datapath = ctsys.resolve('stakeholder/alma')
cls.oldtestscr = 'test_stk_alma_pipeline_imaging_old.py'
cls.curjson = 'test_stk_alma_pipeline_imaging_exp_dicts.json'
cls.stdcubejson = 'test_standard_cube_cur_stats.json'
shutil.copy(os.path.join(self.datapath,self.stdcubejson),self.stdcubejson)
shutil.copy(os.path.join(self.datapath,self.curjson),self.curjson)
def compareDict(self, indict, refdict):
if type(indict[key]==dict):
if type(refdict[key][mt])==list and type(indict[key][mt])!=list:
if indict[key][mt] == refdict[key][mt][1]:
if indict[key][mt] == refdict[key][mt]:
if type(refdict[key])==list and type(indict[key])!=list:
if indict[key] == refdict[key][1]:
if indict[key]==refdict[key]:
def test_extract_subexpdict(self):
''' Test a fuction to extract a subset of exp dicts from a single testcase json file '''
print("stdcubejon=",self.stdcubejson)
metrickeys=['im_stats_dict','psf_stats_dict']
almastktestutils.extract_subexpdict(self.stdcubejson,keylist=metrickeys)
outputname = self.stdcubejson.rstrip('.json') + '_subDict.json'
print("output=",outputname)
outputexist = os.path.exists(outputname)
self.assertTrue(outputexist)
with open(outputname) as f:
self.assertTrue('test_standard_cube' in subdict)
self.assertTrue('im_stats_dict' in subdict['test_standard_cube'])
self.assertTrue('psf_stats_dict' in subdict['test_standard_cube'])
def test_read_testcase_expdicts(self):
''' Test a fuction to read the combined metric value json and returns a dictionary of the values for a testcase'''
with open (os.path.join(self.datapath, self.curjson)) as f:
if 'casa_version' in refdict:
casaversion = refdict['casa_version']
self.assertNotEqual(casaversion,'')
retdict = almastktestutils.read_testcase_expdicts(os.path.join(self.datapath,self.curjson), 'test_mosaic_cube', casaversion)
compres = self.compareDict(retdict,refdict['test_mosaic_cube'])
self.assertTrue(compres==0)
def test_read_testcase_expdicts_mismatchCasaVersion(self):
''' Test a fuction to read stored fiducial value json: CASA version check '''