mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Check for empty release array (#64973)
This commit is contained in:
parent
2b101dd5c2
commit
eb5c6076af
@ -97,7 +97,7 @@ class RepositoryReleaseDataUpdateCoordinator(
|
|||||||
response: GitHubResponseModel[GitHubReleaseModel | None],
|
response: GitHubResponseModel[GitHubReleaseModel | None],
|
||||||
) -> GitHubReleaseModel | None:
|
) -> GitHubReleaseModel | None:
|
||||||
"""Parse the response from GitHub API."""
|
"""Parse the response from GitHub API."""
|
||||||
if response.data is None:
|
if not response.data:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
for release in response.data:
|
for release in response.data:
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
"""Test GitHub sensor."""
|
"""Test GitHub sensor."""
|
||||||
from unittest.mock import patch
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
from aiogithubapi import GitHubNotModifiedException
|
from aiogithubapi import GitHubNotModifiedException
|
||||||
import pytest
|
import pytest
|
||||||
@ -40,3 +40,23 @@ async def test_sensor_updates_with_not_modified_content(
|
|||||||
)
|
)
|
||||||
new_state = hass.states.get(TEST_SENSOR_ENTITY)
|
new_state = hass.states.get(TEST_SENSOR_ENTITY)
|
||||||
assert state.state == new_state.state
|
assert state.state == new_state.state
|
||||||
|
|
||||||
|
|
||||||
|
async def test_sensor_updates_with_empty_release_array(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
init_integration: MockConfigEntry,
|
||||||
|
) -> None:
|
||||||
|
"""Test the sensor updates by default GitHub sensors."""
|
||||||
|
state = hass.states.get(TEST_SENSOR_ENTITY)
|
||||||
|
assert state.state == "v1.0.0"
|
||||||
|
|
||||||
|
with patch(
|
||||||
|
"aiogithubapi.namespaces.releases.GitHubReleasesNamespace.list",
|
||||||
|
return_value=MagicMock(data=[]),
|
||||||
|
):
|
||||||
|
|
||||||
|
async_fire_time_changed(hass, dt.utcnow() + DEFAULT_UPDATE_INTERVAL)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
new_state = hass.states.get(TEST_SENSOR_ENTITY)
|
||||||
|
assert new_state.state == "unavailable"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user