casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables
test_caltabconvert.py
Go to the documentation of this file.
00001 # unit test for the caltabconvert task
00002 
00003 import os
00004 import shutil
00005 import numpy as np       
00006 
00007 from __main__ import default
00008 from tasks import *
00009 from taskinit import *
00010 import unittest
00011 import testhelper as th
00012 
00013 class caltabconvert_test(unittest.TestCase):
00014 
00015     vis_f = 'multisource_unittest.ms'
00016     ref = 'multisource_unittest_reference.wvr'
00017     ref2 = 'multisource_unittest_reference-newformat.wvr'
00018     out = 'mycaltable.wvr'
00019     rval = False
00020     
00021     def setUp(self):    
00022         self.rval = False
00023 
00024         if(not os.path.exists(self.vis_f)):
00025             os.system('cp -R '+os.environ['CASAPATH'].split()[0]+'/data/regression/unittest/wvrgcal/input/multisource_unittest.ms .')
00026         if(not os.path.exists(self.ref)):
00027             os.system('cp -R '+os.environ['CASAPATH'].split()[0]+'/data/regression/unittest/wvrgcal/input/multisource_unittest_reference.wvr .')
00028         if(not os.path.exists(self.ref2)):
00029             os.system('cp -R '+os.environ['CASAPATH'].split()[0]+'/data/regression/unittest/wvrgcal/input/multisource_unittest_reference-newformat.wvr .')
00030 
00031         default(caltabconvert)
00032 
00033     def tearDown(self):
00034         os.system('rm -rf ' + self.out)
00035 
00036 
00037 # Test cases    
00038     def test1(self):
00039         '''Test 1: Testing default'''
00040         self.rval = caltabconvert()
00041         print "Expected error ..."
00042         self.assertFalse(self.rval)
00043 
00044     def test2(self):
00045         '''Test 2: Testing with a WVR caltable'''
00046         os.system('rm -rf '+self.out)
00047         self.rval = caltabconvert(vis=self.vis_f,
00048                                   caltabold=self.ref,
00049                                   ptype='complex',
00050                                   caltabnew=self.out)
00051 
00052         if(self.rval):
00053             self.rval = th.compTables(self.ref2, self.out,['WEIGHT', 'PARAMERR']) # WEIGHT column is empty
00054 
00055             self.rval = self.rval and th.compTables(self.ref2+'/ANTENNA', self.out+'/ANTENNA', [])
00056 
00057             self.rval = self.rval and th.compTables(self.ref2+'/FIELD', self.out+'/FIELD', [])
00058 
00059             self.rval = self.rval and th.compTables(self.ref2+'/SPECTRAL_WINDOW', self.out+'/SPECTRAL_WINDOW', [])
00060                                                           
00061 
00062         self.assertTrue(self.rval)
00063 
00064 
00065 
00066 def suite():
00067     return [caltabconvert_test]
00068