Skip to content

Commit b083cb2

Browse files
imbasimbabsipocz
authored andcommitted
Added tests for ESASky spectra
1 parent ef3ea15 commit b083cb2

File tree

1 file changed

+65
-5
lines changed

1 file changed

+65
-5
lines changed

astroquery/esasky/tests/test_esasky_remote.py

Lines changed: 65 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,74 @@ def test_esasky_get_maps(self):
8888
file_path = os.path.join(download_directory, 'ISO-IR')
8989

9090
all_maps = ESASkyClass.query_object_maps("M51")
91-
isomaps = ESASkyClass.query_object_maps("M51", missions='ISO-IR')
91+
iso_maps = ESASkyClass.query_object_maps("M51", missions='ISO-IR')
9292
# Remove a few maps, so the other list will have downloadable ones, too
93-
isomaps['ISO-IR'].remove_rows([0, 1])
94-
ESASkyClass.get_maps(isomaps, download_dir=download_directory)
93+
iso_maps['ISO-IR'].remove_rows([0, 1])
94+
ESASkyClass.get_maps(iso_maps, download_dir=download_directory)
9595
assert len(os.listdir(file_path)) == len(all_maps['ISO-IR']) - 2
9696

97-
isomaps2 = dict({'ISO-IR': all_maps['ISO-IR'][:2]})
98-
ESASkyClass.get_maps(isomaps2, download_dir=download_directory)
97+
iso_maps2 = dict({'ISO-IR': all_maps['ISO-IR'][:2]})
98+
ESASkyClass.get_maps(iso_maps2, download_dir=download_directory)
9999
assert len(os.listdir(file_path)) == len(all_maps['ISO-IR'])
100100

101101
shutil.rmtree(download_directory)
102+
103+
def test_esasky_query_region_spectra(self):
104+
result = ESASkyClass.query_region_spectra("M51", "5 arcmin")
105+
assert isinstance(result, TableList)
106+
107+
def test_esasky_query_object_spectra(self):
108+
result = ESASkyClass.query_object_spectra("M51")
109+
assert isinstance(result, TableList)
110+
111+
@pytest.mark.bigdata
112+
def test_esasky_get_spectra(self):
113+
download_directory = "ESASkyRemoteTest"
114+
if not os.path.exists(download_directory):
115+
os.makedirs(download_directory)
116+
117+
missions = ESASkyClass.list_spectra()
118+
# HST-IR has no data, LAMOST does not support download
119+
missions = [mission for mission in missions if mission not in ("HST-IR", "LAMOST")]
120+
ESASkyClass.get_spectra("M1", missions=missions, download_dir=download_directory)
121+
122+
for mission in missions:
123+
file_path = os.path.join(download_directory, mission)
124+
assert os.path.exists(file_path)
125+
126+
shutil.rmtree(download_directory)
127+
128+
def test_esasky_get_spectra_small(self):
129+
download_directory = "ESASkyRemoteTest"
130+
if not os.path.exists(download_directory):
131+
os.makedirs(download_directory)
132+
133+
missions = ['HST-IR']
134+
135+
ESASkyClass.get_spectra("M1", radius="9arcmin", missions=missions, download_dir=download_directory)
136+
137+
for mission in missions:
138+
file_path = os.path.join(download_directory, mission)
139+
assert os.path.exists(file_path)
140+
141+
shutil.rmtree(download_directory)
142+
143+
def test_esasky_get_spectra_from_table(self):
144+
download_directory = "ESASkyRemoteTest"
145+
if not os.path.exists(download_directory):
146+
os.makedirs(download_directory)
147+
148+
file_path = os.path.join(download_directory, 'ISO-IR')
149+
150+
all_spectra = ESASkyClass.query_object_spectra("M51")
151+
iso_spectra = ESASkyClass.query_object_spectra("M51", missions='ISO-IR')
152+
# Remove a few maps, so the other list will have downloadable ones, too
153+
iso_spectra['ISO-IR'].remove_rows([0, 1])
154+
ESASkyClass.get_spectra_from_table(iso_spectra, download_dir=download_directory)
155+
assert len(os.listdir(file_path)) == len(all_spectra['ISO-IR']) - 2
156+
157+
iso_spectra2 = dict({'ISO-IR': all_spectra['ISO-IR'][:2]})
158+
ESASkyClass.get_spectra_from_table(iso_spectra2, download_dir=download_directory)
159+
assert len(os.listdir(file_path)) == len(all_spectra['ISO-IR'])
160+
161+
shutil.rmtree(download_directory)

0 commit comments

Comments
 (0)