mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Indicate database migration in /api/core/state response (#122445)
* Indicate database migration in /api/core/state response * Change API response according to review comment * Adjust API response * Update test * Add test
This commit is contained in:
@@ -770,4 +770,43 @@ async def test_api_core_state(hass: HomeAssistant, mock_api_client: TestClient)
|
||||
resp = await mock_api_client.get("/api/core/state")
|
||||
assert resp.status == HTTPStatus.OK
|
||||
json = await resp.json()
|
||||
assert json["state"] == "RUNNING"
|
||||
assert json == {
|
||||
"state": "RUNNING",
|
||||
"recorder_state": {"migration_in_progress": False, "migration_is_live": False},
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("migration_in_progress", "migration_is_live"),
|
||||
[
|
||||
(False, False),
|
||||
(False, True),
|
||||
(True, False),
|
||||
(True, True),
|
||||
],
|
||||
)
|
||||
async def test_api_core_state_recorder_migrating(
|
||||
hass: HomeAssistant,
|
||||
mock_api_client: TestClient,
|
||||
migration_in_progress: bool,
|
||||
migration_is_live: bool,
|
||||
) -> None:
|
||||
"""Test getting core status."""
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.helpers.recorder.async_migration_in_progress",
|
||||
return_value=migration_in_progress,
|
||||
),
|
||||
patch(
|
||||
"homeassistant.helpers.recorder.async_migration_is_live",
|
||||
return_value=migration_is_live,
|
||||
),
|
||||
):
|
||||
resp = await mock_api_client.get("/api/core/state")
|
||||
assert resp.status == HTTPStatus.OK
|
||||
json = await resp.json()
|
||||
expected_recorder_state = {
|
||||
"migration_in_progress": migration_in_progress,
|
||||
"migration_is_live": migration_is_live,
|
||||
}
|
||||
assert json == {"state": "RUNNING", "recorder_state": expected_recorder_state}
|
||||
|
||||
Reference in New Issue
Block a user