From 688f3e264c69a2242e1c1c1dca28461a1ec2607b Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 22 Dec 2024 10:38:22 -1000 Subject: [PATCH] chore: add basic scanner tests --- tests/backend/__init__.py | 0 tests/backend/test_scanner.py | 16 ++++++++++++++++ tests/conftest.py | 14 ++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 tests/backend/__init__.py create mode 100644 tests/backend/test_scanner.py create mode 100644 tests/conftest.py diff --git a/tests/backend/__init__.py b/tests/backend/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/backend/test_scanner.py b/tests/backend/test_scanner.py new file mode 100644 index 0000000..79d94e5 --- /dev/null +++ b/tests/backend/test_scanner.py @@ -0,0 +1,16 @@ +from habluetooth import ( + BaseHaRemoteScanner, + HaBluetoothConnector, +) + +from bleak_esphome.backend.client import ESPHomeClientData +from bleak_esphome.backend.scanner import ESPHomeScanner + +ESP_MAC_ADDRESS = "AA:BB:CC:DD:EE:FF" +ESP_NAME = "proxy" + + +def test_scanner(): + connector = HaBluetoothConnector(ESPHomeClientData, ESP_MAC_ADDRESS, lambda: True) + scanner = ESPHomeScanner(ESP_MAC_ADDRESS, ESP_NAME, connector, True) + assert isinstance(scanner, BaseHaRemoteScanner) diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..fd5ca8c --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,14 @@ +import pytest +from bleak_retry_connector import BleakSlotManager +from bluetooth_adapters import BluetoothAdapters +from habluetooth import ( + BluetoothManager, + set_manager, +) + + +@pytest.fixture(scope="session", autouse=True) +def manager(): + slot_manager = BleakSlotManager() + bluetooth_adapters = BluetoothAdapters() + set_manager(BluetoothManager(bluetooth_adapters, slot_manager))