File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed
Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -162,7 +162,7 @@ def init():
162162 def stop_server ():
163163 if GraphServer ._server :
164164 GraphServer ._server .shutdown ()
165- print ("Spanner Graph Notebook shutting down..." )
165+ print ("BigQuery-magics graph server shutting down..." )
166166
167167 @staticmethod
168168 def get_ping ():
Original file line number Diff line number Diff line change 1313# limitations under the License.
1414
1515import json
16-
1716import pytest
17+ import unittest
1818
1919try :
2020 import spanner_graphs .graph_visualization as graph_visualization
2121except ImportError :
2222 graph_visualization = None
2323
24- from bigquery_magics .graph_server import convert_graph_data
24+ from bigquery_magics .graph_server import convert_graph_data , GraphServer
2525
2626alex_properties = {
2727 "birthday" : "1991-12-21T08:00:00Z" ,
@@ -214,3 +214,22 @@ def test_convert_nongraph_json():
214214 assert result ["response" ]["query_result" ] == {"result" : [{"foo" : 1 , "bar" : 2 }]}
215215 assert result ["response" ]["rows" ] == [[{"foo" : 1 , "bar" : 2 }]]
216216 assert result ["response" ]["schema" ] is None
217+
218+
219+ class TestGraphServer (unittest .TestCase ):
220+ def setUp (self ):
221+ self .server_thread = GraphServer .init ()
222+
223+ def tearDown (self ):
224+ GraphServer .stop_server () # Stop the server after each test
225+ self .server_thread .join () # Wait for the thread to finish
226+
227+ def test_ping (self ):
228+ self .assertTrue (self .server_thread .is_alive ())
229+
230+ response = GraphServer .get_ping ()
231+ self .assertEqual (response , {"message" : "pong" })
232+
233+ request = {"data" : "ping" }
234+ response = GraphServer .post_ping (request )
235+ self .assertEqual (response , {"your_request" : request })
You can’t perform that action at this time.
0 commit comments