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

Function test_roundtrip_errors

python/pyarrow/tests/test_flight.py:2062–2097  ·  view source on GitHub ↗

Ensure that Flight errors propagate from server to client.

()

Source from the content-addressed store, hash-verified

2060
2061
2062def test_roundtrip_errors():
2063 """Ensure that Flight errors propagate from server to client."""
2064 with ErrorFlightServer() as server, \
2065 FlightClient(('localhost', server.port)) as client:
2066
2067 for arg, exc_type in ErrorFlightServer.error_cases().items():
2068 with pytest.raises(exc_type, match=".*foo.*"):
2069 list(client.do_action(flight.Action(arg, b"")))
2070 with pytest.raises(flight.FlightInternalError, match=".*foo.*"):
2071 list(client.list_flights())
2072
2073 data = [pa.array([-10, -5, 0, 5, 10])]
2074 table = pa.Table.from_arrays(data, names=['a'])
2075
2076 exceptions = {
2077 'internal': flight.FlightInternalError,
2078 'timedout': flight.FlightTimedOutError,
2079 'cancel': flight.FlightCancelledError,
2080 'unauthenticated': flight.FlightUnauthenticatedError,
2081 'unauthorized': flight.FlightUnauthorizedError,
2082 }
2083
2084 for command, exception in exceptions.items():
2085
2086 with pytest.raises(exception, match=".*foo.*"):
2087 writer, reader = client.do_put(
2088 flight.FlightDescriptor.for_command(command),
2089 table.schema)
2090 writer.write_table(table)
2091 writer.close()
2092
2093 with pytest.raises(exception, match=".*foo.*"):
2094 writer, reader = client.do_put(
2095 flight.FlightDescriptor.for_command(command),
2096 table.schema)
2097 writer.close()
2098
2099
2100def 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