mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Fix jewish calendar sensor with language set to english (#17104)
* Add failing testcase for issue #16830 * Fix for #16830
This commit is contained in:
parent
467a59a6ed
commit
cf5f02b347
@ -116,10 +116,14 @@ class JewishCalSensor(Entity):
|
||||
date.get_reading(self.diaspora), hebrew=self._hebrew)
|
||||
elif self.type == 'holiday_name':
|
||||
try:
|
||||
self._state = next(
|
||||
x.description[self._hebrew].long
|
||||
description = next(
|
||||
x.description[self._hebrew]
|
||||
for x in hdate.htables.HOLIDAYS
|
||||
if x.index == date.get_holyday())
|
||||
if not self._hebrew:
|
||||
self._state = description
|
||||
else:
|
||||
self._state = description.long
|
||||
except StopIteration:
|
||||
self._state = None
|
||||
elif self.type == 'holyness':
|
||||
|
@ -95,6 +95,18 @@ class TestJewishCalenderSensor(unittest.TestCase):
|
||||
sensor.async_update(), self.hass.loop).result()
|
||||
self.assertEqual(sensor.state, "א\' ראש השנה")
|
||||
|
||||
def test_jewish_calendar_sensor_holiday_name_english(self):
|
||||
"""Test Jewish calendar sensor date output in hebrew."""
|
||||
test_time = dt(2018, 9, 10)
|
||||
sensor = JewishCalSensor(
|
||||
name='test', language='english', sensor_type='holiday_name',
|
||||
latitude=self.TEST_LATITUDE, longitude=self.TEST_LONGITUDE,
|
||||
diaspora=False)
|
||||
with patch('homeassistant.util.dt.now', return_value=test_time):
|
||||
run_coroutine_threadsafe(
|
||||
sensor.async_update(), self.hass.loop).result()
|
||||
self.assertEqual(sensor.state, "Rosh Hashana I")
|
||||
|
||||
def test_jewish_calendar_sensor_holyness(self):
|
||||
"""Test Jewish calendar sensor date output in hebrew."""
|
||||
test_time = dt(2018, 9, 10)
|
||||
|
Loading…
x
Reference in New Issue
Block a user