Test that middleware records methods correctly.
()
| 2133 | |
| 2134 | |
| 2135 | def test_middleware_mapping(): |
| 2136 | """Test that middleware records methods correctly.""" |
| 2137 | server_middleware = RecordingServerMiddlewareFactory() |
| 2138 | client_middleware = RecordingClientMiddlewareFactory() |
| 2139 | with FlightServerBase(middleware={"test": server_middleware}) as server, \ |
| 2140 | FlightClient( |
| 2141 | ('localhost', server.port), |
| 2142 | middleware=[client_middleware] |
| 2143 | ) as client: |
| 2144 | |
| 2145 | descriptor = flight.FlightDescriptor.for_command(b"") |
| 2146 | with pytest.raises(NotImplementedError): |
| 2147 | list(client.list_flights()) |
| 2148 | with pytest.raises(NotImplementedError): |
| 2149 | client.get_flight_info(descriptor) |
| 2150 | with pytest.raises(NotImplementedError): |
| 2151 | client.get_schema(descriptor) |
| 2152 | with pytest.raises(NotImplementedError): |
| 2153 | client.do_get(flight.Ticket(b"")) |
| 2154 | with pytest.raises(NotImplementedError): |
| 2155 | writer, _ = client.do_put(descriptor, pa.schema([])) |
| 2156 | writer.close() |
| 2157 | with pytest.raises(NotImplementedError): |
| 2158 | list(client.do_action(flight.Action(b"", b""))) |
| 2159 | with pytest.raises(NotImplementedError): |
| 2160 | list(client.list_actions()) |
| 2161 | with pytest.raises(NotImplementedError): |
| 2162 | writer, _ = client.do_exchange(descriptor) |
| 2163 | writer.close() |
| 2164 | |
| 2165 | expected = [ |
| 2166 | flight.FlightMethod.LIST_FLIGHTS, |
| 2167 | flight.FlightMethod.GET_FLIGHT_INFO, |
| 2168 | flight.FlightMethod.GET_SCHEMA, |
| 2169 | flight.FlightMethod.DO_GET, |
| 2170 | flight.FlightMethod.DO_PUT, |
| 2171 | flight.FlightMethod.DO_ACTION, |
| 2172 | flight.FlightMethod.LIST_ACTIONS, |
| 2173 | flight.FlightMethod.DO_EXCHANGE, |
| 2174 | ] |
| 2175 | assert server_middleware.methods == expected |
| 2176 | assert client_middleware.methods == expected |
| 2177 | |
| 2178 | |
| 2179 | def test_extra_info(): |
nothing calls this directly
no test coverage detected