Fix translation missing errors in supervisor tests (#130640)

* Fix translation missing errors in supervisor tests

* Add suggestion to suggestions_by_issue mock
This commit is contained in:
Mike Degatano 2024-11-14 15:11:33 -05:00 committed by GitHub
parent a1e3c7513b
commit 2344b7c9eb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -323,6 +323,17 @@ async def test_reset_issues_supervisor_restart(
uuid=(uuid := uuid4()), uuid=(uuid := uuid4()),
) )
], ],
suggestions_by_issue={
uuid: [
Suggestion(
SuggestionType.EXECUTE_REBOOT,
context=ContextType.SYSTEM,
reference=None,
uuid=uuid4(),
auto=False,
)
]
},
) )
result = await async_setup_component(hass, "hassio", {}) result = await async_setup_component(hass, "hassio", {})
@ -341,7 +352,7 @@ async def test_reset_issues_supervisor_restart(
uuid=uuid.hex, uuid=uuid.hex,
context="system", context="system",
type_="reboot_required", type_="reboot_required",
fixable=False, fixable=True,
reference=None, reference=None,
) )
@ -510,9 +521,9 @@ async def test_supervisor_issues(
supervisor_client, supervisor_client,
issues=[ issues=[
Issue( Issue(
type=IssueType.REBOOT_REQUIRED, type=IssueType.DETACHED_ADDON_MISSING,
context=ContextType.SYSTEM, context=ContextType.ADDON,
reference=None, reference="test",
uuid=(uuid_issue1 := uuid4()), uuid=(uuid_issue1 := uuid4()),
), ),
Issue( Issue(
@ -553,10 +564,11 @@ async def test_supervisor_issues(
assert_issue_repair_in_list( assert_issue_repair_in_list(
msg["result"]["issues"], msg["result"]["issues"],
uuid=uuid_issue1.hex, uuid=uuid_issue1.hex,
context="system", context="addon",
type_="reboot_required", type_="detached_addon_missing",
fixable=False, fixable=False,
reference=None, reference="test",
placeholders={"addon_url": "/hassio/addon/test", "addon": "test"},
) )
assert_issue_repair_in_list( assert_issue_repair_in_list(
msg["result"]["issues"], msg["result"]["issues"],
@ -571,31 +583,39 @@ async def test_supervisor_issues(
@pytest.mark.usefixtures("all_setup_requests") @pytest.mark.usefixtures("all_setup_requests")
async def test_supervisor_issues_initial_failure( async def test_supervisor_issues_initial_failure(
hass: HomeAssistant, hass: HomeAssistant,
supervisor_client: AsyncMock,
resolution_info: AsyncMock, resolution_info: AsyncMock,
resolution_suggestions_for_issue: AsyncMock,
hass_ws_client: WebSocketGenerator, hass_ws_client: WebSocketGenerator,
freezer: FrozenDateTimeFactory, freezer: FrozenDateTimeFactory,
) -> None: ) -> None:
"""Test issues manager retries after initial update failure.""" """Test issues manager retries after initial update failure."""
resolution_info.side_effect = [ mock_resolution_info(
SupervisorBadRequestError("System is not ready with state: setup"), supervisor_client,
ResolutionInfo( unsupported=[],
unsupported=[], unhealthy=[],
unhealthy=[], issues=[
suggestions=[], Issue(
issues=[ type=IssueType.REBOOT_REQUIRED,
Issue( context=ContextType.SYSTEM,
type=IssueType.REBOOT_REQUIRED, reference=None,
uuid=(uuid := uuid4()),
)
],
suggestions_by_issue={
uuid: [
Suggestion(
SuggestionType.EXECUTE_REBOOT,
context=ContextType.SYSTEM, context=ContextType.SYSTEM,
reference=None, reference=None,
uuid=uuid4(), uuid=uuid4(),
auto=False,
) )
], ]
checks=[ },
Check(enabled=True, slug=CheckType.SUPERVISOR_TRUST), )
Check(enabled=True, slug=CheckType.FREE_SPACE), resolution_info.side_effect = [
], SupervisorBadRequestError("System is not ready with state: setup"),
), resolution_info.return_value,
] ]
with patch("homeassistant.components.hassio.issues.REQUEST_REFRESH_DELAY", new=0.1): with patch("homeassistant.components.hassio.issues.REQUEST_REFRESH_DELAY", new=0.1):
@ -643,6 +663,14 @@ async def test_supervisor_issues_add_remove(
"type": "reboot_required", "type": "reboot_required",
"context": "system", "context": "system",
"reference": None, "reference": None,
"suggestions": [
{
"uuid": uuid4().hex,
"type": "execute_reboot",
"context": "system",
"reference": None,
}
],
}, },
}, },
} }
@ -655,46 +683,6 @@ async def test_supervisor_issues_add_remove(
msg = await client.receive_json() msg = await client.receive_json()
assert msg["success"] assert msg["success"]
assert len(msg["result"]["issues"]) == 1 assert len(msg["result"]["issues"]) == 1
assert_issue_repair_in_list(
msg["result"]["issues"],
uuid=issue_uuid,
context="system",
type_="reboot_required",
fixable=False,
reference=None,
)
await client.send_json(
{
"id": 3,
"type": "supervisor/event",
"data": {
"event": "issue_changed",
"data": {
"uuid": issue_uuid,
"type": "reboot_required",
"context": "system",
"reference": None,
"suggestions": [
{
"uuid": uuid4().hex,
"type": "execute_reboot",
"context": "system",
"reference": None,
}
],
},
},
}
)
msg = await client.receive_json()
assert msg["success"]
await hass.async_block_till_done()
await client.send_json({"id": 4, "type": "repairs/list_issues"})
msg = await client.receive_json()
assert msg["success"]
assert len(msg["result"]["issues"]) == 1
assert_issue_repair_in_list( assert_issue_repair_in_list(
msg["result"]["issues"], msg["result"]["issues"],
uuid=issue_uuid, uuid=issue_uuid,
@ -706,7 +694,7 @@ async def test_supervisor_issues_add_remove(
await client.send_json( await client.send_json(
{ {
"id": 5, "id": 3,
"type": "supervisor/event", "type": "supervisor/event",
"data": { "data": {
"event": "issue_removed", "event": "issue_removed",
@ -723,7 +711,7 @@ async def test_supervisor_issues_add_remove(
assert msg["success"] assert msg["success"]
await hass.async_block_till_done() await hass.async_block_till_done()
await client.send_json({"id": 6, "type": "repairs/list_issues"}) await client.send_json({"id": 4, "type": "repairs/list_issues"})
msg = await client.receive_json() msg = await client.receive_json()
assert msg["success"] assert msg["success"]
assert msg["result"] == {"issues": []} assert msg["result"] == {"issues": []}