mirror of
https://github.com/home-assistant/core.git
synced 2026-09-25 17:04:04 -04:00
Allow importing gist (#43659)
This commit is contained in:
@@ -80,8 +80,8 @@ def test_extract_blueprint_from_community_topic_invalid_yaml():
|
||||
|
||||
def test_extract_blueprint_from_community_topic_wrong_lang():
|
||||
"""Test extracting blueprint with invalid YAML."""
|
||||
assert (
|
||||
importer._extract_blueprint_from_community_topic(
|
||||
with pytest.raises(importer.HomeAssistantError):
|
||||
assert importer._extract_blueprint_from_community_topic(
|
||||
"http://example.com",
|
||||
{
|
||||
"post_stream": {
|
||||
@@ -91,8 +91,6 @@ def test_extract_blueprint_from_community_topic_wrong_lang():
|
||||
}
|
||||
},
|
||||
)
|
||||
is None
|
||||
)
|
||||
|
||||
|
||||
async def test_fetch_blueprint_from_community_url(hass, aioclient_mock, community_post):
|
||||
@@ -141,3 +139,22 @@ async def test_fetch_blueprint_from_github_url(hass, aioclient_mock, url):
|
||||
}
|
||||
assert imported_blueprint.suggested_filename == "balloob/motion_light"
|
||||
assert imported_blueprint.blueprint.metadata["source_url"] == url
|
||||
|
||||
|
||||
async def test_fetch_blueprint_from_github_gist_url(hass, aioclient_mock):
|
||||
"""Test fetching blueprint from url."""
|
||||
aioclient_mock.get(
|
||||
"https://api.github.com/gists/e717ce85dd0d2f1bdcdfc884ea25a344",
|
||||
text=load_fixture("blueprint/github_gist.json"),
|
||||
)
|
||||
|
||||
url = "https://gist.github.com/balloob/e717ce85dd0d2f1bdcdfc884ea25a344"
|
||||
imported_blueprint = await importer.fetch_blueprint_from_url(hass, url)
|
||||
assert isinstance(imported_blueprint, importer.ImportedBlueprint)
|
||||
assert imported_blueprint.blueprint.domain == "automation"
|
||||
assert imported_blueprint.blueprint.placeholders == {
|
||||
"motion_entity",
|
||||
"light_entity",
|
||||
}
|
||||
assert imported_blueprint.suggested_filename == "balloob/motion_light"
|
||||
assert imported_blueprint.blueprint.metadata["source_url"] == url
|
||||
|
||||
Reference in New Issue
Block a user