mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Bump nyt_games to 0.4.0 (#126564)
This commit is contained in:
parent
28c2df37ed
commit
714a1cc311
@ -24,7 +24,7 @@ class NYTGamesConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
session = async_get_clientsession(self.hass)
|
session = async_get_clientsession(self.hass)
|
||||||
client = NYTGamesClient(user_input[CONF_TOKEN], session=session)
|
client = NYTGamesClient(user_input[CONF_TOKEN], session=session)
|
||||||
try:
|
try:
|
||||||
latest_stats = await client.get_latest_stats()
|
user_id = await client.get_user_id()
|
||||||
except NYTGamesAuthenticationError:
|
except NYTGamesAuthenticationError:
|
||||||
errors["base"] = "invalid_auth"
|
errors["base"] = "invalid_auth"
|
||||||
except NYTGamesError:
|
except NYTGamesError:
|
||||||
@ -32,7 +32,7 @@ class NYTGamesConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
except Exception: # noqa: BLE001
|
except Exception: # noqa: BLE001
|
||||||
errors["base"] = "unknown"
|
errors["base"] = "unknown"
|
||||||
else:
|
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()
|
self._abort_if_unique_id_configured()
|
||||||
return self.async_create_entry(title="NYT Games", data=user_input)
|
return self.async_create_entry(title="NYT Games", data=user_input)
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
|
@ -33,6 +33,6 @@ class NYTGamesCoordinator(DataUpdateCoordinator[Wordle]):
|
|||||||
|
|
||||||
async def _async_update_data(self) -> Wordle:
|
async def _async_update_data(self) -> Wordle:
|
||||||
try:
|
try:
|
||||||
return (await self.client.get_latest_stats()).stats.wordle
|
return (await self.client.get_latest_stats()).wordle
|
||||||
except NYTGamesError as error:
|
except NYTGamesError as error:
|
||||||
raise UpdateFailed(error) from error
|
raise UpdateFailed(error) from error
|
||||||
|
@ -15,7 +15,9 @@ class NYTGamesEntity(CoordinatorEntity[NYTGamesCoordinator]):
|
|||||||
def __init__(self, coordinator: NYTGamesCoordinator) -> None:
|
def __init__(self, coordinator: NYTGamesCoordinator) -> None:
|
||||||
"""Initialize a NYT Games entity."""
|
"""Initialize a NYT Games entity."""
|
||||||
super().__init__(coordinator)
|
super().__init__(coordinator)
|
||||||
|
unique_id = coordinator.config_entry.unique_id
|
||||||
|
assert unique_id is not None
|
||||||
self._attr_device_info = DeviceInfo(
|
self._attr_device_info = DeviceInfo(
|
||||||
identifiers={(DOMAIN, str(coordinator.config_entry.unique_id))},
|
identifiers={(DOMAIN, unique_id)},
|
||||||
manufacturer="New York Times",
|
manufacturer="New York Times",
|
||||||
)
|
)
|
||||||
|
@ -6,5 +6,5 @@
|
|||||||
"documentation": "https://www.home-assistant.io/integrations/nyt_games",
|
"documentation": "https://www.home-assistant.io/integrations/nyt_games",
|
||||||
"integration_type": "service",
|
"integration_type": "service",
|
||||||
"iot_class": "cloud_polling",
|
"iot_class": "cloud_polling",
|
||||||
"requirements": ["nyt_games==0.3.0"]
|
"requirements": ["nyt_games==0.4.0"]
|
||||||
}
|
}
|
||||||
|
@ -1484,7 +1484,7 @@ numato-gpio==0.13.0
|
|||||||
numpy==1.26.0
|
numpy==1.26.0
|
||||||
|
|
||||||
# homeassistant.components.nyt_games
|
# homeassistant.components.nyt_games
|
||||||
nyt_games==0.3.0
|
nyt_games==0.4.0
|
||||||
|
|
||||||
# homeassistant.components.oasa_telematics
|
# homeassistant.components.oasa_telematics
|
||||||
oasatelematics==0.3
|
oasatelematics==0.3
|
||||||
|
@ -1232,7 +1232,7 @@ numato-gpio==0.13.0
|
|||||||
numpy==1.26.0
|
numpy==1.26.0
|
||||||
|
|
||||||
# homeassistant.components.nyt_games
|
# homeassistant.components.nyt_games
|
||||||
nyt_games==0.3.0
|
nyt_games==0.4.0
|
||||||
|
|
||||||
# homeassistant.components.google
|
# homeassistant.components.google
|
||||||
oauth2client==4.1.3
|
oauth2client==4.1.3
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
from collections.abc import Generator
|
from collections.abc import Generator
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from nyt_games.models import LatestData
|
from nyt_games.models import WordleStats
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.nyt_games.const import DOMAIN
|
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 = 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)
|
load_fixture("latest.json", DOMAIN)
|
||||||
).player
|
).player.stats
|
||||||
|
client.get_user_id.return_value = 218886794
|
||||||
yield client
|
yield client
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ async def test_flow_errors(
|
|||||||
error: str,
|
error: str,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test flow errors."""
|
"""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(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
@ -70,7 +70,7 @@ async def test_flow_errors(
|
|||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {"base": error}
|
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 = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user