mirror of
https://github.com/home-assistant/core.git
synced 2025-12-26 22:18:40 +00:00
Add save and delete WS commands to blueprints (#42907)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
@@ -17,7 +17,10 @@ def blueprint_1():
|
||||
"blueprint": {
|
||||
"name": "Hello",
|
||||
"domain": "automation",
|
||||
"input": {"test-placeholder": None},
|
||||
"source_url": "https://github.com/balloob/home-assistant-config/blob/main/blueprints/automation/motion_light.yaml",
|
||||
"input": {
|
||||
"test-placeholder": {"name": "Name", "description": "Description"}
|
||||
},
|
||||
},
|
||||
"example": Placeholder("test-placeholder"),
|
||||
}
|
||||
@@ -59,7 +62,8 @@ def test_blueprint_properties(blueprint_1):
|
||||
assert blueprint_1.metadata == {
|
||||
"name": "Hello",
|
||||
"domain": "automation",
|
||||
"input": {"test-placeholder": None},
|
||||
"source_url": "https://github.com/balloob/home-assistant-config/blob/main/blueprints/automation/motion_light.yaml",
|
||||
"input": {"test-placeholder": {"name": "Name", "description": "Description"}},
|
||||
}
|
||||
assert blueprint_1.domain == "automation"
|
||||
assert blueprint_1.name == "Hello"
|
||||
@@ -152,3 +156,19 @@ async def test_domain_blueprints_inputs_from_config(domain_bps, blueprint_1):
|
||||
)
|
||||
assert inputs.blueprint is blueprint_1
|
||||
assert inputs.inputs == {"test-placeholder": None}
|
||||
|
||||
|
||||
async def test_domain_blueprints_add_blueprint(domain_bps, blueprint_1):
|
||||
"""Test DomainBlueprints.async_add_blueprint."""
|
||||
with patch.object(domain_bps, "_create_file") as create_file_mock:
|
||||
# Should add extension when not present.
|
||||
await domain_bps.async_add_blueprint(blueprint_1, "something")
|
||||
assert create_file_mock.call_args[0][1] == ("something.yaml")
|
||||
|
||||
await domain_bps.async_add_blueprint(blueprint_1, "something2.yaml")
|
||||
assert create_file_mock.call_args[0][1] == ("something2.yaml")
|
||||
|
||||
# Should be in cache.
|
||||
with patch.object(domain_bps, "_load_blueprint") as mock_load:
|
||||
assert await domain_bps.async_get_blueprint("something.yaml") == blueprint_1
|
||||
assert not mock_load.mock_calls
|
||||
|
||||
Reference in New Issue
Block a user