1
0
mirror of https://github.com/esphome/esphome.git synced 2026-02-08 00:31:58 +00:00

[esp32_ble] include sdkconfig.h before ESP-Hosted preprocessor guards (#13787)

Co-authored-by: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Andrew Rankin
2026-02-06 06:36:55 -05:00
committed by GitHub
parent 112a2c5d92
commit 7afd0eb1aa
12 changed files with 124 additions and 14 deletions

View File

@@ -1,10 +1,14 @@
"""
Test schema.extend functionality in esphome.config_validation.
Test config_validation functionality in esphome.config_validation.
"""
from typing import Any
import pytest
from voluptuous import Invalid
import esphome.config_validation as cv
from esphome.core import CORE
def test_config_extend() -> None:
@@ -49,3 +53,37 @@ def test_config_extend() -> None:
assert validated["key2"] == "initial_value2"
assert validated["extra_1"] == "value1"
assert validated["extra_2"] == "value2"
def test_requires_component_passes_when_loaded() -> None:
"""Test requires_component passes when the required component is loaded."""
CORE.loaded_integrations.update({"wifi", "logger"})
validator = cv.requires_component("wifi")
result = validator("test_value")
assert result == "test_value"
def test_requires_component_fails_when_not_loaded() -> None:
"""Test requires_component raises Invalid when the required component is not loaded."""
CORE.loaded_integrations.add("logger")
validator = cv.requires_component("wifi")
with pytest.raises(Invalid) as exc_info:
validator("test_value")
assert "requires component wifi" in str(exc_info.value)
def test_conflicts_with_component_passes_when_not_loaded() -> None:
"""Test conflicts_with_component passes when the conflicting component is not loaded."""
CORE.loaded_integrations.update({"wifi", "logger"})
validator = cv.conflicts_with_component("esp32_hosted")
result = validator("test_value")
assert result == "test_value"
def test_conflicts_with_component_fails_when_loaded() -> None:
"""Test conflicts_with_component raises Invalid when the conflicting component is loaded."""
CORE.loaded_integrations.update({"wifi", "esp32_hosted"})
validator = cv.conflicts_with_component("esp32_hosted")
with pytest.raises(Invalid) as exc_info:
validator("test_value")
assert "not compatible with component esp32_hosted" in str(exc_info.value)

View File

@@ -0,0 +1,8 @@
packages:
ble: !include ../../test_build_components/common/ble/esp32-p4-idf.yaml
<<: !include common.yaml
esp32_ble:
io_capability: keyboard_only
disable_bt_logs: false

View File

@@ -0,0 +1,7 @@
packages:
ble: !include ../../test_build_components/common/ble/esp32-p4-idf.yaml
# tx_power is not supported on ESP-Hosted platforms
esp32_ble_beacon:
type: iBeacon
uuid: 'c29ce823-e67a-4e71-bff2-abaa32e77a98'

View File

@@ -0,0 +1,6 @@
packages:
ble: !include ../../test_build_components/common/ble/esp32-p4-idf.yaml
ble_client:
- mac_address: 01:02:03:04:05:06
id: blec

View File

@@ -0,0 +1,4 @@
packages:
ble: !include ../../test_build_components/common/ble/esp32-p4-idf.yaml
<<: !include common.yaml

View File

@@ -0,0 +1,7 @@
packages:
ble: !include ../../test_build_components/common/ble/esp32-p4-idf.yaml
<<: !include common.yaml
esp32_ble_tracker:
max_connections: 9

View File

@@ -0,0 +1,21 @@
# Common BLE tracker configuration for ESP32-P4 IDF tests
# ESP32-P4 requires ESP-Hosted for Bluetooth via external coprocessor
# BLE client components share this tracker infrastructure
# Each component defines its own ble_client with unique MAC address
esp32_hosted:
active_high: true
variant: ESP32C6
reset_pin: GPIO54
cmd_pin: GPIO19
clk_pin: GPIO18
d0_pin: GPIO14
d1_pin: GPIO15
d2_pin: GPIO16
d3_pin: GPIO17
esp32_ble_tracker:
scan_parameters:
interval: 1100ms
window: 1100ms
active: true