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

Function test_repr

python/pyarrow/tests/test_flight.py:926–1000  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

924
925
926def test_repr():
927 action_repr = "<pyarrow.flight.Action type='foo' body=(0 bytes)>"
928 action_type_repr = "ActionType(type='foo', description='bar')"
929 basic_auth_repr = "<pyarrow.flight.BasicAuth username=b'user' password=(redacted)>"
930 descriptor_repr = "<pyarrow.flight.FlightDescriptor cmd=b'foo'>"
931 endpoint_repr = ("<pyarrow.flight.FlightEndpoint "
932 "ticket=<pyarrow.flight.Ticket ticket=b'foo'> "
933 "locations=[] "
934 "expiration_time=2023-04-05 12:34:56+00:00 "
935 "app_metadata=b'endpoint app metadata'>")
936 info_repr = (
937 "<pyarrow.flight.FlightInfo "
938 "schema= "
939 "descriptor=<pyarrow.flight.FlightDescriptor path=[]> "
940 "endpoints=[] "
941 "total_records=1 "
942 "total_bytes=42 "
943 "ordered=True "
944 "app_metadata=b'test app metadata'>")
945 location_repr = "<pyarrow.flight.Location b'grpc+tcp://localhost:1234'>"
946 result_repr = "<pyarrow.flight.Result body=(3 bytes)>"
947 schema_result_repr = "<pyarrow.flight.SchemaResult schema=()>"
948 ticket_repr = "<pyarrow.flight.Ticket ticket=b'foo'>"
949
950 assert repr(flight.Action("foo", b"")) == action_repr
951 assert repr(flight.ActionType("foo", "bar")) == action_type_repr
952 assert repr(flight.BasicAuth("user", "pass")) == basic_auth_repr
953 assert repr(flight.FlightDescriptor.for_command("foo")) == descriptor_repr
954 endpoint = flight.FlightEndpoint(
955 b"foo", [], pa.scalar("2023-04-05T12:34:56").cast(pa.timestamp("s")),
956 b"endpoint app metadata"
957 )
958 assert repr(endpoint) == endpoint_repr
959 info = flight.FlightInfo(
960 pa.schema([]), flight.FlightDescriptor.for_path(), [],
961 1, 42, True, b"test app metadata"
962 )
963 assert repr(info) == info_repr
964 assert repr(flight.Location("grpc+tcp://localhost:1234")) == location_repr
965 assert repr(flight.Result(b"foo")) == result_repr
966 assert repr(flight.SchemaResult(pa.schema([]))) == schema_result_repr
967 assert repr(flight.SchemaResult(pa.schema([("int", "int64")]))) == \
968 "<pyarrow.flight.SchemaResult schema=(int: int64)>"
969 assert repr(flight.Ticket(b"foo")) == ticket_repr
970 assert info.schema == pa.schema([])
971
972 info = flight.FlightInfo(
973 None, flight.FlightDescriptor.for_path(), [],
974 1, 42, True, b"test app metadata"
975 )
976 info_repr = (
977 "<pyarrow.flight.FlightInfo "
978 "schema=None "
979 "descriptor=<pyarrow.flight.FlightDescriptor path=[]> "
980 "endpoints=[] "
981 "total_records=1 "
982 "total_bytes=42 "
983 "ordered=True "

Callers

nothing calls this directly

Calls 5

LocationMethod · 0.80
ResultMethod · 0.80
castMethod · 0.45
scalarMethod · 0.45
schemaMethod · 0.45

Tested by

no test coverage detected