@@ -41,10 +41,50 @@ def data_path(filename):
41
41
42
42
class TestTap :
43
43
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
+
44
66
def test_query_object (self ):
45
67
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
+
46
86
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 )
48
88
# Launch response: we use default response because the query contains
49
89
# decimals
50
90
response_launch_job = DummyResponse ()
@@ -125,7 +165,7 @@ def test_query_object(self):
125
165
def test_query_object_async (self ):
126
166
conn_handler = DummyConnHandler ()
127
167
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 )
129
169
jobid = '12345'
130
170
# Launch response
131
171
response_launch_job = DummyResponse ()
@@ -220,7 +260,7 @@ def test_query_object_async(self):
220
260
def test_cone_search_sync (self ):
221
261
conn_handler = DummyConnHandler ()
222
262
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 )
224
264
# Launch response: we use default response because the query contains
225
265
# decimals
226
266
response_launch_job = DummyResponse ()
@@ -273,7 +313,7 @@ def test_cone_search_sync(self):
273
313
def test_cone_search_async (self ):
274
314
conn_handler = DummyConnHandler ()
275
315
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 )
277
317
jobid = '12345'
278
318
# Launch response
279
319
response_launch_job = DummyResponse ()
@@ -380,7 +420,7 @@ def __check_results_column(self, results, column_name, description, unit,
380
420
381
421
def test_load_data (self ):
382
422
dummy_handler = DummyTapHandler ()
383
- tap = GaiaClass (dummy_handler , dummy_handler )
423
+ tap = GaiaClass (dummy_handler , dummy_handler , show_server_messages = False )
384
424
385
425
ids = "1,2,3,4"
386
426
retrieval_type = "epoch_photometry"
@@ -419,7 +459,7 @@ def test_load_data(self):
419
459
420
460
def test_get_datalinks (self ):
421
461
dummy_handler = DummyTapHandler ()
422
- tap = GaiaClass (dummy_handler , dummy_handler )
462
+ tap = GaiaClass (dummy_handler , dummy_handler , show_server_messages = False )
423
463
ids = ["1" , "2" , "3" , "4" ]
424
464
verbose = True
425
465
parameters = {}
@@ -431,7 +471,7 @@ def test_get_datalinks(self):
431
471
def test_xmatch (self ):
432
472
conn_handler = DummyConnHandler ()
433
473
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 )
435
475
jobid = '12345'
436
476
# Launch response
437
477
response_launch_job = DummyResponse ()
@@ -579,7 +619,7 @@ def test_xmatch(self):
579
619
def test_login (self , mock_login ):
580
620
conn_handler = DummyConnHandler ()
581
621
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 )
583
623
tap .login ("user" , "password" )
584
624
assert (mock_login .call_count == 2 )
585
625
mock_login .side_effect = HTTPError ("Login error" )
@@ -591,7 +631,7 @@ def test_login(self, mock_login):
591
631
def test_login_gui (self , mock_login_gui , mock_login ):
592
632
conn_handler = DummyConnHandler ()
593
633
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 )
595
635
tap .login_gui ()
596
636
assert (mock_login_gui .call_count == 1 )
597
637
mock_login_gui .side_effect = HTTPError ("Login error" )
@@ -602,7 +642,7 @@ def test_login_gui(self, mock_login_gui, mock_login):
602
642
def test_logout (self , mock_logout ):
603
643
conn_handler = DummyConnHandler ()
604
644
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 )
606
646
tap .logout ()
607
647
assert (mock_logout .call_count == 2 )
608
648
mock_logout .side_effect = HTTPError ("Login error" )
0 commit comments