Bump nyt_games to 0.4.0 (#126564)

This commit is contained in:
Joost Lekkerkerker 2024-09-23 19:28:30 +02:00 committed by GitHub
parent 28c2df37ed
commit 714a1cc311
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 15 additions and 12 deletions

View file

@ -24,7 +24,7 @@ class NYTGamesConfigFlow(ConfigFlow, domain=DOMAIN):
session = async_get_clientsession(self.hass)
client = NYTGamesClient(user_input[CONF_TOKEN], session=session)
try:
latest_stats = await client.get_latest_stats()
user_id = await client.get_user_id()
except NYTGamesAuthenticationError:
errors["base"] = "invalid_auth"
except NYTGamesError:
@ -32,7 +32,7 @@ class NYTGamesConfigFlow(ConfigFlow, domain=DOMAIN):
except Exception: # noqa: BLE001
errors["base"] = "unknown"
else:
await self.async_set_unique_id(str(latest_stats.user_id))
await self.async_set_unique_id(str(user_id))
self._abort_if_unique_id_configured()
return self.async_create_entry(title="NYT Games", data=user_input)
return self.async_show_form(

View file

@ -33,6 +33,6 @@ class NYTGamesCoordinator(DataUpdateCoordinator[Wordle]):
async def _async_update_data(self) -> Wordle:
try:
return (await self.client.get_latest_stats()).stats.wordle
return (await self.client.get_latest_stats()).wordle
except NYTGamesError as error:
raise UpdateFailed(error) from error

View file

@ -15,7 +15,9 @@ class NYTGamesEntity(CoordinatorEntity[NYTGamesCoordinator]):
def __init__(self, coordinator: NYTGamesCoordinator) -> None:
"""Initialize a NYT Games entity."""
super().__init__(coordinator)
unique_id = coordinator.config_entry.unique_id
assert unique_id is not None
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, str(coordinator.config_entry.unique_id))},
identifiers={(DOMAIN, unique_id)},
manufacturer="New York Times",
)

View file

@ -6,5 +6,5 @@
"documentation": "https://www.home-assistant.io/integrations/nyt_games",
"integration_type": "service",
"iot_class": "cloud_polling",
"requirements": ["nyt_games==0.3.0"]
"requirements": ["nyt_games==0.4.0"]
}

View file

@ -1484,7 +1484,7 @@ numato-gpio==0.13.0
numpy==1.26.0
# homeassistant.components.nyt_games
nyt_games==0.3.0
nyt_games==0.4.0
# homeassistant.components.oasa_telematics
oasatelematics==0.3

View file

@ -1232,7 +1232,7 @@ numato-gpio==0.13.0
numpy==1.26.0
# homeassistant.components.nyt_games
nyt_games==0.3.0
nyt_games==0.4.0
# homeassistant.components.google
oauth2client==4.1.3

View file

@ -3,7 +3,7 @@
from collections.abc import Generator
from unittest.mock import patch
from nyt_games.models import LatestData
from nyt_games.models import WordleStats
import pytest
from homeassistant.components.nyt_games.const import DOMAIN
@ -37,9 +37,10 @@ def mock_nyt_games_client() -> Generator[AsyncMock]:
),
):
client = mock_client.return_value
client.get_latest_stats.return_value = LatestData.from_json(
client.get_latest_stats.return_value = WordleStats.from_json(
load_fixture("latest.json", DOMAIN)
).player
).player.stats
client.get_user_id.return_value = 218886794
yield client

View file

@ -53,7 +53,7 @@ async def test_flow_errors(
error: str,
) -> None:
"""Test flow errors."""
mock_nyt_games_client.get_latest_stats.side_effect = exception
mock_nyt_games_client.get_user_id.side_effect = exception
result = await hass.config_entries.flow.async_init(
DOMAIN,
@ -70,7 +70,7 @@ async def test_flow_errors(
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": error}
mock_nyt_games_client.get_latest_stats.side_effect = None
mock_nyt_games_client.get_user_id.side_effect = None
result = await hass.config_entries.flow.async_configure(
result["flow_id"],