Test that middleware records methods correctly.
()
| 2171 | |
| 2172 | |
| 2173 | def test_middleware_mapping(): |
| 2174 | """Test that middleware records methods correctly.""" |
| 2175 | server_middleware = RecordingServerMiddlewareFactory() |
| 2176 | client_middleware = RecordingClientMiddlewareFactory() |
| 2177 | with FlightServerBase(middleware={"test": server_middleware}) as server, \ |
| 2178 | FlightClient( |
| 2179 | ('localhost', server.port), |
| 2180 | middleware=[client_middleware] |
| 2181 | ) as client: |
| 2182 | |
| 2183 | descriptor = flight.FlightDescriptor.for_command(b"") |
| 2184 | with pytest.raises(NotImplementedError): |
| 2185 | list(client.list_flights()) |
| 2186 | with pytest.raises(NotImplementedError): |
| 2187 | client.get_flight_info(descriptor) |
| 2188 | with pytest.raises(NotImplementedError): |
| 2189 | client.get_schema(descriptor) |
| 2190 | with pytest.raises(NotImplementedError): |
| 2191 | client.do_get(flight.Ticket(b"")) |
| 2192 | with pytest.raises(NotImplementedError): |
| 2193 | writer, _ = client.do_put(descriptor, pa.schema([])) |
| 2194 | writer.close() |
| 2195 | with pytest.raises(NotImplementedError): |
| 2196 | list(client.do_action(flight.Action(b"", b""))) |
| 2197 | with pytest.raises(NotImplementedError): |
| 2198 | list(client.list_actions()) |
| 2199 | with pytest.raises(NotImplementedError): |
| 2200 | writer, _ = client.do_exchange(descriptor) |
| 2201 | writer.close() |
| 2202 | |
| 2203 | expected = [ |
| 2204 | flight.FlightMethod.LIST_FLIGHTS, |
| 2205 | flight.FlightMethod.GET_FLIGHT_INFO, |
| 2206 | flight.FlightMethod.GET_SCHEMA, |
| 2207 | flight.FlightMethod.DO_GET, |
| 2208 | flight.FlightMethod.DO_PUT, |
| 2209 | flight.FlightMethod.DO_ACTION, |
| 2210 | flight.FlightMethod.LIST_ACTIONS, |
| 2211 | flight.FlightMethod.DO_EXCHANGE, |
| 2212 | ] |
| 2213 | assert server_middleware.methods == expected |
| 2214 | assert client_middleware.methods == expected |
| 2215 | |
| 2216 | |
| 2217 | def test_extra_info(): |
nothing calls this directly
no test coverage detected