Go to the documentation of this file.00001 import os
00002 import string
00003 import sys
00004 import shutil
00005 import unittest
00006 from __main__ import default
00007 from tasks import *
00008 from taskinit import *
00009
00010 '''
00011 Unit tests for task plotants. It tests the following parameters:
00012 vis: wrong and correct values
00013 figfile: if output is created
00014 '''
00015 class plotants_test(unittest.TestCase):
00016
00017 msfile = 'ic2233_1.ms'
00018 res = None
00019 fig = 'plotantstest.png'
00020
00021 def setUp(self):
00022 self.res = None
00023 default(plotants)
00024
00025
00026 tp.setgui(gui=False)
00027
00028
00029 if (not os.path.exists(self.msfile)):
00030 datapath = os.environ.get('CASAPATH').split()[0] + '/data/regression/ic2233/'
00031 shutil.copytree(datapath+self.msfile, self.msfile)
00032
00033 def tearDown(self):
00034 if (os.path.exists(self.msfile)):
00035 os.system('rm -rf ' + self.msfile)
00036
00037 os.system('rm -rf ' + self.fig)
00038
00039 tp.setgui(gui=True)
00040
00041
00042 def test0(self):
00043 '''Test 0: Default parameters'''
00044 self.res = plotants()
00045 self.assertFalse(self.res)
00046
00047 def test1(self):
00048 '''Test 1: Bad input file'''
00049 msfile = 'badfile'
00050 self.res = plotants(vis=msfile)
00051 self.assertFalse(self.res)
00052
00053 def test2(self):
00054 '''Test 2: Good input file and output exists'''
00055 if os.uname()[0] == "Darwin" and \
00056 os.system("sw_vers -productVersion | grep 10.6") == 0 and \
00057 not os.getenv("DISPLAY"):
00058 print >> sys.stderr, "Warning: The DISPLAY environment variable is unset, " + \
00059 "required on OS X 10.6, skipping test"
00060 else:
00061 self.res = plotants(vis=self.msfile, figfile=self.fig)
00062 self.assertEqual(self.res,None)
00063 self.assertTrue(os.path.exists(self.fig))
00064
00065 def suite():
00066 return [plotants_test]
00067
00068
00069
00070
00071
00072
00073
00074