casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables
test_listfits.py
Go to the documentation of this file.
00001 import os
00002 import sys
00003 import shutil
00004 import commands
00005 from __main__ import default
00006 from tasks import *
00007 from taskinit import *
00008 import unittest
00009 
00010 class listfits_test(unittest.TestCase):
00011     
00012     # Input and output names
00013     fitsfile = 'ngc5921.fits'
00014     res = None
00015 
00016     def setUp(self):
00017         self.res = None
00018         default(listfits)
00019         
00020         if(os.path.exists(self.fitsfile)):
00021             os.system('rm -rf ' + self.fitsfile)
00022 
00023         shutil.copyfile(os.environ.get('CASAPATH').split()[0] +\
00024                             '/data/regression/ngc5921/'+self.fitsfile, self.fitsfile)
00025     
00026     def tearDown(self):
00027         if (os.path.exists(self.fitsfile)):
00028             os.system('rm -rf ' + self.fitsfile)
00029         
00030     def test1(self):
00031         '''Test 1: Empty input should return False'''
00032         fitsfile = ''
00033         self.res = listfits(fitsfile)
00034         self.assertFalse(self.res)
00035         
00036     def test2(self):
00037         '''Test 2: Good input should return None'''
00038         self.res=listfits(self.fitsfile)
00039         self.assertEqual(self.res,None)
00040         
00041     def test3(self):
00042         '''Test 3: list the fits into a private logfile'''
00043         thelogfile=casalog.logfile()
00044         logfile= "mylistfits.log"
00045         try:
00046            open(logfile,"w").close()
00047            casalog.setlogfile(logfile)
00048            listfits(self.fitsfile)
00049            casalog.setlogfile(thelogfile)
00050         except:
00051            print 'could not open "%s" for writing' % logfile
00052         
00053 def suite():
00054     return [listfits_test]
00055 
00056        
00057         
00058         
00059         
00060         
00061         
00062