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