Esempio n. 1
0
    def test_scan(self):
        """Test scanning for devices.

        Note: fore the test to pass, there must be at least one BTLE device
        near by.
        """
        devices = BluepyBackend.scan_for_devices(5)
        self.assertGreater(len(devices), 0)
        for d in devices:
            self.assertIsNotNone(d)
Esempio n. 2
0
 def setUp(self):
     self.backend = BluepyBackend()
Esempio n. 3
0
 def test_check_backend_ok(self):
     """Test check_backend successfully."""
     self.assertTrue(BluepyBackend.check_backend())
Esempio n. 4
0
 def test_configuration_invalid(self, _):
     """Test adapter name pattern parsing."""
     backend = BluepyBackend(adapter='somestring')
     with self.assertRaises(ValueError):
         backend.connect(TEST_MAC)
Esempio n. 5
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, iface=12)
Esempio n. 6
0
 def test_connect_exception(self, _):
     """Test exception wrapping."""
     backend = BluepyBackend()
     with self.assertRaises(BluetoothBackendException):
         backend.connect(TEST_MAC)
Esempio n. 7
0
 def test_adapter_configuration_invalid_adapter(self, _):
     be = BluepyBackend(adapter='somestring')
     with self.assertRaises(ValueError):
         be.connect(TEST_MAC)
Esempio n. 8
0
 def test_adapter_configuration_hci12(self, mock_peripheral):
     be = BluepyBackend(adapter='hci12')
     be.connect(TEST_MAC)
     mock_peripheral.assert_called_with(TEST_MAC, iface=12)
Esempio n. 9
0
 def test_adapter_configuration_default(self, mock_peripheral):
     be = BluepyBackend()
     be.connect(TEST_MAC)
     mock_peripheral.assert_called_with(TEST_MAC, iface=0)
Esempio n. 10
0
 def setUp(self):
     """Set up the test environment."""
     self.backend = BluepyBackend()