mirror of
https://github.com/home-assistant/core.git
synced 2025-04-28 11:17:53 +00:00
Add entity translations to islamic prayer times (#95469)
This commit is contained in:
parent
3c072e50c7
commit
c853010f80
@ -19,31 +19,31 @@ from .const import DOMAIN, NAME
|
|||||||
SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="Fajr",
|
key="Fajr",
|
||||||
name="Fajr prayer",
|
translation_key="fajr",
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="Sunrise",
|
key="Sunrise",
|
||||||
name="Sunrise time",
|
translation_key="sunrise",
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="Dhuhr",
|
key="Dhuhr",
|
||||||
name="Dhuhr prayer",
|
translation_key="dhuhr",
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="Asr",
|
key="Asr",
|
||||||
name="Asr prayer",
|
translation_key="asr",
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="Maghrib",
|
key="Maghrib",
|
||||||
name="Maghrib prayer",
|
translation_key="maghrib",
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="Isha",
|
key="Isha",
|
||||||
name="Isha prayer",
|
translation_key="isha",
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="Midnight",
|
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
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.islamic_prayer_times.const import DOMAIN
|
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.core import HomeAssistant
|
||||||
from homeassistant.util import slugify
|
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
|
|
||||||
from . import NOW, PRAYER_TIMES, PRAYER_TIMES_TIMESTAMPS
|
from . import NOW, PRAYER_TIMES, PRAYER_TIMES_TIMESTAMPS
|
||||||
@ -21,7 +19,21 @@ def set_utc(hass: HomeAssistant) -> None:
|
|||||||
hass.config.set_time_zone("UTC")
|
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."""
|
"""Test minimum Islamic prayer times configuration."""
|
||||||
entry = MockConfigEntry(domain=DOMAIN, data={})
|
entry = MockConfigEntry(domain=DOMAIN, data={})
|
||||||
entry.add_to_hass(hass)
|
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.config_entries.async_setup(entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
for prayer in SENSOR_TYPES:
|
|
||||||
assert (
|
assert (
|
||||||
hass.states.get(f"sensor.{DOMAIN}_{slugify(prayer.name)}").state
|
hass.states.get(sensor_name).state
|
||||||
== PRAYER_TIMES_TIMESTAMPS[prayer.key]
|
== PRAYER_TIMES_TIMESTAMPS[key].astimezone(dt_util.UTC).isoformat()
|
||||||
.astimezone(dt_util.UTC)
|
|
||||||
.isoformat()
|
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user