mirror of
https://github.com/esphome/esphome.git
synced 2025-10-29 22:24:26 +00:00
[esp32] Fix strapping pin validation for P4 and H2 (#9980)
This commit is contained in:
@@ -9,13 +9,10 @@ import pytest
|
||||
from esphome import config_validation as cv
|
||||
from esphome.components.esp32 import (
|
||||
KEY_BOARD,
|
||||
KEY_ESP32,
|
||||
KEY_VARIANT,
|
||||
VARIANT_ESP32,
|
||||
VARIANT_ESP32S3,
|
||||
VARIANTS,
|
||||
)
|
||||
from esphome.components.esp32.gpio import validate_gpio_pin
|
||||
from esphome.components.mipi import CONF_NATIVE_HEIGHT
|
||||
from esphome.components.mipi_spi.display import (
|
||||
CONF_BUS_MODE,
|
||||
@@ -32,8 +29,6 @@ from esphome.const import (
|
||||
CONF_WIDTH,
|
||||
PlatformFramework,
|
||||
)
|
||||
from esphome.core import CORE
|
||||
from esphome.pins import internal_gpio_pin_number
|
||||
from esphome.types import ConfigType
|
||||
from tests.component_tests.types import SetCoreConfigCallable
|
||||
|
||||
@@ -43,28 +38,6 @@ def run_schema_validation(config: ConfigType) -> None:
|
||||
FINAL_VALIDATE_SCHEMA(CONFIG_SCHEMA(config))
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def choose_variant_with_pins() -> Callable[..., None]:
|
||||
"""
|
||||
Set the ESP32 variant for the given model based on pins. For ESP32 only since the other platforms
|
||||
do not have variants.
|
||||
"""
|
||||
|
||||
def chooser(*pins: int | str | None) -> None:
|
||||
for v in VARIANTS:
|
||||
try:
|
||||
CORE.data[KEY_ESP32][KEY_VARIANT] = v
|
||||
for pin in pins:
|
||||
if pin is not None:
|
||||
pin = internal_gpio_pin_number(pin)
|
||||
validate_gpio_pin(pin)
|
||||
return
|
||||
except cv.Invalid:
|
||||
continue
|
||||
|
||||
return chooser
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("config", "error_match"),
|
||||
[
|
||||
@@ -315,7 +288,7 @@ def test_custom_model_with_all_options(
|
||||
def test_all_predefined_models(
|
||||
set_core_config: SetCoreConfigCallable,
|
||||
set_component_config: Callable[[str, Any], None],
|
||||
choose_variant_with_pins: Callable[..., None],
|
||||
choose_variant_with_pins: Callable[[list], None],
|
||||
) -> None:
|
||||
"""Test all predefined display models validate successfully with appropriate defaults."""
|
||||
set_core_config(
|
||||
|
||||
Reference in New Issue
Block a user