mirror of
https://github.com/esphome/esphome.git
synced 2026-09-29 16:00:23 +00:00
Merge remote-tracking branch 'origin/api-warning-message' into integration
This commit is contained in:
@@ -1,7 +1,3 @@
|
||||
substitutions:
|
||||
x: 10
|
||||
y: 20
|
||||
z: 30
|
||||
values_from_repo1_main:
|
||||
- package_name: package1
|
||||
x: 3
|
||||
@@ -28,3 +24,20 @@ values_from_repo1_main:
|
||||
y: 20
|
||||
z: 5
|
||||
volume: 1000
|
||||
- package_name: package6
|
||||
x: 12
|
||||
y: 13
|
||||
z: 5
|
||||
volume: 780
|
||||
- package_name: default
|
||||
x: 10
|
||||
y: 20
|
||||
z: 5
|
||||
volume: 1000
|
||||
substitutions:
|
||||
x: 10
|
||||
y: 20
|
||||
z: 30
|
||||
my_repo: repo1
|
||||
my_file: file1
|
||||
my_ref: main
|
||||
|
||||
@@ -2,16 +2,26 @@ substitutions:
|
||||
x: 10
|
||||
y: 20
|
||||
z: 30
|
||||
my_repo: default_repo
|
||||
my_file: default_file
|
||||
my_ref: main
|
||||
|
||||
# The following key is only used by the test framework
|
||||
# to simulate command line substitutions
|
||||
command_line_substitutions:
|
||||
my_repo: repo1
|
||||
my_file: file1
|
||||
|
||||
packages:
|
||||
package1:
|
||||
url: https://github.com/esphome/repo1
|
||||
ref: main
|
||||
files:
|
||||
- path: file1.yaml
|
||||
vars:
|
||||
package_name: package1
|
||||
x: 3
|
||||
y: 4
|
||||
ref: main
|
||||
package2: !include # a package that just includes the given remote package
|
||||
file: remote_package_proxy.yaml
|
||||
vars:
|
||||
@@ -41,3 +51,13 @@ packages:
|
||||
repo: repo1
|
||||
file: file1.yaml
|
||||
ref: main
|
||||
package6:
|
||||
url: https://github.com/esphome/${my_repo}
|
||||
ref: ${my_ref}
|
||||
files:
|
||||
- path: ${my_file + ".yaml"}
|
||||
vars:
|
||||
package_name: package6
|
||||
x: 12
|
||||
y: 13
|
||||
package7: github://esphome/${my_repo}/${my_file + ".yaml"}@${my_ref}
|
||||
|
||||
@@ -37,8 +37,6 @@ substitutions:
|
||||
- id: component8
|
||||
value: 8
|
||||
fancy_package:
|
||||
substitutions:
|
||||
fancy_subst: 42
|
||||
fancy_component: *id001
|
||||
pin: 12
|
||||
some_switches: *id002
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
substitutions:
|
||||
a: 10
|
||||
b: 20
|
||||
x: 79
|
||||
test_list:
|
||||
- level1:
|
||||
a: 10
|
||||
b: 20
|
||||
c: 10
|
||||
d: 20
|
||||
e: ${e}
|
||||
f: ${f}
|
||||
g: ${g}
|
||||
h: ${h}
|
||||
i: ${i}
|
||||
j: ${j}
|
||||
x: 80
|
||||
y: 40
|
||||
level2:
|
||||
- level2:
|
||||
a: 10
|
||||
b: 20
|
||||
c: 10
|
||||
d: 20
|
||||
e: 20
|
||||
f: 40
|
||||
g: ${g}
|
||||
h: ${h}
|
||||
i: ${i}
|
||||
j: ${j}
|
||||
x: 81
|
||||
y: 40
|
||||
level3:
|
||||
- level3:
|
||||
a: 10
|
||||
b: 20
|
||||
c: 10
|
||||
d: 20
|
||||
e: 20
|
||||
f: 40
|
||||
g: 100
|
||||
h: 200
|
||||
i: 30
|
||||
j: ${undefined_variable}
|
||||
x: 82
|
||||
y: 40
|
||||
- a: 10
|
||||
b: 20
|
||||
x: 79
|
||||
@@ -0,0 +1,16 @@
|
||||
substitutions:
|
||||
a: 10
|
||||
b: 20
|
||||
x: 79
|
||||
|
||||
test_list:
|
||||
- !include
|
||||
file: level1_package.yaml
|
||||
vars:
|
||||
x: ${x+1}
|
||||
y: ${d*2}
|
||||
c: ${a}
|
||||
d: ${b}
|
||||
- a: ${a}
|
||||
b: ${b}
|
||||
x: ${x}
|
||||
@@ -0,0 +1,69 @@
|
||||
substitutions:
|
||||
a: from base config
|
||||
b: from package3
|
||||
c: from nested package4
|
||||
nested_package:
|
||||
nested_package_test_list:
|
||||
- a: from base config
|
||||
- b: from package3
|
||||
- c: from nested package4
|
||||
package1:
|
||||
package1_test_list:
|
||||
- a: from base config
|
||||
- b: from package3
|
||||
- c: from nested package4
|
||||
package2:
|
||||
package2_test_list:
|
||||
- a: from package2 vars
|
||||
- b: from package3
|
||||
- c: from nested package4
|
||||
package3:
|
||||
package3_test_list:
|
||||
- a: from base config
|
||||
- b: from package3
|
||||
- c: from nested package4
|
||||
package4:
|
||||
packages:
|
||||
- nested_package_test_list:
|
||||
- a: from base config
|
||||
- b: from package3
|
||||
- c: from nested package4
|
||||
package_map:
|
||||
package1:
|
||||
package1_test_list:
|
||||
- a: from base config
|
||||
- b: from package3
|
||||
- c: from nested package4
|
||||
package2:
|
||||
package2_test_list:
|
||||
- a: from package2 vars
|
||||
- b: from package3
|
||||
- c: from nested package4
|
||||
package3: &id001
|
||||
package3_test_list:
|
||||
- a: from base config
|
||||
- b: from package3
|
||||
- c: from nested package4
|
||||
selected_package_number: 3
|
||||
selected_package_name: package3
|
||||
selected_package: *id001
|
||||
base_test_list:
|
||||
- a: from base config
|
||||
- b: from package3
|
||||
- c: from nested package4
|
||||
package1_test_list:
|
||||
- a: from base config
|
||||
- b: from package3
|
||||
- c: from nested package4
|
||||
package2_test_list:
|
||||
- a: from package2 vars
|
||||
- b: from package3
|
||||
- c: from nested package4
|
||||
package3_test_list:
|
||||
- a: from base config
|
||||
- b: from package3
|
||||
- c: from nested package4
|
||||
nested_package_test_list:
|
||||
- a: from base config
|
||||
- b: from package3
|
||||
- c: from nested package4
|
||||
@@ -0,0 +1,62 @@
|
||||
command_line_substitutions:
|
||||
selected_package_number: 3
|
||||
|
||||
substitutions:
|
||||
a: from base config
|
||||
|
||||
package1: &p1
|
||||
substitutions:
|
||||
a: from package1
|
||||
b: from package1
|
||||
c: from package1
|
||||
package1_test_list:
|
||||
- a: ${ a }
|
||||
- b: ${ b }
|
||||
- c: ${ c }
|
||||
|
||||
package2: &p2 !include
|
||||
file: package2.yaml
|
||||
vars:
|
||||
a: from package2 vars
|
||||
|
||||
package3: &p3
|
||||
substitutions:
|
||||
a: from package3
|
||||
b: from package3
|
||||
c: from package3
|
||||
package3_test_list:
|
||||
- a: ${ a }
|
||||
- b: ${ b }
|
||||
- c: ${ c }
|
||||
|
||||
package4:
|
||||
substitutions:
|
||||
nested_package:
|
||||
substitutions:
|
||||
c: from nested package4
|
||||
nested_package_test_list:
|
||||
- a: ${ a }
|
||||
- b: ${ b }
|
||||
- c: ${ c }
|
||||
packages:
|
||||
- ${ nested_package }
|
||||
|
||||
package_map:
|
||||
package1: *p1
|
||||
package2: *p2
|
||||
package3: *p3
|
||||
|
||||
selected_package_number: 2 # will be overridden by command line substitutions
|
||||
selected_package_name: package${ selected_package_number }
|
||||
selected_package: ${ package_map[selected_package_name] }
|
||||
|
||||
packages:
|
||||
- ${ package1 }
|
||||
- ${ package2 }
|
||||
- ${ selected_package }
|
||||
- ${ package4 }
|
||||
|
||||
base_test_list:
|
||||
- a: ${ a }
|
||||
- b: ${ b }
|
||||
- c: ${ c }
|
||||
@@ -0,0 +1,21 @@
|
||||
# this file is included by 07-include_hierarchy.input.yaml
|
||||
level1:
|
||||
a: ${a} # top-level substitution
|
||||
b: ${b} # top-level substitution
|
||||
c: ${c} # from vars when including
|
||||
d: ${d} # from vars when including
|
||||
e: ${e} # undefined at this level
|
||||
f: ${f} # undefined at this level
|
||||
g: ${g} # undefined at this level
|
||||
h: ${h} # undefined at this level
|
||||
i: ${i} # undefined at this level
|
||||
j: ${j} # undefined at this level
|
||||
x: ${x} # from vars when including, calculated
|
||||
y: ${y} # from vars when including, calculated
|
||||
level2:
|
||||
- !include
|
||||
file: level2_package.yaml
|
||||
vars:
|
||||
e: ${c*2}
|
||||
f: ${d*2}
|
||||
x: ${x+1}
|
||||
@@ -0,0 +1,21 @@
|
||||
# this file is included by level1_package.yaml
|
||||
level2:
|
||||
a: ${a} # top-level substitution
|
||||
b: ${b} # top-level substitution
|
||||
c: ${c} # visible from level1 vars
|
||||
d: ${d} # visible from level1 vars
|
||||
e: ${e} # from vars when including
|
||||
f: ${f} # from vars when including
|
||||
g: ${g} # undefined at this level
|
||||
h: ${h} # undefined at this level
|
||||
i: ${i} # undefined at this level
|
||||
j: ${j} # undefined at this level
|
||||
x: ${x} # from vars when including, calculated
|
||||
y: ${y} # from vars when including, calculated
|
||||
level3:
|
||||
- !include
|
||||
file: level3_package.yaml
|
||||
vars:
|
||||
g: ${e*5}
|
||||
h: ${f*5}
|
||||
x: ${x+1}
|
||||
@@ -0,0 +1,16 @@
|
||||
# this file is included by level2_package.yaml
|
||||
defaults:
|
||||
i: 30
|
||||
level3:
|
||||
a: ${a} # top-level substitution
|
||||
b: ${b} # top-level substitution
|
||||
c: ${c} # visible from level1 vars
|
||||
d: ${d} # visible from level1 vars
|
||||
e: ${e} # visible from level2 vars
|
||||
f: ${f} # visible from level2 vars
|
||||
g: ${g} # from vars when including
|
||||
h: ${h} # from vars when including
|
||||
i: ${i} # Should take the default value of 30
|
||||
j: ${undefined_variable} # Does not exist, should be output as-is
|
||||
x: ${x} # from vars when including, calculated
|
||||
y: ${y} # from vars when including, calculated
|
||||
@@ -0,0 +1,10 @@
|
||||
# included from 10-dynamic_packages.input.yaml
|
||||
substitutions:
|
||||
a: from package2 # must not override base config's a
|
||||
# b not defined here, won't override package1's b
|
||||
c: from package2 # will override package1's c
|
||||
|
||||
package2_test_list:
|
||||
- a: ${ a }
|
||||
- b: ${ b }
|
||||
- c: ${ c }
|
||||
@@ -143,7 +143,9 @@ def test_substitutions_fixtures(
|
||||
|
||||
command_line_substitutions = config.pop("command_line_substitutions", None)
|
||||
|
||||
config = do_packages_pass(config)
|
||||
config = do_packages_pass(
|
||||
config, command_line_substitutions=command_line_substitutions
|
||||
)
|
||||
|
||||
config = substitutions.do_substitution_pass(config, command_line_substitutions)
|
||||
|
||||
|
||||
@@ -98,13 +98,15 @@ def test_construct_secret_missing(fixture_path: Path, tmp_path: Path) -> None:
|
||||
"""Test that missing secrets raise proper errors."""
|
||||
# Create a YAML file with a secret that doesn't exist
|
||||
test_yaml = tmp_path / "test.yaml"
|
||||
test_yaml.write_text("""
|
||||
test_yaml.write_text(
|
||||
"""
|
||||
esphome:
|
||||
name: test
|
||||
|
||||
wifi:
|
||||
password: !secret nonexistent_secret
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
# Create an empty secrets file
|
||||
secrets_yaml = tmp_path / "secrets.yaml"
|
||||
@@ -118,10 +120,12 @@ def test_construct_secret_no_secrets_file(tmp_path: Path) -> None:
|
||||
"""Test that missing secrets.yaml file raises proper error."""
|
||||
# Create a YAML file with a secret but no secrets.yaml
|
||||
test_yaml = tmp_path / "test.yaml"
|
||||
test_yaml.write_text("""
|
||||
test_yaml.write_text(
|
||||
"""
|
||||
wifi:
|
||||
password: !secret some_secret
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
# Mock CORE.config_path to avoid NoneType error
|
||||
with (
|
||||
@@ -140,10 +144,12 @@ def test_construct_secret_fallback_to_main_config_dir(
|
||||
subdir.mkdir()
|
||||
|
||||
test_yaml = subdir / "test.yaml"
|
||||
test_yaml.write_text("""
|
||||
test_yaml.write_text(
|
||||
"""
|
||||
wifi:
|
||||
password: !secret test_secret
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
# Create secrets.yaml in the main directory
|
||||
main_secrets = tmp_path / "secrets.yaml"
|
||||
@@ -164,9 +170,11 @@ def test_construct_include_dir_named(fixture_path: Path, tmp_path: Path) -> None
|
||||
|
||||
# Create test YAML that uses include_dir_named
|
||||
test_yaml = dst_dir / "test_include_named.yaml"
|
||||
test_yaml.write_text("""
|
||||
test_yaml.write_text(
|
||||
"""
|
||||
sensor: !include_dir_named named_dir
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
actual = yaml_util.load_yaml(test_yaml)
|
||||
actual_sensor = actual["sensor"]
|
||||
@@ -199,9 +207,11 @@ def test_construct_include_dir_named_empty_dir(tmp_path: Path) -> None:
|
||||
empty_dir.mkdir()
|
||||
|
||||
test_yaml = tmp_path / "test.yaml"
|
||||
test_yaml.write_text("""
|
||||
test_yaml.write_text(
|
||||
"""
|
||||
sensor: !include_dir_named empty_dir
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
actual = yaml_util.load_yaml(test_yaml)
|
||||
|
||||
@@ -231,9 +241,11 @@ def test_construct_include_dir_named_with_dots(tmp_path: Path) -> None:
|
||||
hidden_subfile.write_text("key: hidden_subfile_value")
|
||||
|
||||
test_yaml = tmp_path / "test.yaml"
|
||||
test_yaml.write_text("""
|
||||
test_yaml.write_text(
|
||||
"""
|
||||
test: !include_dir_named test_dir
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
actual = yaml_util.load_yaml(test_yaml)
|
||||
|
||||
@@ -255,9 +267,11 @@ def test_find_files_recursive(fixture_path: Path, tmp_path: Path) -> None:
|
||||
|
||||
# This indirectly tests _find_files by using include_dir_named
|
||||
test_yaml = dst_dir / "test_include_recursive.yaml"
|
||||
test_yaml.write_text("""
|
||||
test_yaml.write_text(
|
||||
"""
|
||||
all_sensors: !include_dir_named named_dir
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
actual = yaml_util.load_yaml(test_yaml)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user