コード例 #1
0
 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)
コード例 #2
0
 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)
コード例 #3
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)
コード例 #4
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)
コード例 #5
0
 def test_configuration_invalid(self, _):
     """Test adapter name pattern parsing."""
     backend = BluepyBackend(adapter="somestring")
     with self.assertRaises(BluetoothBackendException):
         backend.connect(TEST_MAC)
コード例 #6
0
ファイル: test_bluepy.py プロジェクト: ratcashdev/btlewrap
 def test_connect_exception(self, _):
     """Test exception wrapping."""
     backend = BluepyBackend()
     with self.assertRaises(BluetoothBackendException):
         backend.connect(TEST_MAC)