mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 20:27:08 +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)
|
date.get_reading(self.diaspora), hebrew=self._hebrew)
|
||||||
elif self.type == 'holiday_name':
|
elif self.type == 'holiday_name':
|
||||||
try:
|
try:
|
||||||
self._state = next(
|
description = next(
|
||||||
x.description[self._hebrew].long
|
x.description[self._hebrew]
|
||||||
for x in hdate.htables.HOLIDAYS
|
for x in hdate.htables.HOLIDAYS
|
||||||
if x.index == date.get_holyday())
|
if x.index == date.get_holyday())
|
||||||
|
if not self._hebrew:
|
||||||
|
self._state = description
|
||||||
|
else:
|
||||||
|
self._state = description.long
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
self._state = None
|
self._state = None
|
||||||
elif self.type == 'holyness':
|
elif self.type == 'holyness':
|
||||||
|
@ -95,6 +95,18 @@ class TestJewishCalenderSensor(unittest.TestCase):
|
|||||||
sensor.async_update(), self.hass.loop).result()
|
sensor.async_update(), self.hass.loop).result()
|
||||||
self.assertEqual(sensor.state, "א\' ראש השנה")
|
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):
|
def test_jewish_calendar_sensor_holyness(self):
|
||||||
"""Test Jewish calendar sensor date output in hebrew."""
|
"""Test Jewish calendar sensor date output in hebrew."""
|
||||||
test_time = dt(2018, 9, 10)
|
test_time = dt(2018, 9, 10)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user