Add icon translations to Github (#111614)
* Add icon translations to Github * Fix
This commit is contained in:
parent
510e7ccf76
commit
23353812a9
3 changed files with 64 additions and 6 deletions
42
homeassistant/components/github/icons.json
Normal file
42
homeassistant/components/github/icons.json
Normal file
|
@ -0,0 +1,42 @@
|
|||
{
|
||||
"entity": {
|
||||
"sensor": {
|
||||
"discussions_count": {
|
||||
"default": "mdi:forum"
|
||||
},
|
||||
"stargazers_count": {
|
||||
"default": "mdi:star"
|
||||
},
|
||||
"subscribers_count": {
|
||||
"default": "mdi:glasses"
|
||||
},
|
||||
"forks_count": {
|
||||
"default": "mdi:source-fork"
|
||||
},
|
||||
"issues_count": {
|
||||
"default": "mdi:github"
|
||||
},
|
||||
"pulls_count": {
|
||||
"default": "mdi:source-pull"
|
||||
},
|
||||
"latest_commit": {
|
||||
"default": "mdi:source-commit"
|
||||
},
|
||||
"latest_discussion": {
|
||||
"default": "mdi:forum"
|
||||
},
|
||||
"latest_release": {
|
||||
"default": "mdi:github"
|
||||
},
|
||||
"latest_issue": {
|
||||
"default": "mdi:github"
|
||||
},
|
||||
"latest_pull_request": {
|
||||
"default": "mdi:source-pull"
|
||||
},
|
||||
"latest_tag": {
|
||||
"default": "mdi:tag"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -28,7 +28,7 @@ class GitHubSensorEntityDescription(SensorEntityDescription):
|
|||
"""Describes GitHub issue sensor entity."""
|
||||
|
||||
value_fn: Callable[[dict[str, Any]], StateType]
|
||||
icon: str = "mdi:github"
|
||||
|
||||
attr_fn: Callable[[dict[str, Any]], Mapping[str, Any] | None] = lambda data: None
|
||||
avabl_fn: Callable[[dict[str, Any]], bool] = lambda data: True
|
||||
|
||||
|
@ -45,7 +45,6 @@ SENSOR_DESCRIPTIONS: tuple[GitHubSensorEntityDescription, ...] = (
|
|||
GitHubSensorEntityDescription(
|
||||
key="stargazers_count",
|
||||
translation_key="stargazers_count",
|
||||
icon="mdi:star",
|
||||
native_unit_of_measurement="Stars",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
|
@ -54,7 +53,6 @@ SENSOR_DESCRIPTIONS: tuple[GitHubSensorEntityDescription, ...] = (
|
|||
GitHubSensorEntityDescription(
|
||||
key="subscribers_count",
|
||||
translation_key="subscribers_count",
|
||||
icon="mdi:glasses",
|
||||
native_unit_of_measurement="Watchers",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
|
@ -63,7 +61,6 @@ SENSOR_DESCRIPTIONS: tuple[GitHubSensorEntityDescription, ...] = (
|
|||
GitHubSensorEntityDescription(
|
||||
key="forks_count",
|
||||
translation_key="forks_count",
|
||||
icon="mdi:source-fork",
|
||||
native_unit_of_measurement="Forks",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
|
|
|
@ -4,7 +4,7 @@ import pytest
|
|||
|
||||
from homeassistant.components.github import CONF_REPOSITORIES
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er, icon
|
||||
|
||||
from .common import setup_github_integration
|
||||
|
||||
|
@ -21,7 +21,7 @@ async def test_device_registry_cleanup(
|
|||
aioclient_mock: AiohttpClientMocker,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test that we remove untracked repositories from the decvice registry."""
|
||||
"""Test that we remove untracked repositories from the device registry."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
hass.config_entries.async_update_entry(
|
||||
mock_config_entry,
|
||||
|
@ -113,3 +113,22 @@ async def test_subscription_setup_polling_disabled(
|
|||
"https://api.github.com/repos/home-assistant/core/events" in x[1]
|
||||
for x in aioclient_mock.mock_calls
|
||||
)
|
||||
|
||||
|
||||
# This tests needs to be adjusted to remove lingering tasks
|
||||
@pytest.mark.parametrize("expected_lingering_tasks", [True])
|
||||
async def test_sensor_icons(
|
||||
hass: HomeAssistant,
|
||||
init_integration: MockConfigEntry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
) -> None:
|
||||
"""Test to ensure that all sensor entities have an icon definition."""
|
||||
entities = er.async_entries_for_config_entry(
|
||||
entity_registry,
|
||||
config_entry_id=init_integration.entry_id,
|
||||
)
|
||||
|
||||
icons = await icon.async_get_icons(hass, "entity", integrations=["github"])
|
||||
for entity in entities:
|
||||
assert entity.translation_key is not None
|
||||
assert icons["github"]["sensor"][entity.translation_key] is not None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue