Skip to content

Commit 5d25430

Browse files
mhsarmientobsipocz
authored andcommitted
Implement comments to PR #2376
1 parent 62fc989 commit 5d25430

File tree

2 files changed

+51
-6
lines changed

2 files changed

+51
-6
lines changed

astroquery/gaia/core.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
from astropy import units as u
3434
import warnings
3535
from astroquery.exceptions import InputWarning
36+
from collections.abc import Iterable
3637

3738

3839
class GaiaClass(TapPlus):
@@ -925,10 +926,14 @@ def get_status_messages(self):
925926
connHandler = self._TapPlus__getconnhandler()
926927
response = connHandler.execute_tapget(subContext, False)
927928
if response.status == 200:
928-
for line in response:
929-
string_message = line.decode("utf-8")
930-
print(string_message[string_message.index('=') + 1:])
931-
except OSError as e:
929+
if isinstance(response, Iterable):
930+
for line in response:
931+
try:
932+
print(line.decode("utf-8").split('=', 1)[1])
933+
except ValueError as e:
934+
print(e)
935+
pass
936+
except OSError:
932937
print("Status messages could not be retrieved")
933938

934939

astroquery/gaia/tests/test_gaiatap.py

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,50 @@ def data_path(filename):
4141

4242
class TestTap:
4343

44+
def test_show_message(self):
45+
connHandler = DummyConnHandler()
46+
47+
dummy_response = DummyResponse()
48+
dummy_response.set_status_code(200)
49+
dummy_response.set_message("OK")
50+
51+
message_text = "1653401204784D[type: -100,-1]=Gaia dev is under maintenance"
52+
53+
dummy_response.set_data(method='GET',
54+
context=None,
55+
body=message_text,
56+
headers=None)
57+
connHandler.set_default_response(dummy_response)
58+
59+
# show_messages
60+
tableRequest = 'notification?action=GetNotifications'
61+
connHandler.set_response(tableRequest, dummy_response)
62+
63+
tapplus = TapPlus("http://test:1111/tap", connhandler=connHandler)
64+
tap = GaiaClass(connHandler, tapplus, show_messages=True)
65+
4466
def test_query_object(self):
4567
conn_handler = DummyConnHandler()
68+
# Launch response: we use default response because the query contains
69+
# decimals
70+
dummy_response = DummyResponse()
71+
dummy_response.set_status_code(200)
72+
dummy_response.set_message("OK")
73+
74+
message_text = "1653401204784D[type: -100,-1]=Gaia dev is under maintenance"
75+
76+
dummy_response.set_data(method='GET',
77+
context=None,
78+
body=message_text,
79+
headers=None)
80+
conn_handler.set_default_response(dummy_response)
81+
82+
# show_messages
83+
tableRequest = 'notification?action=GetNotifications'
84+
conn_handler.set_response(tableRequest, dummy_response)
85+
4686
tapplus = TapPlus("http://test:1111/tap", connhandler=conn_handler)
47-
tap = GaiaClass(conn_handler, tapplus, show_messages=False)
87+
tap = GaiaClass(conn_handler, tapplus, show_messages=True)
4888
# Launch response: we use default response because the query contains
4989
# decimals
5090
response_launch_job = DummyResponse()
@@ -395,7 +435,7 @@ def test_load_data(self):
395435
output_file = os.path.abspath(path_to_end_with)
396436

397437
params_dict = {}
398-
params_dict['VALID_DATA'] = "false"
438+
params_dict['VALID_DATA'] = "true"
399439
params_dict['ID'] = ids
400440
params_dict['FORMAT'] = str(format)
401441
params_dict['RETRIEVAL_TYPE'] = str(retrieval_type)

0 commit comments

Comments
 (0)