@@ -41,10 +41,50 @@ def data_path(filename):
4141
4242class 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_server_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_server_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_server_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 )
87+ tap = GaiaClass (conn_handler , tapplus , show_server_messages = True )
4888 # Launch response: we use default response because the query contains
4989 # decimals
5090 response_launch_job = DummyResponse ()
@@ -125,7 +165,7 @@ def test_query_object(self):
125165 def test_query_object_async (self ):
126166 conn_handler = DummyConnHandler ()
127167 tapplus = TapPlus ("http://test:1111/tap" , connhandler = conn_handler )
128- tap = GaiaClass (conn_handler , tapplus )
168+ tap = GaiaClass (conn_handler , tapplus , show_server_messages = False )
129169 jobid = '12345'
130170 # Launch response
131171 response_launch_job = DummyResponse ()
@@ -220,7 +260,7 @@ def test_query_object_async(self):
220260 def test_cone_search_sync (self ):
221261 conn_handler = DummyConnHandler ()
222262 tapplus = TapPlus ("http://test:1111/tap" , connhandler = conn_handler )
223- tap = GaiaClass (conn_handler , tapplus )
263+ tap = GaiaClass (conn_handler , tapplus , show_server_messages = False )
224264 # Launch response: we use default response because the query contains
225265 # decimals
226266 response_launch_job = DummyResponse ()
@@ -273,7 +313,7 @@ def test_cone_search_sync(self):
273313 def test_cone_search_async (self ):
274314 conn_handler = DummyConnHandler ()
275315 tapplus = TapPlus ("http://test:1111/tap" , connhandler = conn_handler )
276- tap = GaiaClass (conn_handler , tapplus )
316+ tap = GaiaClass (conn_handler , tapplus , show_server_messages = False )
277317 jobid = '12345'
278318 # Launch response
279319 response_launch_job = DummyResponse ()
@@ -380,7 +420,7 @@ def __check_results_column(self, results, column_name, description, unit,
380420
381421 def test_load_data (self ):
382422 dummy_handler = DummyTapHandler ()
383- tap = GaiaClass (dummy_handler , dummy_handler )
423+ tap = GaiaClass (dummy_handler , dummy_handler , show_server_messages = False )
384424
385425 ids = "1,2,3,4"
386426 retrieval_type = "epoch_photometry"
@@ -419,7 +459,7 @@ def test_load_data(self):
419459
420460 def test_get_datalinks (self ):
421461 dummy_handler = DummyTapHandler ()
422- tap = GaiaClass (dummy_handler , dummy_handler )
462+ tap = GaiaClass (dummy_handler , dummy_handler , show_server_messages = False )
423463 ids = ["1" , "2" , "3" , "4" ]
424464 verbose = True
425465 parameters = {}
@@ -431,7 +471,7 @@ def test_get_datalinks(self):
431471 def test_xmatch (self ):
432472 conn_handler = DummyConnHandler ()
433473 tapplus = TapPlus ("http://test:1111/tap" , connhandler = conn_handler )
434- tap = GaiaClass (conn_handler , tapplus )
474+ tap = GaiaClass (conn_handler , tapplus , show_server_messages = False )
435475 jobid = '12345'
436476 # Launch response
437477 response_launch_job = DummyResponse ()
@@ -579,7 +619,7 @@ def test_xmatch(self):
579619 def test_login (self , mock_login ):
580620 conn_handler = DummyConnHandler ()
581621 tapplus = TapPlus ("http://test:1111/tap" , connhandler = conn_handler )
582- tap = GaiaClass (conn_handler , tapplus )
622+ tap = GaiaClass (conn_handler , tapplus , show_server_messages = False )
583623 tap .login ("user" , "password" )
584624 assert (mock_login .call_count == 2 )
585625 mock_login .side_effect = HTTPError ("Login error" )
@@ -591,7 +631,7 @@ def test_login(self, mock_login):
591631 def test_login_gui (self , mock_login_gui , mock_login ):
592632 conn_handler = DummyConnHandler ()
593633 tapplus = TapPlus ("http://test:1111/tap" , connhandler = conn_handler )
594- tap = GaiaClass (conn_handler , tapplus )
634+ tap = GaiaClass (conn_handler , tapplus , show_server_messages = False )
595635 tap .login_gui ()
596636 assert (mock_login_gui .call_count == 1 )
597637 mock_login_gui .side_effect = HTTPError ("Login error" )
@@ -602,7 +642,7 @@ def test_login_gui(self, mock_login_gui, mock_login):
602642 def test_logout (self , mock_logout ):
603643 conn_handler = DummyConnHandler ()
604644 tapplus = TapPlus ("http://test:1111/tap" , connhandler = conn_handler )
605- tap = GaiaClass (conn_handler , tapplus )
645+ tap = GaiaClass (conn_handler , tapplus , show_server_messages = False )
606646 tap .logout ()
607647 assert (mock_logout .call_count == 2 )
608648 mock_logout .side_effect = HTTPError ("Login error" )
0 commit comments