mirror of
https://github.com/esphome/esphome.git
synced 2026-10-07 11:26:39 +00:00
[bluetooth_connection] Move BluetoothConnection out of bluetooth_proxy (#18129)
This commit is contained in:
@@ -5,12 +5,12 @@ advertisement-only arm applies its own defaults."""
|
||||
import pytest
|
||||
|
||||
from esphome import config_validation as cv
|
||||
from esphome.components import bluetooth_proxy
|
||||
from esphome.components import bluetooth_connection, bluetooth_proxy
|
||||
from esphome.const import CONF_ACTIVE, KEY_TARGET_PLATFORM
|
||||
from esphome.core import CORE, KEY_CORE
|
||||
|
||||
|
||||
def _set_platform(platform: str) -> None:
|
||||
def _set_platform(platform: str | None) -> None:
|
||||
CORE.data.setdefault(KEY_CORE, {})[KEY_TARGET_PLATFORM] = platform
|
||||
|
||||
|
||||
@@ -46,3 +46,17 @@ def test_hub_platform_accepts_the_advertisement_only_shape() -> None:
|
||||
_set_platform("ln882x")
|
||||
validated = bluetooth_proxy.CONFIG_SCHEMA({})
|
||||
assert validated[CONF_ACTIVE] is False
|
||||
|
||||
|
||||
def test_bluetooth_connection_auto_load_covers_its_includes() -> None:
|
||||
# The esp32 connection header includes esp32_ble_client; the auto load
|
||||
# must satisfy that closure itself (regression: it once relied on the
|
||||
# consumer's auto loads).
|
||||
_set_platform("esp32")
|
||||
assert "esp32_ble_client" in bluetooth_connection.AUTO_LOAD()
|
||||
_set_platform("rp2")
|
||||
assert bluetooth_connection.AUTO_LOAD() == ["ble_device_base"]
|
||||
# No target platform (tooling resolving the manifest): the union, so
|
||||
# dependency closures stay complete for build_codeowners and friends.
|
||||
_set_platform(None)
|
||||
assert bluetooth_connection.AUTO_LOAD() == ["ble_device_base", "esp32_ble_client"]
|
||||
|
||||
Reference in New Issue
Block a user