Skip to content

MockConfluentMessage

faststream.confluent.testing.MockConfluentMessage #

MockConfluentMessage(
    raw_msg: bytes | None,
    topic: str,
    key: bytes | str,
    headers: Sequence[tuple[str, str | bytes | None]],
    offset: int,
    partition: int,
    timestamp_type: int,
    timestamp_ms: int,
    error: KafkaError | None = None,
)

Bases: Message

The message the in-memory broker delivers, answering as the client's does.

Source code in faststream/confluent/testing.py
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
def __init__(
    self,
    raw_msg: bytes | None,
    topic: str,
    key: bytes | str,
    headers: Sequence[tuple[str, str | bytes | None]],
    offset: int,
    partition: int,
    timestamp_type: int,
    timestamp_ms: int,
    error: KafkaError | None = None,
) -> None:
    self._raw_msg = raw_msg
    self._topic = topic

    if isinstance(key, str):
        self._key = key.encode()
    else:
        self._key = key

    self._headers = list(headers)
    self._error = error
    self._offset = offset
    self._partition = partition
    self._timestamp = (timestamp_type, timestamp_ms)

len #

len() -> int
Source code in faststream/confluent/testing.py
324
325
def len(self) -> int:
    return 0 if self._raw_msg is None else len(self._raw_msg)

error #

error() -> KafkaError | None
Source code in faststream/confluent/testing.py
331
332
def error(self) -> KafkaError | None:
    return self._error

headers #

headers() -> list[tuple[str, str | bytes | None]]
Source code in faststream/confluent/testing.py
334
335
def headers(self) -> list[tuple[str, str | bytes | None]]:
    return self._headers

key #

key() -> bytes
Source code in faststream/confluent/testing.py
337
338
def key(self) -> bytes:
    return self._key

offset #

offset() -> int
Source code in faststream/confluent/testing.py
340
341
def offset(self) -> int:
    return self._offset

partition #

partition() -> int
Source code in faststream/confluent/testing.py
343
344
def partition(self) -> int:
    return self._partition

timestamp #

timestamp() -> tuple[int, int]
Source code in faststream/confluent/testing.py
346
347
def timestamp(self) -> tuple[int, int]:
    return self._timestamp

topic #

topic() -> str
Source code in faststream/confluent/testing.py
349
350
def topic(self) -> str:
    return self._topic

value #

value() -> bytes | None
Source code in faststream/confluent/testing.py
352
353
def value(self) -> bytes | None:
    return self._raw_msg