MCPcopy Create free account
hub / github.com/apache/arrow / test_roundtrip_errors

Function test_roundtrip_errors

python/pyarrow/tests/test_flight.py:2024–2059  ·  view source on GitHub ↗

Ensure that Flight errors propagate from server to client.

()

Source from the content-addressed store, hash-verified

2022
2023
2024def test_roundtrip_errors():
2025 """Ensure that Flight errors propagate from server to client."""
2026 with ErrorFlightServer() as server, \
2027 FlightClient(('localhost', server.port)) as client:
2028
2029 for arg, exc_type in ErrorFlightServer.error_cases().items():
2030 with pytest.raises(exc_type, match=".*foo.*"):
2031 list(client.do_action(flight.Action(arg, b"")))
2032 with pytest.raises(flight.FlightInternalError, match=".*foo.*"):
2033 list(client.list_flights())
2034
2035 data = [pa.array([-10, -5, 0, 5, 10])]
2036 table = pa.Table.from_arrays(data, names=['a'])
2037
2038 exceptions = {
2039 'internal': flight.FlightInternalError,
2040 'timedout': flight.FlightTimedOutError,
2041 'cancel': flight.FlightCancelledError,
2042 'unauthenticated': flight.FlightUnauthenticatedError,
2043 'unauthorized': flight.FlightUnauthorizedError,
2044 }
2045
2046 for command, exception in exceptions.items():
2047
2048 with pytest.raises(exception, match=".*foo.*"):
2049 writer, reader = client.do_put(
2050 flight.FlightDescriptor.for_command(command),
2051 table.schema)
2052 writer.write_table(table)
2053 writer.close()
2054
2055 with pytest.raises(exception, match=".*foo.*"):
2056 writer, reader = client.do_put(
2057 flight.FlightDescriptor.for_command(command),
2058 table.schema)
2059 writer.close()
2060
2061
2062def test_do_put_independent_read_write():

Callers

nothing calls this directly

Calls 10

FlightClientClass · 0.90
ErrorFlightServerClass · 0.85
listFunction · 0.85
error_casesMethod · 0.80
do_actionMethod · 0.45
list_flightsMethod · 0.45
arrayMethod · 0.45
do_putMethod · 0.45
write_tableMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected