[tests] Add testing of command line substitutions (#12210)
Co-authored-by: J. Nick Koston <nick+github@koston.org> Co-authored-by: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com>
This commit is contained in:
@@ -8,6 +8,8 @@ substitutions:
|
||||
position:
|
||||
x: 79
|
||||
y: 82
|
||||
a: 15
|
||||
b: 20
|
||||
|
||||
esphome:
|
||||
name: test
|
||||
@@ -34,3 +36,5 @@ test_list:
|
||||
- '{{{"AA"}}}'
|
||||
- '"HELLO"'
|
||||
- '{ 79, 82 }'
|
||||
- a: 15 should be 15, overridden from command line
|
||||
b: 20 should stay as 20, not overridden
|
||||
|
||||
@@ -11,6 +11,13 @@ substitutions:
|
||||
position:
|
||||
x: 79
|
||||
y: 82
|
||||
a: 10
|
||||
b: 20
|
||||
|
||||
# The following key is only used by the test framework
|
||||
# to simulate command line substitutions
|
||||
command_line_substitutions:
|
||||
a: 15
|
||||
|
||||
test_list:
|
||||
- "$var1"
|
||||
@@ -35,3 +42,5 @@ test_list:
|
||||
- ${ '{{{"AA"}}}' }
|
||||
- ${ '"HELLO"' }
|
||||
- '{ ${position.x}, ${position.y} }'
|
||||
- a: ${a} should be 15, overridden from command line
|
||||
b: ${b} should stay as 20, not overridden
|
||||
|
||||
@@ -138,9 +138,11 @@ def test_substitutions_fixtures(
|
||||
# Load using ESPHome's YAML loader
|
||||
config = yaml_util.load_yaml(source_path)
|
||||
|
||||
command_line_substitutions = config.pop("command_line_substitutions", None)
|
||||
|
||||
config = do_packages_pass(config)
|
||||
|
||||
substitutions.do_substitution_pass(config, None)
|
||||
substitutions.do_substitution_pass(config, command_line_substitutions)
|
||||
|
||||
resolve_extend_remove(config)
|
||||
verify_database_result = verify_database(config)
|
||||
|
||||
Reference in New Issue
Block a user