def test_extract_inputs(): """Test extracting inputs from data.""" assert extract_inputs(Input("hello")) == {"hello"} assert extract_inputs({"info": [1, Input("hello"), 2, Input("world")]}) == { "hello", "world", }
def test_substitute(): """Test we can substitute.""" assert substitute(Input("hello"), {"hello": 5}) == 5 with pytest.raises(UndefinedSubstitution): substitute(Input("hello"), {}) assert ( substitute( {"info": [1, Input("hello"), 2, Input("world")]}, {"hello": 5, "world": 10}, ) == {"info": [1, 5, 2, 10]} )
def test_blueprint_model_init(): """Test constructor validation.""" with pytest.raises(errors.InvalidBlueprint): models.Blueprint({}) with pytest.raises(errors.InvalidBlueprint): models.Blueprint( {"blueprint": { "name": "Hello", "domain": "automation" }}, expected_domain="not-automation", ) with pytest.raises(errors.InvalidBlueprint): models.Blueprint({ "blueprint": { "name": "Hello", "domain": "automation", "input": { "something": None }, }, "trigger": { "platform": Input("non-existing") }, })
def blueprint_2(): """Blueprint fixture with default inputs.""" return models.Blueprint( { "blueprint": { "name": "Hello", "domain": "automation", "source_url": "https://github.com/balloob/home-assistant-config/blob/main/blueprints/automation/motion_light.yaml", "input": { "test-input": {"name": "Name", "description": "Description"}, "test-input-default": {"default": "test"}, }, }, "example": Input("test-input"), "example-default": Input("test-input-default"), } )