def test_configuration_hci12(self, mock_peripheral): """Test adapter name pattern parsing.""" backend = BluepyBackend(adapter="hci12") backend.connect(TEST_MAC) mock_peripheral.assert_called_with(TEST_MAC, addrType="public", iface=12)
def test_configuration_default(self, mock_peripheral): """Test adapter name pattern parsing.""" backend = BluepyBackend() backend.connect(TEST_MAC) mock_peripheral.assert_called_with(TEST_MAC, addrType='public', iface=0)
def test_wait_for_notification(self, mock_peripheral): """Test writing to a handle successfully.""" backend = BluepyBackend() backend.connect(TEST_MAC) self.assertTrue(backend.wait_for_notification(0xFF, None, 10)) mock_peripheral.assert_called_with(TEST_MAC, addrType="public", iface=0)
def test_connect_exception(self, mock_peripheral): """Test exception wrapping.""" mock_peripheral.side_effect = BTLEException("Test") backend = BluepyBackend() with self.assertRaises(BluetoothBackendException): backend.connect(TEST_MAC)
def test_configuration_invalid(self, _): """Test adapter name pattern parsing.""" backend = BluepyBackend(adapter="somestring") with self.assertRaises(BluetoothBackendException): backend.connect(TEST_MAC)
def test_connect_exception(self, _): """Test exception wrapping.""" backend = BluepyBackend() with self.assertRaises(BluetoothBackendException): backend.connect(TEST_MAC)