Add entity translations to islamic prayer times (#95469)
parent
3c072e50c7
commit
c853010f80
|
@ -19,31 +19,31 @@ from .const import DOMAIN, NAME
|
|||
SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
||||
SensorEntityDescription(
|
||||
key="Fajr",
|
||||
name="Fajr prayer",
|
||||
translation_key="fajr",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="Sunrise",
|
||||
name="Sunrise time",
|
||||
translation_key="sunrise",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="Dhuhr",
|
||||
name="Dhuhr prayer",
|
||||
translation_key="dhuhr",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="Asr",
|
||||
name="Asr prayer",
|
||||
translation_key="asr",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="Maghrib",
|
||||
name="Maghrib prayer",
|
||||
translation_key="maghrib",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="Isha",
|
||||
name="Isha prayer",
|
||||
translation_key="isha",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="Midnight",
|
||||
name="Midnight time",
|
||||
translation_key="midnight",
|
||||
),
|
||||
)
|
||||
|
||||
|
|
|
@ -19,5 +19,30 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"entity": {
|
||||
"sensor": {
|
||||
"fajr": {
|
||||
"name": "Fajr prayer"
|
||||
},
|
||||
"sunrise": {
|
||||
"name": "Sunrise time"
|
||||
},
|
||||
"dhuhr": {
|
||||
"name": "Dhuhr prayer"
|
||||
},
|
||||
"asr": {
|
||||
"name": "Asr prayer"
|
||||
},
|
||||
"maghrib": {
|
||||
"name": "Maghrib prayer"
|
||||
},
|
||||
"isha": {
|
||||
"name": "Isha prayer"
|
||||
},
|
||||
"midnight": {
|
||||
"name": "Midnight time"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,9 +5,7 @@ from freezegun import freeze_time
|
|||
import pytest
|
||||
|
||||
from homeassistant.components.islamic_prayer_times.const import DOMAIN
|
||||
from homeassistant.components.islamic_prayer_times.sensor import SENSOR_TYPES
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.util import slugify
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
from . import NOW, PRAYER_TIMES, PRAYER_TIMES_TIMESTAMPS
|
||||
|
@ -21,7 +19,21 @@ def set_utc(hass: HomeAssistant) -> None:
|
|||
hass.config.set_time_zone("UTC")
|
||||
|
||||
|
||||
async def test_islamic_prayer_times_sensors(hass: HomeAssistant) -> None:
|
||||
@pytest.mark.parametrize(
|
||||
("key", "sensor_name"),
|
||||
[
|
||||
("Fajr", "sensor.islamic_prayer_times_fajr_prayer"),
|
||||
("Sunrise", "sensor.islamic_prayer_times_sunrise_time"),
|
||||
("Dhuhr", "sensor.islamic_prayer_times_dhuhr_prayer"),
|
||||
("Asr", "sensor.islamic_prayer_times_asr_prayer"),
|
||||
("Maghrib", "sensor.islamic_prayer_times_maghrib_prayer"),
|
||||
("Isha", "sensor.islamic_prayer_times_isha_prayer"),
|
||||
("Midnight", "sensor.islamic_prayer_times_midnight_time"),
|
||||
],
|
||||
)
|
||||
async def test_islamic_prayer_times_sensors(
|
||||
hass: HomeAssistant, key: str, sensor_name: str
|
||||
) -> None:
|
||||
"""Test minimum Islamic prayer times configuration."""
|
||||
entry = MockConfigEntry(domain=DOMAIN, data={})
|
||||
entry.add_to_hass(hass)
|
||||
|
@ -33,10 +45,7 @@ async def test_islamic_prayer_times_sensors(hass: HomeAssistant) -> None:
|
|||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
for prayer in SENSOR_TYPES:
|
||||
assert (
|
||||
hass.states.get(f"sensor.{DOMAIN}_{slugify(prayer.name)}").state
|
||||
== PRAYER_TIMES_TIMESTAMPS[prayer.key]
|
||||
.astimezone(dt_util.UTC)
|
||||
.isoformat()
|
||||
)
|
||||
assert (
|
||||
hass.states.get(sensor_name).state
|
||||
== PRAYER_TIMES_TIMESTAMPS[key].astimezone(dt_util.UTC).isoformat()
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue