Skip to content

Commit

Permalink
Fix translation missing errors in supervisor tests (#130640)
Browse files Browse the repository at this point in the history
* Fix translation missing errors in supervisor tests

* Add suggestion to suggestions_by_issue mock
  • Loading branch information
mdegat01 authored Nov 14, 2024
1 parent a1e3c75 commit 2344b7c
Showing 1 changed file with 46 additions and 58 deletions.
104 changes: 46 additions & 58 deletions tests/components/hassio/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,17 @@ async def test_reset_issues_supervisor_restart(
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", {})
Expand All @@ -341,7 +352,7 @@ async def test_reset_issues_supervisor_restart(
uuid=uuid.hex,
context="system",
type_="reboot_required",
fixable=False,
fixable=True,
reference=None,
)

Expand Down Expand Up @@ -510,9 +521,9 @@ async def test_supervisor_issues(
supervisor_client,
issues=[
Issue(
type=IssueType.REBOOT_REQUIRED,
context=ContextType.SYSTEM,
reference=None,
type=IssueType.DETACHED_ADDON_MISSING,
context=ContextType.ADDON,
reference="test",
uuid=(uuid_issue1 := uuid4()),
),
Issue(
Expand Down Expand Up @@ -553,10 +564,11 @@ async def test_supervisor_issues(
assert_issue_repair_in_list(
msg["result"]["issues"],
uuid=uuid_issue1.hex,
context="system",
type_="reboot_required",
context="addon",
type_="detached_addon_missing",
fixable=False,
reference=None,
reference="test",
placeholders={"addon_url": "/hassio/addon/test", "addon": "test"},
)
assert_issue_repair_in_list(
msg["result"]["issues"],
Expand All @@ -571,31 +583,39 @@ async def test_supervisor_issues(
@pytest.mark.usefixtures("all_setup_requests")
async def test_supervisor_issues_initial_failure(
hass: HomeAssistant,
supervisor_client: AsyncMock,
resolution_info: AsyncMock,
resolution_suggestions_for_issue: AsyncMock,
hass_ws_client: WebSocketGenerator,
freezer: FrozenDateTimeFactory,
) -> None:
"""Test issues manager retries after initial update failure."""
resolution_info.side_effect = [
SupervisorBadRequestError("System is not ready with state: setup"),
ResolutionInfo(
unsupported=[],
unhealthy=[],
suggestions=[],
issues=[
Issue(
type=IssueType.REBOOT_REQUIRED,
mock_resolution_info(
supervisor_client,
unsupported=[],
unhealthy=[],
issues=[
Issue(
type=IssueType.REBOOT_REQUIRED,
context=ContextType.SYSTEM,
reference=None,
uuid=(uuid := uuid4()),
)
],
suggestions_by_issue={
uuid: [
Suggestion(
SuggestionType.EXECUTE_REBOOT,
context=ContextType.SYSTEM,
reference=None,
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):
Expand Down Expand Up @@ -643,38 +663,6 @@ async def test_supervisor_issues_add_remove(
"type": "reboot_required",
"context": "system",
"reference": None,
},
},
}
)
msg = await client.receive_json()
assert msg["success"]
await hass.async_block_till_done()

await client.send_json({"id": 2, "type": "repairs/list_issues"})
msg = await client.receive_json()
assert msg["success"]
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,
Expand All @@ -691,7 +679,7 @@ async def test_supervisor_issues_add_remove(
assert msg["success"]
await hass.async_block_till_done()

await client.send_json({"id": 4, "type": "repairs/list_issues"})
await client.send_json({"id": 2, "type": "repairs/list_issues"})
msg = await client.receive_json()
assert msg["success"]
assert len(msg["result"]["issues"]) == 1
Expand All @@ -706,7 +694,7 @@ async def test_supervisor_issues_add_remove(

await client.send_json(
{
"id": 5,
"id": 3,
"type": "supervisor/event",
"data": {
"event": "issue_removed",
Expand All @@ -723,7 +711,7 @@ async def test_supervisor_issues_add_remove(
assert msg["success"]
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()
assert msg["success"]
assert msg["result"] == {"issues": []}
Expand Down

0 comments on commit 2344b7c

Please sign in to comment.