Skip to content

Commit 155f337

Browse files
committed
remove some strict requirements on remote tests
1 parent 0f7ab71 commit 155f337

1 file changed

Lines changed: 29 additions & 3 deletions

File tree

astroquery/noirlab/tests/test_noirlab_remote.py

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@
66
77
tox -e py310-test-online -- -P noirlab
88
"""
9+
import re
910
import pytest
1011
from astropy import units as u
1112
from astropy.coordinates import SkyCoord
1213
from .. import NOIRLab, conf
1314
from . import expected as exp
1415

1516

17+
md5sum_string = re.compile(r'[0-9a-f]+')
18+
19+
1620
@pytest.mark.remote_data
1721
@pytest.mark.parametrize('hdu', [(False,), (True,)])
1822
def test_service_metadata(hdu):
@@ -77,6 +81,9 @@ def test_categoricals():
7781
@pytest.mark.remote_data
7882
def test_query_file_metadata():
7983
"""Search FILE metadata.
84+
85+
Both the column ordering and the actual returned results may vary,
86+
so just check that the response "looks like" the expected data.
8087
"""
8188
conf.timeout = 300
8289
qspec = {"outfields": ["md5sum",
@@ -86,21 +93,33 @@ def test_query_file_metadata():
8693
"proc_type"],
8794
"search": [['original_filename', 'c4d_', 'contains']]}
8895
actual = NOIRLab().query_metadata(qspec, sort='md5sum', limit=3)
89-
assert actual.pformat(max_width=-1) == NOIRLab._response_to_table(exp.query_file_meta_raw).pformat(max_width=-1)
96+
actual_formatted = actual.pformat(max_width=-1)
97+
for f in qspec['outfields']:
98+
assert f in actual_formatted[0]
99+
assert md5sum_string.match(actual['md5sum'][2]) is not None
100+
assert actual['instrument'][0] == 'decam'
90101

91102

92103
@pytest.mark.remote_data
93104
def test_query_file_metadata_minimal_input():
94105
"""Search FILE metadata with minimum input parameters.
106+
107+
Actual returned results may vary, so just check that the response
108+
"looks like" the expected data.
95109
"""
96110
conf.timeout = 300
97111
actual = NOIRLab().query_metadata(qspec=None, sort='md5sum', limit=5)
98-
assert actual.pformat(max_width=-1) == exp.query_file_metadata_minimal
112+
actual_formatted = actual.pformat(max_width=-1)
113+
assert actual_formatted[0] == exp.query_file_metadata_minimal[0]
114+
assert md5sum_string.match(actual_formatted[6]) is not None
99115

100116

101117
@pytest.mark.remote_data
102118
def test_query_hdu_metadata():
103119
"""Search HDU metadata.
120+
121+
Both the column ordering and the actual returned results may vary,
122+
so just check that the response "looks like" the expected data.
104123
"""
105124
conf.timeout = 300
106125
qspec = {"outfields": ["md5sum",
@@ -116,7 +135,14 @@ def test_query_hdu_metadata():
116135
["instrument", "decam"],
117136
["proc_type", "raw"]]}
118137
actual = NOIRLab().query_metadata(qspec, sort='md5sum', limit=3, hdu=True)
119-
assert actual.pformat(max_width=-1) == NOIRLab._response_to_table(exp.query_hdu_metadata_raw).pformat(max_width=-1)
138+
actual_formatted = actual.pformat(max_width=-1)
139+
for f in qspec['outfields']:
140+
if 'hdu:' in f:
141+
assert f.split(':')[1] in actual_formatted[0]
142+
else:
143+
assert f in actual_formatted[0]
144+
assert md5sum_string.match(actual['md5sum'][2]) is not None
145+
assert actual['caldat'][0] == '2017-08-15'
120146

121147

122148
@pytest.mark.remote_data

0 commit comments

Comments
 (0)