Skip to content

Commit 668a7d3

Browse files
committed
test for escaping URI in download_file
1 parent 22734da commit 668a7d3

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

astroquery/mast/tests/test_mast_remote.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,19 @@ def test_observations_download_file_cloud(self, tmp_path, in_uri):
498498
assert result == ('COMPLETE', None, None)
499499
assert Path(tmp_path, filename).exists()
500500

501+
def test_observations_download_file_escaped(self, tmp_path):
502+
# test that `download_file` correctly escapes a URI
503+
in_uri = 'mast:HLA/url/cgi-bin/fitscut.cgi?' \
504+
'red=hst_04819_65_wfpc2_f814w_pc&blue=hst_04819_65_wfpc2_f555w_pc&size=ALL&format=fits'
505+
filename = Path(in_uri).name
506+
result = Observations.download_file(uri=in_uri, local_path=tmp_path)
507+
assert result == ('COMPLETE', None, None)
508+
assert Path(tmp_path, filename).exists()
509+
510+
# check that downloaded file is a valid FITS file
511+
f = fits.open(filename)
512+
f.close()
513+
501514
@pytest.mark.parametrize("test_data_uri, expected_cloud_uri", [
502515
("mast:HST/product/u24r0102t_c1f.fits",
503516
"s3://stpubdata/hst/public/u24r/u24r0102t/u24r0102t_c1f.fits"),

0 commit comments

Comments
 (0)