mirror of
https://github.com/esphome/esphome.git
synced 2025-10-26 20:53:50 +00:00
cleanups
This commit is contained in:
@@ -3,10 +3,11 @@
|
|||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from esphome import config, config_validation as cv
|
from esphome import config, config_validation as cv, yaml_util
|
||||||
from esphome.config import Config
|
from esphome.config import Config
|
||||||
from esphome.const import CONF_AREA, CONF_AREAS, CONF_DEVICES
|
from esphome.const import CONF_AREA, CONF_AREAS, CONF_DEVICES
|
||||||
from esphome.core import CORE
|
from esphome.core import CORE
|
||||||
@@ -38,8 +39,15 @@ def load_config_from_yaml(
|
|||||||
yaml_file: Callable[[str], str], yaml_content: str
|
yaml_file: Callable[[str], str], yaml_content: str
|
||||||
) -> Config | None:
|
) -> Config | None:
|
||||||
"""Load configuration from YAML content."""
|
"""Load configuration from YAML content."""
|
||||||
CORE.config_path = yaml_file(yaml_content)
|
yaml_path = yaml_file(yaml_content)
|
||||||
return config.read_config({})
|
parsed_yaml = yaml_util.load_yaml(yaml_path)
|
||||||
|
|
||||||
|
# Mock yaml_util.load_yaml to return our parsed content
|
||||||
|
with (
|
||||||
|
patch.object(yaml_util, "load_yaml", return_value=parsed_yaml),
|
||||||
|
patch.object(CORE, "config_path", yaml_path),
|
||||||
|
):
|
||||||
|
return config.read_config({})
|
||||||
|
|
||||||
|
|
||||||
def load_config_from_fixture(
|
def load_config_from_fixture(
|
||||||
|
|||||||
Reference in New Issue
Block a user