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

Function test_middleware_mapping

python/pyarrow/tests/test_flight.py:2135–2176  ·  view source on GitHub ↗

Test that middleware records methods correctly.

()

Source from the content-addressed store, hash-verified

2133
2134
2135def 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
2179def 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