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

Function test_middleware_mapping

python/pyarrow/tests/test_flight.py:2173–2214  ·  view source on GitHub ↗

Test that middleware records methods correctly.

()

Source from the content-addressed store, hash-verified

2171
2172
2173def 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
2217def test_extra_info():

Callers

nothing calls this directly

Calls 15

FlightServerBaseClass · 0.90
FlightClientClass · 0.90
listFunction · 0.85
get_schemaMethod · 0.80
list_flightsMethod · 0.45
get_flight_infoMethod · 0.45
do_getMethod · 0.45
do_putMethod · 0.45
schemaMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected