Exemplo n.º 1
0
    def test_iter_tile_errors(self, stub):
        start_datetime = datetime.datetime.utcnow()
        session_id = "bar"
        errors = [
            xyz_pb2.XYZError(session_id=session_id),
            xyz_pb2.XYZError(session_id=session_id),
        ]

        xyz = XYZ.build(utils.Foo(1), name="foo", description="a foo")

        stub.return_value.GetXYZSessionErrors.return_value = errors

        assert (list(
            xyz.iter_tile_errors(session_id=session_id,
                                 start_datetime=start_datetime)) == errors)

        stub.return_value.GetXYZSessionErrors.assert_called_once_with(
            xyz_pb2.GetXYZSessionErrorsRequest(
                session_id=session_id,
                start_timestamp=pb_datetime_to_milliseconds(start_datetime),
                xyz_id=xyz.id,
            ),
            timeout=Client.STREAM_TIMEOUT,
            metadata=(("x-wf-channel", _channel.__channel__), ),
        )
Exemplo n.º 2
0
def _tile_error_stream(xyz_id, session_id, start_datetime=None, client=None):
    if client is None:
        client = get_global_grpc_client()

    if start_datetime is None:
        start_timestamp = 0
    else:
        start_timestamp = pb_datetime_to_milliseconds(start_datetime)

    msg = xyz_pb2.GetXYZSessionErrorsRequest(
        session_id=session_id, xyz_id=xyz_id, start_timestamp=start_timestamp
    )

    return client.api["GetXYZSessionErrors"](msg, timeout=client.STREAM_TIMEOUT)