ARROW-5398: [Python] Fix Flight tests

Also improve the example a bit.
This commit is contained in:
Antoine Pitrou committed 2019-05-23 10:02:24 +02:00
1 parent 522ed106fe
commit a15313f600
2 files changed
+9 -8

No files matched your search

+5 -1
View File
@@ -87,11 +87,15 @@ class FlightServer(pyarrow.flight.FlightServerBase):
if action.type == "clear":
raise NotImplementedError(
"{} is not implemented.".format(action.type))
else:
elif action.type == "healthcheck":
pass
elif action.type == "shutdown":
yield pyarrow.flight.Result(pyarrow.py_buffer(b'Shutdown!'))
# Shut down on background thread to avoid blocking current
# request
threading.Thread(target=self._shutdown).start()
else:
raise KeyError(f"Unknown action {action.type!r}")
def _shutdown(self):
"""Shut down after a delay."""
+4 -7
View File
@@ -276,8 +276,8 @@ def test_flight_do_get_ints():
"""Try a simple do_get call."""
table = simple_ints_table()
with flight_server(ConstantFlightServer) as server_port:
client = flight.FlightClient.connect('localhost', server_port)
with flight_server(ConstantFlightServer) as server_location:
client = flight.FlightClient.connect(server_location)
data = client.do_get(flight.Ticket(b'ints')).read_all()
assert data.equals(table)
@@ -321,10 +321,7 @@ def test_flight_get_info():
def test_flight_domain_socket():
"""Try a simple do_get call over a domain socket."""
data = [
pa.array([-10, -5, 0, 5, 10])
]
table = pa.Table.from_arrays(data, names=['a'])
table = simple_ints_table()
with tempfile.NamedTemporaryFile() as sock:
sock.close()
@@ -332,7 +329,7 @@ def test_flight_domain_socket():
with flight_server(ConstantFlightServer,
location=location) as server_location:
client = flight.FlightClient.connect(server_location)
data = client.do_get(flight.Ticket(b'')).read_all()
data = client.do_get(flight.Ticket(b'ints')).read_all()
assert data.equals(table)