-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
read_files now handles more types and returns a dict
fits_info renamed and improved
- Loading branch information
Showing
8 changed files
with
280 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,56 @@ | ||
import pytest | ||
from irispy.io.utils import fits_info, read_files, tar_extract_all | ||
|
||
from irispy.io.utils import fitsinfo, read_files | ||
|
||
def test_tar_extract_all(fake_tar): | ||
# fake_tar is a Path | ||
extracted_files = tar_extract_all(fake_tar) | ||
assert len(extracted_files) == 4 | ||
for file in extracted_files: | ||
assert file.exists() | ||
assert file.is_file() | ||
assert all(file.suffix == ".fits" for file in extracted_files) | ||
assert all(file.parent == fake_tar.parent / fake_tar.stem for file in extracted_files) | ||
|
||
def test_fitsinfo(capsys, raster_file, sji_1330_file, sji_1400_file, sji_2796_file, sji_2832_file): | ||
fitsinfo(raster_file) | ||
|
||
def test_fits_info(capsys, raster_file, sji_1330_file, sji_1400_file, sji_2796_file, sji_2832_file): | ||
RASTER = "\nObservation: Medium sit-and-stare 0.3x60 1s C II Si IV Mg II h/k Mg II w s\nOBS ID: 3620258102\nNo. Name Ver ... Format Description \n--- ------- --- ... ------------------------ -------------------------\n 0 PRIMARY 1 ... float32 SJI 1330 (1310 - 1350 AA)\n 1 1 ... float64 Auxiliary data\n 2 1 ... [A10, A10, A4, A66, A63] Auxiliary data\n' = CaptureResult(out='Filename: /home/nabil/Git/irispy-lmsal/irispy/data/test/iris_l2_20210905_001833_3620258102_SJI_1330_t000_test.fits\nObservation: Medium sit-and-stare 0.3x60 1s C II Si IV Mg II h/k Mg II w s\nOBS ID: 3620258102\nNo. Name Ver ... Format Description \n--- ------- --- ... ------------------------ -------------------------\n 0 PRIMARY 1 ... float32 SJI 1330 (1310 - 1350 AA)\n 1 1 ... float64 Auxiliary data\n 2 1 ... [A10, A10, A4, A66, A63] Auxiliary data\n'" | ||
fits_info(raster_file) | ||
captured = capsys.readouterr() | ||
assert raster_file in captured.out | ||
assert RASTER in captured.out | ||
|
||
fitsinfo(sji_1330_file) | ||
SJI = "" | ||
fits_info(sji_1330_file) | ||
captured = capsys.readouterr() | ||
assert sji_1330_file in captured.out | ||
assert sji_1400_file in captured.out | ||
assert SJI in captured.out | ||
|
||
fitsinfo(sji_1400_file) | ||
fits_info(sji_1400_file) | ||
captured = capsys.readouterr() | ||
assert sji_1400_file in captured.out | ||
|
||
fitsinfo(sji_2796_file) | ||
fits_info(sji_2796_file) | ||
captured = capsys.readouterr() | ||
assert sji_2796_file in captured.out | ||
|
||
fitsinfo(sji_2832_file) | ||
fits_info(sji_2832_file) | ||
captured = capsys.readouterr() | ||
assert sji_2832_file in captured.out | ||
|
||
|
||
def test_read_files_errors_with_mix(raster_file, sji_1330_file): | ||
with pytest.raises(ValueError, match="You cannot mix raster and SJI files."): | ||
read_files([raster_file, sji_1330_file]) | ||
|
||
|
||
def test_read_files_raster(raster_file): | ||
# Simple test to ensure it does not error | ||
read_files(raster_file) | ||
read_files([raster_file]) | ||
read_files([raster_file, raster_file]) | ||
|
||
|
||
def test_read_files_sji(sji_1330_file, sji_1400_file, sji_2796_file, sji_2832_file): | ||
# Simple test to ensure it does not error | ||
read_files(sji_1330_file) | ||
read_files(sji_1400_file) | ||
read_files(sji_2796_file) | ||
read_files(sji_2832_file) | ||
read_files([sji_2832_file]) | ||
read_files([sji_2832_file, sji_2796_file, sji_1400_file, sji_1330_file]) | ||
|
||
|
||
def test_read_files_sji_more_than_one(sji_1330_file): | ||
# Don't allow more than one SJI file for now. | ||
with pytest.raises(ValueError, match="You cannot load more than one SJI file at a time."): | ||
read_files([sji_1330_file, sji_1330_file]) | ||
def test_read_files_with_mix(raster_file, sji_1330_file): | ||
read_files([raster_file, sji_1330_file]) |
Oops, something went wrong.