Add unique_id to jewish_calendar entities (#39025)
This commit is contained in:
1 parent
c74f187b1f
commit
d0af3339fc
6 files changed
+93
-2
No files matched your search
@@ -10,6 +10,7 @@ from tests.async_mock import patch
|
||||
|
||||
_LatLng = namedtuple("_LatLng", ["lat", "lng"])
|
||||
|
||||
HDATE_DEFAULT_ALTITUDE = 754
|
||||
NYC_LATLNG = _LatLng(40.7128, -74.0060)
|
||||
JERUSALEM_LATLNG = _LatLng(31.778, 35.235)
|
||||
|
||||
|
||||
@@ -8,7 +8,12 @@ from homeassistant.const import STATE_OFF, STATE_ON
|
||||
from homeassistant.setup import async_setup_component
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
from . import alter_time, make_jerusalem_test_params, make_nyc_test_params
|
||||
from . import (
|
||||
HDATE_DEFAULT_ALTITUDE,
|
||||
alter_time,
|
||||
make_jerusalem_test_params,
|
||||
make_nyc_test_params,
|
||||
)
|
||||
|
||||
from tests.common import async_fire_time_changed
|
||||
|
||||
@@ -79,6 +84,8 @@ async def test_issur_melacha_sensor(
|
||||
hass.config.latitude = latitude
|
||||
hass.config.longitude = longitude
|
||||
|
||||
registry = await hass.helpers.entity_registry.async_get_registry()
|
||||
|
||||
with alter_time(test_time):
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
@@ -103,3 +110,21 @@ async def test_issur_melacha_sensor(
|
||||
hass.states.get("binary_sensor.test_issur_melacha_in_effect").state
|
||||
== result
|
||||
)
|
||||
entity = registry.async_get("binary_sensor.test_issur_melacha_in_effect")
|
||||
target_uid = "_".join(
|
||||
map(
|
||||
str,
|
||||
[
|
||||
latitude,
|
||||
longitude,
|
||||
time_zone,
|
||||
HDATE_DEFAULT_ALTITUDE,
|
||||
diaspora,
|
||||
"english",
|
||||
candle_lighting,
|
||||
havdalah,
|
||||
"issur_melacha_in_effect",
|
||||
],
|
||||
)
|
||||
)
|
||||
assert entity.unique_id == target_uid
|
||||
@@ -7,7 +7,12 @@ from homeassistant.components import jewish_calendar
|
||||
from homeassistant.setup import async_setup_component
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
from . import alter_time, make_jerusalem_test_params, make_nyc_test_params
|
||||
from . import (
|
||||
HDATE_DEFAULT_ALTITUDE,
|
||||
alter_time,
|
||||
make_jerusalem_test_params,
|
||||
make_nyc_test_params,
|
||||
)
|
||||
|
||||
from tests.common import async_fire_time_changed
|
||||
|
||||
@@ -506,6 +511,8 @@ async def test_shabbat_times_sensor(
|
||||
hass.config.latitude = latitude
|
||||
hass.config.longitude = longitude
|
||||
|
||||
registry = await hass.helpers.entity_registry.async_get_registry()
|
||||
|
||||
with alter_time(test_time):
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
@@ -543,6 +550,26 @@ async def test_shabbat_times_sensor(
|
||||
result_value
|
||||
), f"Value for {sensor_type}"
|
||||
|
||||
entity = registry.async_get(f"sensor.test_{sensor_type}")
|
||||
target_sensor_type = sensor_type.replace("parshat_hashavua", "weekly_portion")
|
||||
target_uid = "_".join(
|
||||
map(
|
||||
str,
|
||||
[
|
||||
latitude,
|
||||
longitude,
|
||||
time_zone,
|
||||
HDATE_DEFAULT_ALTITUDE,
|
||||
diaspora,
|
||||
language,
|
||||
candle_lighting,
|
||||
havdalah,
|
||||
target_sensor_type,
|
||||
],
|
||||
)
|
||||
)
|
||||
assert entity.unique_id == target_uid
|
||||
|
||||
|
||||
OMER_PARAMS = [
|
||||
(dt(2019, 4, 21, 0), "1"),
|
||||
|
||||
Reference in new issue
Block a user