Skip to content

Commit

Permalink
Testing and type fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mdegat01 committed Apr 14, 2023
1 parent 23dad47 commit 08d552b
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
2 changes: 1 addition & 1 deletion homeassistant/components/hassio/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ async def async_update_core(

@bind_hass
@_api_bool
async def async_apply_suggestion(hass: HomeAssistant, suggestion_uuid: str) -> dict:
async def async_apply_suggestion(hass: HomeAssistant, suggestion_uuid: str) -> bool:
"""Apply a suggestion from supervisor's resolution center.
The caller of the function should handle HassioAPIError.
Expand Down
6 changes: 1 addition & 5 deletions homeassistant/components/hassio/issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,7 @@ def add_issue(self, issue: Issue) -> None:
self._issues[issue.uuid] = issue

async def add_issue_from_data(self, data: IssueDataType) -> None:
"""Add issue from data to list after getting suggestions (if necessary)."""
if ATTR_SUGGESTIONS in data:
self.add_issue(Issue.from_dict(data))
return

"""Add issue from data to list after getting latest suggestions."""
try:
suggestions = (await self._client.get_suggestions_for_issue(data["uuid"]))[
ATTR_SUGGESTIONS
Expand Down
33 changes: 33 additions & 0 deletions tests/components/hassio/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,3 +682,36 @@ async def test_supervisor_issues_suggestions_fail(
msg = await client.receive_json()
assert msg["success"]
assert len(msg["result"]["issues"]) == 0


async def test_supervisor_remove_missing_issue_without_error(
hass: HomeAssistant,
aioclient_mock: AiohttpClientMocker,
hass_ws_client: WebSocketGenerator,
) -> None:
"""Test HA skips message to remove issue that it didn't know about (sync issue)."""
mock_resolution_info(aioclient_mock)

result = await async_setup_component(hass, "hassio", {})
assert result

client = await hass_ws_client(hass)

await client.send_json(
{
"id": 5,
"type": "supervisor/event",
"data": {
"event": "issue_removed",
"data": {
"uuid": "1234",
"type": "reboot_required",
"context": "system",
"reference": None,
},
},
}
)
msg = await client.receive_json()
assert msg["success"]
await hass.async_block_till_done()

0 comments on commit 08d552b

Please sign in to comment.