raydriver.core.transport
MockTransport
An in-memory byte transport for tests.
Feed bytes to the session with push() (as if the device had sent them), inspect everything the
session sent with sent(), and simulate link state with set_connected() / set_write_error().
is_connected
is_connected: bool
True while the transport link is open (i.e. a session connected through this mock).
clear_sent()
clear_sent() -> None
Clear the recorded sent bytes.
| Parameter | Type | Description |
|---|---|---|
| Returns | None |
push()
push(data: Sequence[int]) -> None
Deliver bytes to the session as if the device sent them.
| Parameter | Type | Description |
|---|---|---|
data | Sequence[int] | |
| Returns | None |
sent()
sent() -> list[bytes]
All bytes written to the device so far.
| Parameter | Type | Description |
|---|---|---|
| Returns | list[bytes] |
set_connected()
set_connected(connected: bool) -> None
Simulate connect/disconnect of the physical link.
| Parameter | Type | Description |
|---|---|---|
connected | bool | |
| Returns | None |
set_write_error()
set_write_error(message: Optional[str] = None) -> None
Fail subsequent writes with this message (and mark the link down), simulating an unplugged cable.
| Parameter | Type | Description |
|---|---|---|
message | Optional[str] = None | |
| Returns | None |
take_new_sent()
take_new_sent() -> list[bytes]
Writes recorded since the previous call (or the last clear_sent): a monotonic cursor, so clearing
the log never skips or replays chunks. This is what device emulators should consume.
| Parameter | Type | Description |
|---|---|---|
| Returns | list[bytes] |