def test_search_headers_no_datafile(self): """ Tests the search_headers function against the original file that caused the issue. """ try: download_folder("search_headers") except: raise DataDownloadException( "Could not download test data for skies." ) raw_dir = "src/simmer/tests/test_search_header/" data, header = pyfits.getdata( raw_dir + "wrong_header.fits", header=True ) del header["DATAFILE"] pyfits.writeto( raw_dir + "wrong_header.fits", data, header, overwrite=True ) with captured_output() as (out, err): search.search_headers(raw_dir) anticipated_string = "Header Incomplete in src/simmer/tests/test_search_header/wrong_header.fits!!!" # This can go inside or outside the `with` block output = out.getvalue().strip() delete_folder(raw_dir) self.assertEqual(output, anticipated_string)
def test_create_config_xlsx(self): try: download_folder("config_test") except: raise DataDownloadException( "Could not download test data for config_test." ) tab = "Sheet1" excel_path = "src/simmer/Examples/Shane/logsheet.xlsx" c.create_config(excel_path, "created_frame.csv", tab) created_frame = pd.read_csv("created_frame.csv") compare_frame = pd.read_csv( "src/simmer/tests/config_test/created_frame_xlsx.csv" ) delete_folder("src/simmer/tests/config_test") self.assertTrue(created_frame.equals(compare_frame))
def test_add_dark_exposure(self): try: download_folder("dark_test") except: raise DataDownloadException( "Could not download test data for darks." ) excel_path = "src/simmer/Examples/Shane/logsheet.xlsx" copy_path = "src/simmer/Examples/Shane/logsheet_copy.xlsx" copyfile(excel_path, copy_path) raw_dir = "src/simmer/tests/dark_test/" tab = "Sheet1" inst = i.ShARCS() ad.add_dark_exp(inst, copy_path, raw_dir, tab) os.remove(copy_path) delete_folder(raw_dir) self.assertTrue(True)
def test_readpharo_quadrants(self): try: download_folder("readpharo_test") except: raise DataDownloadException( "Could not download test data for readpharo function." ) raw_dir, new_dir, test_red_dir = ( "src/simmer/tests/readpharo_test/raw/", "src/simmer/tests/readpharo_test/test_newdir/", "src/simmer/tests/readpharo_test/test_red/", ) self.inst.read_data(raw_dir, new_dir) compare_flattened = pyfits.getdata(test_red_dir + "sph0436.fits") zero = np.zeros(np.shape(compare_flattened)) flattened = pyfits.getdata(new_dir + "sph0436.fits") val = np.all(np.allclose(compare_flattened, flattened, equal_nan=True)) delete_folder("src/simmer/tests/readpharo_test") self.assertTrue(val)