Mock API¶
Blue Dot also contains a useful mock API for simulating Blue Dot and
bluetooth comms. This is useful for testing and allows for prototyping
without having to use a Blue Dot client.
MockBlueDot¶
-
class
bluedot.mock.MockBlueDot(device='hci0', port=1, auto_start_server=True, power_up_device=False, print_messages=True, cols=1, rows=1)[source]¶ MockBlueDotinherits fromBlueDotbut overrides_create_server(), to create aMockBluetoothServerwhich can be used for testing and debugging.-
launch_mock_app()[source]¶ Launches a mock Blue Dot app.
The mock app reacts to mouse clicks and movement and calls the mock blue dot methods to simulates presses.
This is useful for testing, allowing you to interact with Blue Dot without having to script mock functions.
The mock app uses pygame which will need to be installed.
-
MockBluetoothServer¶
-
class
bluedot.mock.MockBluetoothServer(data_received_callback, auto_start=True, device='mock0', port=1, encoding='utf-8', power_up_device=False, when_client_connects=None, when_client_disconnects=None)[source]¶ MockBluetoothServerinherits fromBluetoothServerbut overrides__init__,start(),stop()andsend_raw()to create aMockBluetoothServerwhich can be used for testing and debugging.-
mock_client_connected(mock_client=None)[source]¶ Simulates a client connected to the
BluetoothServer.Parameters: mock_client (MockBluetoothClient) – The mock client to interact with, defaults to None. If None, client address is set to ‘99:99:99:99:99:99’
-
mock_client_disconnected()[source]¶ Simulates a client disconnecting from the
BluetoothServer.
-
mock_client_sending_data(data)[source]¶ Simulates a client sending data to the
BluetoothServer.
-
MockBluetoothClient¶
-
class
bluedot.mock.MockBluetoothClient(server, data_received_callback, port=1, device='mock1', encoding='utf-8', power_up_device=False, auto_connect=True)[source]¶ MockBluetoothClientinherits fromBluetoothClientbut overrides__init__,connect()andsend_raw()to create aMockBluetoothServerwhich can be used for testing and debugging.Note - the server parameter should be an instance of
MockBluetoothServer.-
mock_server_sending_data(data)[source]¶ Simulates a server sending data to the
BluetoothClient.
-