Update error handling in update coordinator (#32452)

This commit is contained in:
Paulus Schoutsen 2020-03-04 08:05:46 -08:00 committed by GitHub
parent f62322cfb4
commit b27c46750c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 58 additions and 67 deletions

View file

@ -1,5 +1,4 @@
"""The tests for the Updater component."""
import asyncio
from unittest.mock import Mock
from asynctest import patch
@ -130,17 +129,6 @@ async def test_get_newest_version_analytics_when_huuid(hass, aioclient_mock):
assert res == (MOCK_RESPONSE["version"], MOCK_RESPONSE["release-notes"])
async def test_error_fetching_new_version_timeout(hass):
"""Test we handle timeout error while fetching new version."""
with patch(
"homeassistant.helpers.system_info.async_get_system_info",
Mock(return_value=mock_coro({"fake": "bla"})),
), patch("async_timeout.timeout", side_effect=asyncio.TimeoutError), pytest.raises(
UpdateFailed
):
await updater.get_newest_version(hass, MOCK_HUUID, False)
async def test_error_fetching_new_version_bad_json(hass, aioclient_mock):
"""Test we handle json error while fetching new version."""
aioclient_mock.post(updater.UPDATER_URL, text="not json")