hass-core/tests/components/blueprint/test_default_blueprints.py
Paulus Schoutsen b3be708db6
Add default config if not there ()
Co-authored-by: Bram Kragten <mail@bramkragten.nl>
2020-11-25 15:10:04 +01:00

28 lines
906 B
Python

"""Test default blueprints."""
import importlib
import logging
import pathlib
import pytest
from homeassistant.components.blueprint import models
from homeassistant.components.blueprint.const import BLUEPRINT_FOLDER
from homeassistant.util import yaml
DOMAINS = ["automation"]
LOGGER = logging.getLogger(__name__)
@pytest.mark.parametrize("domain", DOMAINS)
def test_default_blueprints(domain: str):
"""Validate a folder of blueprints."""
integration = importlib.import_module(f"homeassistant.components.{domain}")
blueprint_folder = pathlib.Path(integration.__file__).parent / BLUEPRINT_FOLDER
items = list(blueprint_folder.glob("*"))
assert len(items) > 0, "Folder cannot be empty"
for fil in items:
LOGGER.info("Processing %s", fil)
assert fil.name.endswith(".yaml")
data = yaml.load_yaml(fil)
models.Blueprint(data, expected_domain=domain)