def test2(): '''ASTRODATA-mode TEST 2: Overwrite readonly AD using name change''' ad = AstroData(sci123) outfile = 'testmode2.fits' if os.path.exists(outfile): os.remove(outfile) ad.filename = outfile ad.write() assert_true(os.path.isfile(outfile), 'ad.write() FAIL') os.remove(outfile) ad.close()
def test5(): '''ASTRODATA-mode TEST 5: Clobber changed readonly file''' outfile = 'testmode5.fits' if os.path.exists(outfile): os.remove(outfile) shutil.copy(sci123, outfile) ad = AstroData(outfile, mode='update') ad.hdulist[0].header['INSTRUME'] = 'GMOS-S' ad.write(clobber=True) ad.close() ad = AstroData(outfile) ok_(ad.hdulist[0].header['INSTRUME'] == 'GMOS-S', msg='Keyword is different') os.remove(outfile) ad.close()
def test3(): '''ASTRODATA-mode TEST 3: Clobber unchanged readonly file''' ad = AstroData(sci123) ad.write(clobber=True) assert_true(os.path.isfile(sci123), 'Clobber fail') ad.close()
def test1(): '''ASTRODATA-mode TEST 1: Fail when try to overwrite readonly''' ad = AstroData(sci123) ad.write()
def test4(): '''ASTRODATA-mode TEST 4: Fail when try to update readonly file ''' ad = AstroData(sci123, mode='update') ad.hdulist[0].header['INSTRUME'] = 'GMOS-S' ad.write()