1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-30 06:33:51 +00:00

[packages] Allow list instead of dict for packages (#8688)

This commit is contained in:
Clyde Stubbs
2025-05-05 10:26:59 +10:00
committed by GitHub
parent 3ed03edfec
commit a31d8ec309
5 changed files with 63 additions and 33 deletions

View File

@@ -76,10 +76,11 @@ def test_package_unused(basic_esphome, basic_wifi):
def test_package_invalid_dict(basic_esphome, basic_wifi):
"""
Ensures an error is raised if packages is not valid.
If a url: key is present, it's expected to be well-formed remote package spec. Ensure an error is raised if not.
Any other simple dict passed as a package will be merged as usual but may fail later validation.
"""
config = {CONF_ESPHOME: basic_esphome, CONF_PACKAGES: basic_wifi}
config = {CONF_ESPHOME: basic_esphome, CONF_PACKAGES: basic_wifi | {CONF_URL: ""}}
with pytest.raises(cv.Invalid):
do_packages_pass(config)

View File

@@ -0,0 +1,3 @@
sensor:
- platform: template
id: package_sensor

View File

@@ -0,0 +1,11 @@
packages:
- sensor:
- platform: template
id: inline_sensor
- !include package.yaml
- github://esphome/esphome/tests/components/template/common.yaml@dev
- url: https://github.com/esphome/esphome
file: tests/components/binary_sensor_map/common.yaml
ref: dev
refresh: 1d

View File

@@ -0,0 +1,13 @@
packages:
sensor:
sensor:
- platform: template
id: inline_sensor
local: !include package.yaml
shorthand: github://esphome/esphome/tests/components/template/common.yaml@dev
github:
url: https://github.com/esphome/esphome
file: tests/components/binary_sensor_map/common.yaml
ref: dev
refresh: 1d