32
32
33
33
34
34
GAIA_QUERIER = GaiaClass (show_server_messages = False )
35
- job_data = (Path (__file__ ).with_name ("data" ) / "job_1.vot" ).read_text ()
36
-
37
- skycoord = SkyCoord (ra = 19 * u .deg , dec = 20 * u .deg , frame = "icrs" )
35
+ JOB_DATA = (Path (__file__ ).with_name ("data" ) / "job_1.vot" ).read_text ()
36
+ SKYCOORD = SkyCoord (ra = 19 * u .deg , dec = 20 * u .deg , frame = "icrs" )
38
37
39
38
40
39
@pytest .fixture (scope = "module" )
@@ -56,7 +55,7 @@ def mock_querier():
56
55
conn_handler = DummyConnHandler ()
57
56
tapplus = TapPlus ("http://test:1111/tap" , connhandler = conn_handler )
58
57
launch_response = DummyResponse (200 )
59
- launch_response .set_data (method = "POST" , body = job_data )
58
+ launch_response .set_data (method = "POST" , body = JOB_DATA )
60
59
# The query contains decimals: default response is more robust.
61
60
conn_handler .set_default_response (launch_response )
62
61
return GaiaClass (tap_plus_conn_handler = conn_handler , datalink_handler = tapplus , show_server_messages = False )
@@ -78,7 +77,7 @@ def mock_querier_async():
78
77
conn_handler .set_response ("async/" + jobid + "/phase" , phase_response )
79
78
80
79
results_response = DummyResponse (200 )
81
- results_response .set_data (method = "GET" , body = job_data )
80
+ results_response .set_data (method = "GET" , body = JOB_DATA )
82
81
conn_handler .set_response ("async/" + jobid + "/results/result" , results_response )
83
82
84
83
return GaiaClass (tap_plus_conn_handler = conn_handler , datalink_handler = tapplus , show_server_messages = False )
@@ -104,42 +103,42 @@ def test_show_message():
104
103
105
104
def test_query_object (column_attrs , mock_querier ):
106
105
with pytest .raises (ValueError ) as err :
107
- mock_querier .query_object (skycoord )
106
+ mock_querier .query_object (SKYCOORD )
108
107
assert "Missing required argument: width" in err .value .args [0 ]
109
108
110
109
width = 12 * u .deg
111
110
112
111
with pytest .raises (ValueError ) as err :
113
- mock_querier .query_object (skycoord , width = width )
112
+ mock_querier .query_object (SKYCOORD , width = width )
114
113
assert "Missing required argument: height" in err .value .args [0 ]
115
114
116
- table = mock_querier .query_object (skycoord , width = width , height = 10 * u .deg )
115
+ table = mock_querier .query_object (SKYCOORD , width = width , height = 10 * u .deg )
117
116
assert len (table ) == 3
118
117
for colname , attrs in column_attrs .items ():
119
118
assert table [colname ].attrs_equal (attrs )
120
119
# by radius
121
- table = mock_querier .query_object (skycoord , radius = 1 * u .deg )
120
+ table = mock_querier .query_object (SKYCOORD , radius = 1 * u .deg )
122
121
assert len (table ) == 3
123
122
for colname , attrs in column_attrs .items ():
124
123
assert table [colname ].attrs_equal (attrs )
125
124
126
125
127
126
def test_query_object_async (column_attrs , mock_querier_async ):
128
127
table = mock_querier_async .query_object_async (
129
- skycoord , width = 12 * u .deg , height = 10 * u .deg
128
+ SKYCOORD , width = 12 * u .deg , height = 10 * u .deg
130
129
)
131
130
assert len (table ) == 3
132
131
for colname , attrs in column_attrs .items ():
133
132
assert table [colname ].attrs_equal (attrs )
134
133
# by radius
135
- table = mock_querier_async .query_object_async (skycoord , radius = 1 * u .deg )
134
+ table = mock_querier_async .query_object_async (SKYCOORD , radius = 1 * u .deg )
136
135
assert len (table ) == 3
137
136
for colname , attrs in column_attrs .items ():
138
137
assert table [colname ].attrs_equal (attrs )
139
138
140
139
141
140
def test_cone_search_sync (column_attrs , mock_querier ):
142
- job = mock_querier .cone_search (skycoord , radius = 1 * u .deg )
141
+ job = mock_querier .cone_search (SKYCOORD , radius = 1 * u .deg )
143
142
assert job .async_ is False
144
143
assert job .get_phase () == "COMPLETED"
145
144
assert job .failed is False
@@ -152,7 +151,7 @@ def test_cone_search_sync(column_attrs, mock_querier):
152
151
153
152
def test_cone_search_async (column_attrs , mock_querier_async ):
154
153
radius = 1.0 * u .deg
155
- job = mock_querier_async .cone_search_async (skycoord , radius = radius )
154
+ job = mock_querier_async .cone_search_async (SKYCOORD , radius = radius )
156
155
assert job .async_ is True
157
156
assert job .get_phase () == "COMPLETED"
158
157
assert job .failed is False
@@ -167,11 +166,11 @@ def test_cone_search_async(column_attrs, mock_querier_async):
167
166
# The preceding tests should have used the default value.
168
167
assert 'gaiadr3.gaia_source' in job .parameters ['query' ]
169
168
with conf .set_temp ("MAIN_GAIA_TABLE" , "name_from_conf" ):
170
- job = mock_querier_async .cone_search_async (skycoord , radius = radius )
169
+ job = mock_querier_async .cone_search_async (SKYCOORD , radius = radius )
171
170
assert "name_from_conf" in job .parameters ["query" ]
172
171
# Changing the value through the class should overrule conf.
173
172
mock_querier_async .MAIN_GAIA_TABLE = "name_from_class"
174
- job = mock_querier_async .cone_search_async (skycoord , radius = radius )
173
+ job = mock_querier_async .cone_search_async (SKYCOORD , radius = radius )
175
174
assert "name_from_class" in job .parameters ["query" ]
176
175
177
176
0 commit comments