Ensure that Flight errors propagate from server to client.
()
| 2060 | |
| 2061 | |
| 2062 | def 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 | |
| 2100 | def test_do_put_independent_read_write(): |
nothing calls this directly
no test coverage detected