Add initial blueprint support (#42469)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com> Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
parent
a84dc14569
commit
0fb587727c
30 changed files with 2144 additions and 22 deletions
71
tests/components/blueprint/test_schemas.py
Normal file
71
tests/components/blueprint/test_schemas.py
Normal file
|
@ -0,0 +1,71 @@
|
|||
"""Test schemas."""
|
||||
import logging
|
||||
|
||||
import pytest
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.blueprint import schemas
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"blueprint",
|
||||
(
|
||||
# Test allow extra
|
||||
{
|
||||
"trigger": "Test allow extra",
|
||||
"blueprint": {"name": "Test Name", "domain": "automation"},
|
||||
},
|
||||
# Bare minimum
|
||||
{"blueprint": {"name": "Test Name", "domain": "automation"}},
|
||||
# Empty triggers
|
||||
{"blueprint": {"name": "Test Name", "domain": "automation", "input": {}}},
|
||||
# No definition of input
|
||||
{
|
||||
"blueprint": {
|
||||
"name": "Test Name",
|
||||
"domain": "automation",
|
||||
"input": {
|
||||
"some_placeholder": None,
|
||||
},
|
||||
}
|
||||
},
|
||||
),
|
||||
)
|
||||
def test_blueprint_schema(blueprint):
|
||||
"""Test different schemas."""
|
||||
try:
|
||||
schemas.BLUEPRINT_SCHEMA(blueprint)
|
||||
except vol.Invalid:
|
||||
_LOGGER.exception("%s", blueprint)
|
||||
assert False, "Expected schema to be valid"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"blueprint",
|
||||
(
|
||||
# no domain
|
||||
{"blueprint": {}},
|
||||
# non existing key in blueprint
|
||||
{
|
||||
"blueprint": {
|
||||
"name": "Example name",
|
||||
"domain": "automation",
|
||||
"non_existing": None,
|
||||
}
|
||||
},
|
||||
# non existing key in input
|
||||
{
|
||||
"blueprint": {
|
||||
"name": "Example name",
|
||||
"domain": "automation",
|
||||
"input": {"some_placeholder": {"non_existing": "bla"}},
|
||||
}
|
||||
},
|
||||
),
|
||||
)
|
||||
def test_blueprint_schema_invalid(blueprint):
|
||||
"""Test different schemas."""
|
||||
with pytest.raises(vol.Invalid):
|
||||
schemas.BLUEPRINT_SCHEMA(blueprint)
|
Loading…
Add table
Add a link
Reference in a new issue