Skip to content

Commit 1a58a5c

Browse files
committed
INTEGRALSWRQ-158: tests for utils
1 parent 089e777 commit 1a58a5c

File tree

13 files changed

+318
-56
lines changed

13 files changed

+318
-56
lines changed

astroquery/esa/integral/core.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ def get_observations(self, *, target_name=None, coordinates=None, radius=14.0, s
325325
output_format=output_format)
326326

327327
def download_science_windows(self, *, science_windows=None, observation_id=None, revolution=None, proposal=None,
328-
output_file=None, read_fits=True):
328+
output_file=None, cache=False, read_fits=True):
329329
"""Method to download science windows associated to one of these parameters:
330330
science_windows, observation_id, revolution or proposal
331331
@@ -341,6 +341,8 @@ def download_science_windows(self, *, science_windows=None, observation_id=None,
341341
Proposal ID associated to science windows
342342
output_file: str, optional
343343
File name and path for the downloaded file
344+
cache: bool, optional, default False
345+
Flag to determine if the file is stored in the cache or not
344346
read_fits: bool, optional, default True
345347
Open the downloaded file and parse the existing FITS files
346348
@@ -355,7 +357,8 @@ def download_science_windows(self, *, science_windows=None, observation_id=None,
355357
try:
356358

357359
downloaded_file = esautils.download_file(url=conf.ISLA_DATA_SERVER, session=self.tap._session,
358-
filename=output_file, params=params, verbose=True)
360+
filename=output_file, params=params,
361+
cache=cache, cache_folder=self.cache_location, verbose=True)
359362
if read_fits:
360363
return esautils.read_downloaded_fits([downloaded_file])
361364
else:
-1.46 MB
Binary file not shown.

astroquery/esa/integral/tests/test_isla_tap.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ def test_get_long_term_timeseries_exception(self, instrument_band_mock, log_mock
412412
@patch('astroquery.esa.integral.core.IntegralClass.get_instrument_band_map')
413413
def test_get_long_term_timeseries(self, instrument_band_mock, download_mock):
414414
instrument_band_mock.return_value = mocks.get_instrument_bands()
415-
download_mock.return_value = data_path('lt.zip')
415+
download_mock.return_value = data_path('zip_file.zip')
416416

417417
isla = IntegralClass()
418418
mock_instrument_bands(isla_module=isla)
@@ -421,7 +421,6 @@ def test_get_long_term_timeseries(self, instrument_band_mock, download_mock):
421421
assert len(lt_timeseries_list_extracted) == 2
422422
lt_timeseries_list_compressed = isla.get_long_term_timeseries(target_name='J174537.0-290107', band='b1',
423423
read_fits=False)
424-
425424
assert type(lt_timeseries_list_compressed) is str
426425
close_files(lt_timeseries_list_extracted)
427426

@@ -483,7 +482,7 @@ def test_get_short_term_timeseries(self, instrument_band_mock, epoch_mock, downl
483482

484483
instrument_band_mock.return_value = mocks.get_instrument_bands()
485484
epoch_mock.return_value = {'epoch': ['time']}
486-
download_mock.return_value = data_path('st.tar')
485+
download_mock.return_value = data_path('tar_file.tar')
487486

488487
isla = IntegralClass()
489488
mock_instrument_bands(isla_module=isla)
@@ -559,7 +558,7 @@ def test_get_spectra(self, instrument_band_mock, servlet_mock, epoch_mock, downl
559558
instrument_band_mock.return_value = mocks.get_instrument_bands()
560559
servlet_mock.return_value = mocks.get_mock_spectra()
561560
epoch_mock.return_value = {'epoch': ['today']}
562-
download_mock.return_value = data_path('spectra.tar')
561+
download_mock.return_value = data_path('tar_file.tar')
563562

564563
isla = IntegralClass()
565564
mock_instrument_bands(isla_module=isla)
@@ -615,7 +614,7 @@ def test_get_mosaic(self, instrument_band_mock, servlet_mock, epoch_mock, downlo
615614
instrument_band_mock.return_value = mocks.get_instrument_bands()
616615
servlet_mock.return_value = mocks.get_mock_mosaic()
617616
epoch_mock.return_value = {'epoch': ['today']}
618-
download_mock.return_value = data_path('mosaic.tar.gz')
617+
download_mock.return_value = data_path('tar_gz_file.gz')
619618

620619
isla = IntegralClass()
621620
mock_instrument_bands(isla_module=isla)
31 KB
Binary file not shown.
Binary file not shown.

astroquery/esa/utils/tests/data/test.fits

Lines changed: 21 additions & 0 deletions
Large diffs are not rendered by default.
10.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)