mirror of
https://github.com/home-assistant/core.git
synced 2026-09-05 04:51:05 +01:00
Bump pynintendoparental to 2.6.2 (#179985)
This commit is contained in:
@@ -8,5 +8,5 @@
|
||||
"iot_class": "cloud_polling",
|
||||
"loggers": ["pynintendoauth", "pynintendoparental"],
|
||||
"quality_scale": "bronze",
|
||||
"requirements": ["pynintendoauth==1.0.3", "pynintendoparental==2.5.0"]
|
||||
"requirements": ["pynintendoauth==1.0.3", "pynintendoparental==2.6.2"]
|
||||
}
|
||||
|
||||
@@ -108,9 +108,9 @@ async def async_setup_entry(
|
||||
for device in entry.runtime_data.api.devices.values():
|
||||
entities.extend(
|
||||
NintendoParentalControlsPlayerSensorEntity(
|
||||
entry.runtime_data, device, player_id, sensor
|
||||
entry.runtime_data, device, player, sensor
|
||||
)
|
||||
for player_id in device.players
|
||||
for player in device.players
|
||||
for sensor in PLAYER_SENSOR_DESCRIPTIONS
|
||||
)
|
||||
async_add_entities(entities)
|
||||
@@ -153,17 +153,18 @@ class NintendoParentalControlsPlayerSensorEntity(NintendoDevice, SensorEntity):
|
||||
self,
|
||||
coordinator: NintendoUpdateCoordinator,
|
||||
device: Device,
|
||||
player_id: str,
|
||||
player: Player,
|
||||
description: NintendoParentalControlsPlayerSensorEntityDescription,
|
||||
) -> None:
|
||||
"""Initialize the sensor."""
|
||||
super().__init__(coordinator=coordinator, device=device, key=description.key)
|
||||
self.entity_description = description
|
||||
self.player_id = player_id
|
||||
player_obj = device.get_player(player_id)
|
||||
nickname = player_obj.nickname or ""
|
||||
self.player_id = player.player_id
|
||||
nickname = player.nickname or ""
|
||||
self._attr_translation_placeholders = {"nickname": nickname}
|
||||
self._attr_unique_id = f"{device.device_id}_{player_id}_{description.key}"
|
||||
self._attr_unique_id = (
|
||||
f"{device.device_id}_{player.player_id}_{description.key}"
|
||||
)
|
||||
|
||||
@property
|
||||
@override
|
||||
|
||||
Generated
+1
-1
@@ -2414,7 +2414,7 @@ pynina==1.0.2
|
||||
pynintendoauth==1.0.3
|
||||
|
||||
# homeassistant.components.nintendo_parental_controls
|
||||
pynintendoparental==2.5.0
|
||||
pynintendoparental==2.6.2
|
||||
|
||||
# homeassistant.components.nobo_hub
|
||||
pynobo==1.9.0
|
||||
|
||||
@@ -5,9 +5,14 @@ from datetime import datetime, time
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
||||
from pynintendoparental import NintendoParental
|
||||
from pynintendoparental.application import (
|
||||
Application,
|
||||
ApplicationRegistry,
|
||||
PlayedAppUsage,
|
||||
)
|
||||
from pynintendoparental.device import Device
|
||||
from pynintendoparental.enum import DeviceTimerMode
|
||||
from pynintendoparental.player import Player
|
||||
from pynintendoparental.player import Player, PlayerRegistry
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.nintendo_parental_controls.const import DOMAIN
|
||||
@@ -28,30 +33,36 @@ def mock_config_entry() -> MockConfigEntry:
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_nintendo_player() -> Player:
|
||||
def mock_nintendo_app() -> Application:
|
||||
"""Return a mocked Nintendo application."""
|
||||
mock_app = MagicMock(spec=Application)
|
||||
mock_app.application_id = "testappid"
|
||||
mock_app.name = "Test Game Name"
|
||||
return mock_app
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_nintendo_player(mock_nintendo_app: Application) -> Player:
|
||||
"""Return a mocked player."""
|
||||
# This class has no async methods
|
||||
mock = MagicMock(spec=Player)
|
||||
mock.player_id = "testplayerid"
|
||||
mock.nickname = "HA Gamer"
|
||||
mock.apps = [
|
||||
{
|
||||
"playingTime": 15,
|
||||
"meta": {
|
||||
"title": "Test Game Name",
|
||||
"imageUri": {"medium": "http://localhost/medium.png"},
|
||||
"shopUri": "http://localhost/shop-test-game-name",
|
||||
},
|
||||
}
|
||||
]
|
||||
mock.apps = [PlayedAppUsage(application=mock_nintendo_app, playing_time=110)]
|
||||
mock.playing_time = 110
|
||||
mock.player_image = "http://localhost/image.png"
|
||||
return mock
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_nintendo_device(mock_nintendo_player: Player) -> Device:
|
||||
def mock_nintendo_device(
|
||||
mock_nintendo_app: Application, mock_nintendo_player: Player
|
||||
) -> Device:
|
||||
"""Return a mocked device."""
|
||||
applications = ApplicationRegistry()
|
||||
players = PlayerRegistry()
|
||||
applications.add_application(mock_nintendo_app)
|
||||
players.add_player(mock_nintendo_player)
|
||||
mock = AsyncMock(spec=Device)
|
||||
mock.device_id = "testdevid"
|
||||
mock.name = "Home Assistant Test"
|
||||
@@ -74,9 +85,9 @@ def mock_nintendo_device(mock_nintendo_player: Player) -> Device:
|
||||
mock.forced_termination_mode = True
|
||||
mock.model = "Test Model"
|
||||
mock.generation = "P00"
|
||||
mock.players = {mock_nintendo_player.player_id: mock_nintendo_player}
|
||||
mock.get_player = MagicMock()
|
||||
mock.get_player.return_value = mock_nintendo_player
|
||||
mock.applications = applications
|
||||
mock.players = players
|
||||
mock.get_player = MagicMock(side_effect=players.get_player)
|
||||
return mock
|
||||
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ async def test_player_sensor_none_handling(
|
||||
assert state.state == "110"
|
||||
assert state.attributes["entity_picture"] == "http://localhost/image.png"
|
||||
|
||||
mock_nintendo_client.devices["testdevid"].players = {}
|
||||
mock_nintendo_client.devices["testdevid"].players.remove_player("testplayerid")
|
||||
freezer.tick(60)
|
||||
async_fire_time_changed(hass)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
Reference in New Issue
Block a user