mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Update ollama config_flow task to use eager_start (#115455)
The test now adds a delay because it finished too fast
This commit is contained in:
parent
f452c5b84e
commit
0bd4064212
@ -151,7 +151,6 @@ class OllamaConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
self.download_task = self.hass.async_create_background_task(
|
self.download_task = self.hass.async_create_background_task(
|
||||||
self.client.pull(self.model),
|
self.client.pull(self.model),
|
||||||
f"Downloading {self.model}",
|
f"Downloading {self.model}",
|
||||||
eager_start=False,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.download_task.done():
|
if self.download_task.done():
|
||||||
|
@ -205,6 +205,10 @@ async def test_download_error(hass: HomeAssistant) -> None:
|
|||||||
ollama.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
ollama.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
async def _delayed_runtime_error(*args, **kwargs):
|
||||||
|
await asyncio.sleep(0)
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
with (
|
with (
|
||||||
patch(
|
patch(
|
||||||
"homeassistant.components.ollama.config_flow.ollama.AsyncClient.list",
|
"homeassistant.components.ollama.config_flow.ollama.AsyncClient.list",
|
||||||
@ -212,7 +216,7 @@ async def test_download_error(hass: HomeAssistant) -> None:
|
|||||||
),
|
),
|
||||||
patch(
|
patch(
|
||||||
"homeassistant.components.ollama.config_flow.ollama.AsyncClient.pull",
|
"homeassistant.components.ollama.config_flow.ollama.AsyncClient.pull",
|
||||||
side_effect=RuntimeError(),
|
_delayed_runtime_error,
|
||||||
),
|
),
|
||||||
):
|
):
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user