tikal.mock package

Submodules

tikal.mock.mock_lovense module

Private Mock: Used to simulate Lovense Devices for testing.

class tikal.mock.mock_lovense.MockBLEDevice(name: str, address: str)[source]

Bases: object

Mock a BLE device that simulates discovered toys

class tikal.mock.mock_lovense.MockBehavior(*values)[source]

Bases: Enum

Defines different toy simulation behaviors for testing

CONNECTION_FAILURE = 'connection_failure'
NORMAL = 'normal'
POWER_OFF = 'power_off'
class tikal.mock.mock_lovense.MockBleakClient(device: MockBLEDevice, disconnected_callback: Callable[[Any], Any])[source]

Bases: object

Mock BLE client that simulates Lovense toy communication.

Supports different behaviors based on device name: - Normal operation: Responds to all commands - connection_failure: Stops responding 5s after the first intensity command - POWEROFF: Sends POWEROFF and disconnects 5s after the first intensity command

async connect() None[source]

Simulate connection to the toy

async disconnect() None[source]

Simulate disconnection

property is_connected: bool

Check connection status

static is_intensity_command(command: str) bool[source]

Check if the command is an intensity command

property services: list[MockService]

Return mock GATT services

async start_notify(_: str, callback: Callable[[int, bytes], None]) None[source]

Start notifications on a characteristic

async stop_notify(_: str) None[source]

Stop notifications on a characteristic

async write_gatt_char(_: str, data: bytes, response: bool = True) None[source]

Simulate writing to a GATT characteristic (sending commands to the toy). Processes commands and triggers appropriate responses via notification callback.

class tikal.mock.mock_lovense.MockBleakScanner(detection_callback: Callable[[MockBLEDevice, Any], None] | None = None)[source]

Bases: object

Mock BLE scanner that returns predefined toy configurations.

Tracks connected devices globally to simulate real Bluetooth behavior where connected devices stop advertising and don’t appear in scan results.

async static discover(timeout: float) list[MockBLEDevice][source]

One-shot discovery: returns a list of mock devices that are not currently connected.

Parameters:

timeout – Simulated scan duration (ignored except for a small delay).

Returns:

List of MockBLEDevice objects for non-connected toys.

classmethod register_connection(address: str) None[source]

Register a device as connected (will be excluded from scan results)

classmethod reset() None[source]

Reset all connection tracking (useful for tests)

async start() None[source]

Start continuous scanning.

Raises:

RuntimeError – If already scanning or no detection callback was provided.

async stop() None[source]

Stop continuous scanning.

classmethod unregister_connection(address: str) None[source]

Unregister a device as connected (will appear in scan results again)

class tikal.mock.mock_lovense.MockCharacteristic(uuid: str)[source]

Bases: object

Mock GATT characteristic that matches bleak’s BleakGATTCharacteristic interface

class tikal.mock.mock_lovense.MockService(uuid: str, characteristics: list[MockCharacteristic])[source]

Bases: object

Mock GATT service that matches bleak’s BleakGATTService interface

Module contents

class tikal.mock.MockBleakClient(device: MockBLEDevice, disconnected_callback: Callable[[Any], Any])[source]

Bases: object

Mock BLE client that simulates Lovense toy communication.

Supports different behaviors based on device name: - Normal operation: Responds to all commands - connection_failure: Stops responding 5s after the first intensity command - POWEROFF: Sends POWEROFF and disconnects 5s after the first intensity command

async connect() None[source]

Simulate connection to the toy

async disconnect() None[source]

Simulate disconnection

property is_connected: bool

Check connection status

static is_intensity_command(command: str) bool[source]

Check if the command is an intensity command

property services: list[MockService]

Return mock GATT services

async start_notify(_: str, callback: Callable[[int, bytes], None]) None[source]

Start notifications on a characteristic

async stop_notify(_: str) None[source]

Stop notifications on a characteristic

async write_gatt_char(_: str, data: bytes, response: bool = True) None[source]

Simulate writing to a GATT characteristic (sending commands to the toy). Processes commands and triggers appropriate responses via notification callback.

class tikal.mock.MockBleakScanner(detection_callback: Callable[[MockBLEDevice, Any], None] | None = None)[source]

Bases: object

Mock BLE scanner that returns predefined toy configurations.

Tracks connected devices globally to simulate real Bluetooth behavior where connected devices stop advertising and don’t appear in scan results.

async static discover(timeout: float) list[MockBLEDevice][source]

One-shot discovery: returns a list of mock devices that are not currently connected.

Parameters:

timeout – Simulated scan duration (ignored except for a small delay).

Returns:

List of MockBLEDevice objects for non-connected toys.

classmethod register_connection(address: str) None[source]

Register a device as connected (will be excluded from scan results)

classmethod reset() None[source]

Reset all connection tracking (useful for tests)

async start() None[source]

Start continuous scanning.

Raises:

RuntimeError – If already scanning or no detection callback was provided.

async stop() None[source]

Stop continuous scanning.

classmethod unregister_connection(address: str) None[source]

Unregister a device as connected (will appear in scan results again)