Remove cloud assist pipeline setup from cloud client (#92056)
This commit is contained in:
parent
6b931b208f
commit
ed737f306b
9 changed files with 119 additions and 133 deletions
|
@ -104,45 +104,68 @@ async def test_google_actions_sync_fails(
|
|||
|
||||
|
||||
async def test_login_view(hass: HomeAssistant, cloud_client) -> None:
|
||||
"""Test logging in."""
|
||||
create_cloud_assist_pipeline_mock = AsyncMock()
|
||||
hass.data["cloud"] = MagicMock(
|
||||
login=AsyncMock(),
|
||||
client=Mock(
|
||||
cloud_pipeline="12345",
|
||||
create_cloud_assist_pipeline=create_cloud_assist_pipeline_mock,
|
||||
),
|
||||
)
|
||||
"""Test logging in when an assist pipeline is available."""
|
||||
hass.data["cloud"] = MagicMock(login=AsyncMock())
|
||||
|
||||
req = await cloud_client.post(
|
||||
"/api/cloud/login", json={"email": "my_username", "password": "my_password"}
|
||||
)
|
||||
with patch(
|
||||
"homeassistant.components.cloud.http_api.assist_pipeline.async_get_pipelines",
|
||||
return_value=[
|
||||
Mock(
|
||||
conversation_engine="homeassistant",
|
||||
id="12345",
|
||||
stt_engine=DOMAIN,
|
||||
tts_engine=DOMAIN,
|
||||
)
|
||||
],
|
||||
), patch(
|
||||
"homeassistant.components.cloud.http_api.assist_pipeline.async_create_default_pipeline",
|
||||
) as create_pipeline_mock:
|
||||
req = await cloud_client.post(
|
||||
"/api/cloud/login", json={"email": "my_username", "password": "my_password"}
|
||||
)
|
||||
|
||||
assert req.status == HTTPStatus.OK
|
||||
result = await req.json()
|
||||
assert result == {"success": True, "cloud_pipeline": "12345"}
|
||||
create_cloud_assist_pipeline_mock.assert_not_awaited()
|
||||
create_pipeline_mock.assert_not_awaited()
|
||||
|
||||
|
||||
async def test_login_view_create_pipeline(hass: HomeAssistant, cloud_client) -> None:
|
||||
"""Test logging in when no assist pipeline is available."""
|
||||
create_cloud_assist_pipeline_mock = AsyncMock()
|
||||
hass.data["cloud"] = MagicMock(
|
||||
login=AsyncMock(),
|
||||
client=Mock(
|
||||
cloud_pipeline=None,
|
||||
create_cloud_assist_pipeline=create_cloud_assist_pipeline_mock,
|
||||
),
|
||||
)
|
||||
hass.data["cloud"] = MagicMock(login=AsyncMock())
|
||||
|
||||
req = await cloud_client.post(
|
||||
"/api/cloud/login", json={"email": "my_username", "password": "my_password"}
|
||||
)
|
||||
with patch(
|
||||
"homeassistant.components.cloud.http_api.assist_pipeline.async_create_default_pipeline",
|
||||
return_value=AsyncMock(id="12345"),
|
||||
) as create_pipeline_mock:
|
||||
req = await cloud_client.post(
|
||||
"/api/cloud/login", json={"email": "my_username", "password": "my_password"}
|
||||
)
|
||||
|
||||
assert req.status == HTTPStatus.OK
|
||||
result = await req.json()
|
||||
assert result == {"success": True, "cloud_pipeline": "12345"}
|
||||
create_pipeline_mock.assert_awaited_once_with(hass, "cloud", "cloud")
|
||||
|
||||
|
||||
async def test_login_view_create_pipeline_fail(
|
||||
hass: HomeAssistant, cloud_client
|
||||
) -> None:
|
||||
"""Test logging in when no assist pipeline is available."""
|
||||
hass.data["cloud"] = MagicMock(login=AsyncMock())
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.cloud.http_api.assist_pipeline.async_create_default_pipeline",
|
||||
return_value=None,
|
||||
) as create_pipeline_mock:
|
||||
req = await cloud_client.post(
|
||||
"/api/cloud/login", json={"email": "my_username", "password": "my_password"}
|
||||
)
|
||||
|
||||
assert req.status == HTTPStatus.OK
|
||||
result = await req.json()
|
||||
assert result == {"success": True, "cloud_pipeline": None}
|
||||
create_cloud_assist_pipeline_mock.assert_awaited_once()
|
||||
create_pipeline_mock.assert_awaited_once_with(hass, "cloud", "cloud")
|
||||
|
||||
|
||||
async def test_login_view_random_exception(cloud_client) -> None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue