2022-05-31 06:45:18 +02:00
|
|
|
from esphome import yaml_util
|
|
|
|
from esphome.components import substitutions
|
2024-01-15 00:06:13 +01:00
|
|
|
from esphome.core import EsphomeError
|
2022-05-31 06:45:18 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_include_with_vars(fixture_path):
|
|
|
|
yaml_file = fixture_path / "yaml_util" / "includetest.yaml"
|
|
|
|
|
|
|
|
actual = yaml_util.load_yaml(yaml_file)
|
|
|
|
substitutions.do_substitution_pass(actual, None)
|
|
|
|
assert actual["esphome"]["name"] == "original"
|
|
|
|
assert actual["esphome"]["libraries"][0] == "Wire"
|
|
|
|
assert actual["esphome"]["board"] == "nodemcu"
|
|
|
|
assert actual["wifi"]["ssid"] == "my_custom_ssid"
|
2024-01-15 00:06:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
def test_loading_a_broken_yaml_file(fixture_path):
|
|
|
|
"""Ensure we fallback to pure python to give good errors."""
|
|
|
|
yaml_file = fixture_path / "yaml_util" / "broken_includetest.yaml"
|
|
|
|
|
|
|
|
try:
|
|
|
|
yaml_util.load_yaml(yaml_file)
|
|
|
|
except EsphomeError as err:
|
|
|
|
assert "broken_included.yaml" in str(err)
|