casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables
test_fixplanets.py
Go to the documentation of this file.
00001 import os
00002 import sys
00003 import shutil
00004 from __main__ import default
00005 from tasks import *
00006 from taskinit import *
00007 import unittest
00008 
00009 '''
00010 Unit tests for task fixplanets.
00011 
00012 Features tested:                                                       
00013   1. Does a standard fixplanets work on an MS imported from an ASDM from April 2011
00014   2. Does the setting of a given direction work on an MS imported from an ASDM from April 2011
00015   3. Does the setting of a given direction with ref !=J2000 and != sol.sys. object give the expected error?
00016   4. Does the setting of a given direction work with a sol system ref frame
00017 
00018 '''
00019 datapath = os.environ.get('CASAPATH').split()[0] + '/data/regression/unittest/listvis/'
00020 inpms = 'uid___A002_X1c6e54_X223-thinned.ms'
00021 outms = inpms
00022 inpms2 = 'uid___A002_X1c6e54_X223-thinned.mms'
00023 outms2 = inpms2
00024 
00025 class fixplanets_test1(unittest.TestCase):
00026     def setUp(self):
00027         res = None
00028         shutil.rmtree(outms, ignore_errors=True)
00029         shutil.copytree(datapath + inpms, outms)
00030         shutil.rmtree(outms2, ignore_errors=True)
00031         shutil.copytree(datapath + inpms2, outms2)
00032         default(fixplanets)
00033         
00034     def tearDown(self):
00035         shutil.rmtree(outms, ignore_errors=True)
00036         shutil.rmtree(outms2, ignore_errors=True)
00037         
00038     def test1(self):
00039         '''Does a standard fixplanets work on an MS imported from an ASDM from April 2011'''
00040         for myms in [outms,outms2]:
00041             rval = fixplanets(myms, 'Titan', True)
00042                 
00043             self.assertTrue(rval)
00044 
00045     def test2(self):
00046         '''Does the setting of a given direction work on an MS imported from an ASDM from April 2011'''
00047         for myms in [outms,outms2]:
00048             rval = fixplanets(myms, 'Titan', False, 'J2000 0h0m0s 0d0m0s')
00049                 
00050             self.assertTrue(rval)
00051 
00052     def test3(self):
00053         '''Does the setting of a given direction with ref !=J2000 and != sol.sys. object give the expected error?'''
00054         for myms in [outms,outms2]:
00055             rval = fixplanets(myms, 'Titan', False, 'B1950 0h0m0s 0d0m0s')
00056                 
00057             self.assertFalse(rval)
00058 
00059     def test4(self):
00060         '''Does the setting of a given direction work with a sol system ref frame?'''
00061         for myms in [outms,outms2]:
00062             rval = fixplanets(myms, 'Titan', False, 'SATURN 0h0m0s 0d0m0s')
00063                 
00064             self.assertTrue(rval)
00065 
00066     def test5(self):
00067         '''Does a standard fixplanets work on an MS imported from an ASDM from April 2011 with parameter reftime'''
00068         for myms in [outms,outms2]:
00069             rval = fixplanets(vis=myms, field='Titan', fixuvw=True, reftime='median')
00070                 
00071             self.assertTrue(rval)
00072 
00073     def test6(self):
00074         '''Does a standard fixplanets with put of bounds parameter reftime give the expected error'''
00075         for myms in [outms,outms2]:
00076             rval = fixplanets(vis=myms, field='Titan', fixuvw=True, reftime='2012/07/11/08:41:32')
00077                 
00078             self.assertFalse(rval)
00079 
00080     def test7(self):
00081         '''Does a standard fixplanets with wrong parameter reftime give the expected error'''
00082         for myms in [outms,outms2]:
00083             rval = fixplanets(vis=myms, field='Titan', fixuvw=True, reftime='MUDIAN')
00084                 
00085             self.assertFalse(rval)
00086 
00087 
00088 
00089     
00090 def suite():
00091     return [fixplanets_test1]        
00092         
00093