66
77 tox -e py310-test-online -- -P noirlab
88"""
9+ import re
910import pytest
1011from astropy import units as u
1112from astropy .coordinates import SkyCoord
1213from .. import NOIRLab , conf
1314from . 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 ,)])
1822def test_service_metadata (hdu ):
@@ -77,6 +81,9 @@ def test_categoricals():
7781@pytest .mark .remote_data
7882def 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
93104def 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
102118def 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