Refactor coordinator data update and exception handling in Xbox integration (#154848)

This commit is contained in:
Manu
2025-10-21 15:07:37 +02:00
committed by GitHub
parent b08eb3a201
commit 84d9fa3bd7
6 changed files with 141 additions and 114 deletions
+30
View File
@@ -64,3 +64,33 @@ async def test_config_implementation_not_available(
await hass.async_block_till_done()
assert config_entry.state is ConfigEntryState.SETUP_RETRY
@pytest.mark.parametrize("exception", [ConnectTimeout, HTTPStatusError, ProtocolError])
@pytest.mark.parametrize(
("provider", "method"),
[
("smartglass", "get_console_status"),
("catalog", "get_product_from_alternate_id"),
("people", "get_friends_own_batch"),
("people", "get_friends_own"),
],
)
async def test_coordinator_update_failed(
hass: HomeAssistant,
config_entry: MockConfigEntry,
xbox_live_client: AsyncMock,
exception: Exception,
provider: str,
method: str,
) -> None:
"""Test coordinator update failed."""
provider = getattr(xbox_live_client, provider)
getattr(provider, method).side_effect = exception
config_entry.add_to_hass(hass)
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
assert config_entry.state is ConfigEntryState.SETUP_RETRY