mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
Return default repairs flow for cloud TTS issues (#113981)
* Set TTS repairs as not fixable * Return default confirm flow for fixable cloud issues * Depend on repairs * Test default repair flow --------- Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
parent
abb217086f
commit
a2143a7c1a
@ -3,7 +3,7 @@
|
|||||||
"name": "Home Assistant Cloud",
|
"name": "Home Assistant Cloud",
|
||||||
"after_dependencies": ["assist_pipeline", "google_assistant", "alexa"],
|
"after_dependencies": ["assist_pipeline", "google_assistant", "alexa"],
|
||||||
"codeowners": ["@home-assistant/cloud"],
|
"codeowners": ["@home-assistant/cloud"],
|
||||||
"dependencies": ["http", "webhook"],
|
"dependencies": ["http", "repairs", "webhook"],
|
||||||
"documentation": "https://www.home-assistant.io/integrations/cloud",
|
"documentation": "https://www.home-assistant.io/integrations/cloud",
|
||||||
"integration_type": "system",
|
"integration_type": "system",
|
||||||
"iot_class": "cloud_push",
|
"iot_class": "cloud_push",
|
||||||
|
@ -8,7 +8,11 @@ from typing import Any
|
|||||||
from hass_nabucasa import Cloud
|
from hass_nabucasa import Cloud
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.repairs import RepairsFlow, repairs_flow_manager
|
from homeassistant.components.repairs import (
|
||||||
|
ConfirmRepairFlow,
|
||||||
|
RepairsFlow,
|
||||||
|
repairs_flow_manager,
|
||||||
|
)
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
from homeassistant.data_entry_flow import FlowResult
|
||||||
from homeassistant.helpers import issue_registry as ir
|
from homeassistant.helpers import issue_registry as ir
|
||||||
@ -120,4 +124,6 @@ async def async_create_fix_flow(
|
|||||||
data: dict[str, str | int | float | None] | None,
|
data: dict[str, str | int | float | None] | None,
|
||||||
) -> RepairsFlow:
|
) -> RepairsFlow:
|
||||||
"""Create flow."""
|
"""Create flow."""
|
||||||
return LegacySubscriptionRepairFlow()
|
if issue_id == "legacy_subscription":
|
||||||
|
return LegacySubscriptionRepairFlow()
|
||||||
|
return ConfirmRepairFlow()
|
||||||
|
@ -526,6 +526,8 @@ async def test_deprecated_voice(
|
|||||||
}
|
}
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
issue_id = f"deprecated_voice_{deprecated_voice}"
|
||||||
|
|
||||||
assert mock_process_tts.call_count == 1
|
assert mock_process_tts.call_count == 1
|
||||||
assert mock_process_tts.call_args is not None
|
assert mock_process_tts.call_args is not None
|
||||||
assert mock_process_tts.call_args.kwargs["text"] == "There is someone at the door."
|
assert mock_process_tts.call_args.kwargs["text"] == "There is someone at the door."
|
||||||
@ -533,9 +535,7 @@ async def test_deprecated_voice(
|
|||||||
assert mock_process_tts.call_args.kwargs["gender"] is None
|
assert mock_process_tts.call_args.kwargs["gender"] is None
|
||||||
assert mock_process_tts.call_args.kwargs["voice"] == replacement_voice
|
assert mock_process_tts.call_args.kwargs["voice"] == replacement_voice
|
||||||
assert mock_process_tts.call_args.kwargs["output"] == "mp3"
|
assert mock_process_tts.call_args.kwargs["output"] == "mp3"
|
||||||
issue = issue_registry.async_get_issue(
|
issue = issue_registry.async_get_issue("cloud", issue_id)
|
||||||
"cloud", f"deprecated_voice_{deprecated_voice}"
|
|
||||||
)
|
|
||||||
assert issue is not None
|
assert issue is not None
|
||||||
assert issue.breaks_in_ha_version == "2024.8.0"
|
assert issue.breaks_in_ha_version == "2024.8.0"
|
||||||
assert issue.is_fixable is True
|
assert issue.is_fixable is True
|
||||||
@ -547,6 +547,46 @@ async def test_deprecated_voice(
|
|||||||
"replacement_voice": replacement_voice,
|
"replacement_voice": replacement_voice,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resp = await client.post(
|
||||||
|
"/api/repairs/issues/fix",
|
||||||
|
json={"handler": DOMAIN, "issue_id": issue.issue_id},
|
||||||
|
)
|
||||||
|
|
||||||
|
assert resp.status == HTTPStatus.OK
|
||||||
|
data = await resp.json()
|
||||||
|
|
||||||
|
flow_id = data["flow_id"]
|
||||||
|
assert data == {
|
||||||
|
"type": "form",
|
||||||
|
"flow_id": flow_id,
|
||||||
|
"handler": DOMAIN,
|
||||||
|
"step_id": "confirm",
|
||||||
|
"data_schema": [],
|
||||||
|
"errors": None,
|
||||||
|
"description_placeholders": {
|
||||||
|
"deprecated_voice": "XiaoxuanNeural",
|
||||||
|
"replacement_voice": "XiaozhenNeural",
|
||||||
|
},
|
||||||
|
"last_step": None,
|
||||||
|
"preview": None,
|
||||||
|
}
|
||||||
|
|
||||||
|
resp = await client.post(f"/api/repairs/issues/fix/{flow_id}")
|
||||||
|
|
||||||
|
assert resp.status == HTTPStatus.OK
|
||||||
|
data = await resp.json()
|
||||||
|
|
||||||
|
flow_id = data["flow_id"]
|
||||||
|
assert data == {
|
||||||
|
"type": "create_entry",
|
||||||
|
"flow_id": flow_id,
|
||||||
|
"handler": DOMAIN,
|
||||||
|
"description": None,
|
||||||
|
"description_placeholders": None,
|
||||||
|
}
|
||||||
|
|
||||||
|
assert not issue_registry.async_get_issue(DOMAIN, issue_id)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
("data", "expected_url_suffix"),
|
("data", "expected_url_suffix"),
|
||||||
@ -631,6 +671,8 @@ async def test_deprecated_gender(
|
|||||||
}
|
}
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
issue_id = "deprecated_gender"
|
||||||
|
|
||||||
assert mock_process_tts.call_count == 1
|
assert mock_process_tts.call_count == 1
|
||||||
assert mock_process_tts.call_args is not None
|
assert mock_process_tts.call_args is not None
|
||||||
assert mock_process_tts.call_args.kwargs["text"] == "There is someone at the door."
|
assert mock_process_tts.call_args.kwargs["text"] == "There is someone at the door."
|
||||||
@ -638,7 +680,7 @@ async def test_deprecated_gender(
|
|||||||
assert mock_process_tts.call_args.kwargs["gender"] == gender_option
|
assert mock_process_tts.call_args.kwargs["gender"] == gender_option
|
||||||
assert mock_process_tts.call_args.kwargs["voice"] == "JennyNeural"
|
assert mock_process_tts.call_args.kwargs["voice"] == "JennyNeural"
|
||||||
assert mock_process_tts.call_args.kwargs["output"] == "mp3"
|
assert mock_process_tts.call_args.kwargs["output"] == "mp3"
|
||||||
issue = issue_registry.async_get_issue("cloud", "deprecated_gender")
|
issue = issue_registry.async_get_issue("cloud", issue_id)
|
||||||
assert issue is not None
|
assert issue is not None
|
||||||
assert issue.breaks_in_ha_version == "2024.10.0"
|
assert issue.breaks_in_ha_version == "2024.10.0"
|
||||||
assert issue.is_fixable is True
|
assert issue.is_fixable is True
|
||||||
@ -650,3 +692,44 @@ async def test_deprecated_gender(
|
|||||||
"deprecated_option": "gender",
|
"deprecated_option": "gender",
|
||||||
"replacement_option": "voice",
|
"replacement_option": "voice",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resp = await client.post(
|
||||||
|
"/api/repairs/issues/fix",
|
||||||
|
json={"handler": DOMAIN, "issue_id": issue.issue_id},
|
||||||
|
)
|
||||||
|
|
||||||
|
assert resp.status == HTTPStatus.OK
|
||||||
|
data = await resp.json()
|
||||||
|
|
||||||
|
flow_id = data["flow_id"]
|
||||||
|
assert data == {
|
||||||
|
"type": "form",
|
||||||
|
"flow_id": flow_id,
|
||||||
|
"handler": DOMAIN,
|
||||||
|
"step_id": "confirm",
|
||||||
|
"data_schema": [],
|
||||||
|
"errors": None,
|
||||||
|
"description_placeholders": {
|
||||||
|
"integration_name": "Home Assistant Cloud",
|
||||||
|
"deprecated_option": "gender",
|
||||||
|
"replacement_option": "voice",
|
||||||
|
},
|
||||||
|
"last_step": None,
|
||||||
|
"preview": None,
|
||||||
|
}
|
||||||
|
|
||||||
|
resp = await client.post(f"/api/repairs/issues/fix/{flow_id}")
|
||||||
|
|
||||||
|
assert resp.status == HTTPStatus.OK
|
||||||
|
data = await resp.json()
|
||||||
|
|
||||||
|
flow_id = data["flow_id"]
|
||||||
|
assert data == {
|
||||||
|
"type": "create_entry",
|
||||||
|
"flow_id": flow_id,
|
||||||
|
"handler": DOMAIN,
|
||||||
|
"description": None,
|
||||||
|
"description_placeholders": None,
|
||||||
|
}
|
||||||
|
|
||||||
|
assert not issue_registry.async_get_issue(DOMAIN, issue_id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user