def test_get_image_source_unknown_and_known_camera(): image_response_unknown = image_protos.ImageResponse( status=image_protos.ImageResponse.STATUS_UNKNOWN_CAMERA) image_response_ok = image_protos.ImageResponse(status=image_protos.ImageResponse.STATUS_OK) client, service, server = _setup(expected_image_sources=['foo', 'bar'], image_responses=[image_response_ok, image_response_unknown]) with pytest.raises(bosdyn.client.image.UnknownImageSourceError): res = client.get_image_from_sources(image_sources=['foo', 'bar'])
def test_get_image_source_data_error(): image_response = image_protos.ImageResponse( status=image_protos.ImageResponse.STATUS_IMAGE_DATA_ERROR) client, service, server = _setup(expected_image_sources=['foo'], image_responses=[image_response]) with pytest.raises(bosdyn.client.image.ImageDataError): res = client.get_image_from_sources(image_sources=['foo'])
def test_get_image_source_unset_async(): image_response = image_protos.ImageResponse() client, service, server = _setup(expected_image_sources=['foo'], image_responses=[image_response]) fut = client.get_image_from_sources_async(image_sources=['foo']) with pytest.raises(bosdyn.client.exceptions.UnsetStatusError): res = fut.result()
def test_get_image_source_async_ok(): image_response = image_protos.ImageResponse( status=image_protos.ImageResponse.STATUS_OK) client, service, server = _setup(expected_image_sources=['foo'], image_responses=[image_response]) fut = client.get_image_from_sources_async(image_sources=['foo']) assert 1 == len(fut.result())
def copy_image_response_and_strip_bytes(proto): """Makes a copy of the protobuf message and strip the bytes data. This is such that bytes fields can be stripped for logging, without modifying the main proto. Args: proto (image_pb2.ImageResponse): The proto to copy and remove the image data from. Returns: The copied, stripped image response proto. """ copied_image_data = image_pb2.ImageResponse() copied_image_data.CopyFrom(proto) strip_image_response(copied_image_data) return copied_image_data