mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 01:07:10 +00:00
Fix test
This commit is contained in:
parent
72419a1afe
commit
d2246d5a4f
@ -126,8 +126,7 @@ class JewishCalSensor(Entity):
|
|||||||
self._state = hdate.date.get_holyday_type(date.get_holyday())
|
self._state = hdate.date.get_holyday_type(date.get_holyday())
|
||||||
else:
|
else:
|
||||||
times = hdate.Zmanim(
|
times = hdate.Zmanim(
|
||||||
date=today,
|
date=today, latitude=self.latitude, longitude=self.longitude,
|
||||||
latitude=self.latitude, longitude=self.longitude,
|
|
||||||
hebrew=self._hebrew).zmanim
|
hebrew=self._hebrew).zmanim
|
||||||
self._state = times[self.type].time()
|
self._state = times[self.type].time()
|
||||||
|
|
||||||
|
@ -23,12 +23,6 @@ class TestJewishCalenderSensor(unittest.TestCase):
|
|||||||
"""Stop everything that was started."""
|
"""Stop everything that was started."""
|
||||||
self.hass.stop()
|
self.hass.stop()
|
||||||
|
|
||||||
def checkForLoggingErrors(self):
|
|
||||||
"""Check whether logger spitted out errors."""
|
|
||||||
errors = [rec for rec in self.cm.records if rec.levelname == "ERROR"]
|
|
||||||
self.assertFalse(errors, ("Logger reported error(s): ",
|
|
||||||
[err.getMessage() for err in errors]))
|
|
||||||
|
|
||||||
def test_jewish_calendar_min_config(self):
|
def test_jewish_calendar_min_config(self):
|
||||||
"""Test minimum jewish calendar configuration."""
|
"""Test minimum jewish calendar configuration."""
|
||||||
config = {
|
config = {
|
||||||
@ -36,9 +30,7 @@ class TestJewishCalenderSensor(unittest.TestCase):
|
|||||||
'platform': 'jewish_calendar'
|
'platform': 'jewish_calendar'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
with self.assertLogs() as self.cm:
|
assert setup_component(self.hass, 'sensor', config)
|
||||||
assert setup_component(self.hass, 'sensor', config)
|
|
||||||
self.checkForLoggingErrors()
|
|
||||||
|
|
||||||
def test_jewish_calendar_hebrew(self):
|
def test_jewish_calendar_hebrew(self):
|
||||||
"""Test jewish calendar sensor with language set to hebrew."""
|
"""Test jewish calendar sensor with language set to hebrew."""
|
||||||
@ -48,9 +40,8 @@ class TestJewishCalenderSensor(unittest.TestCase):
|
|||||||
'language': 'hebrew',
|
'language': 'hebrew',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
with self.assertLogs() as self.cm:
|
|
||||||
assert setup_component(self.hass, 'sensor', config)
|
assert setup_component(self.hass, 'sensor', config)
|
||||||
self.checkForLoggingErrors()
|
|
||||||
|
|
||||||
def test_jewish_calendar_multiple_sensors(self):
|
def test_jewish_calendar_multiple_sensors(self):
|
||||||
"""Test jewish calendar sensor with multiple sensors setup."""
|
"""Test jewish calendar sensor with multiple sensors setup."""
|
||||||
@ -64,9 +55,8 @@ class TestJewishCalenderSensor(unittest.TestCase):
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
with self.assertLogs() as self.cm:
|
|
||||||
assert setup_component(self.hass, 'sensor', config)
|
assert setup_component(self.hass, 'sensor', config)
|
||||||
self.checkForLoggingErrors()
|
|
||||||
|
|
||||||
def test_jewish_calendar_sensor_date_output(self):
|
def test_jewish_calendar_sensor_date_output(self):
|
||||||
"""Test Jewish calendar sensor date output."""
|
"""Test Jewish calendar sensor date output."""
|
||||||
@ -90,8 +80,7 @@ class TestJewishCalenderSensor(unittest.TestCase):
|
|||||||
diaspora=False)
|
diaspora=False)
|
||||||
with patch('homeassistant.util.dt.now', return_value=test_time):
|
with patch('homeassistant.util.dt.now', return_value=test_time):
|
||||||
run_coroutine_threadsafe(
|
run_coroutine_threadsafe(
|
||||||
sensor.async_update(),
|
sensor.async_update(), self.hass.loop).result()
|
||||||
self.hass.loop).result()
|
|
||||||
self.assertEqual(sensor.state, "כ\"ג באלול ה\' תשע\"ח")
|
self.assertEqual(sensor.state, "כ\"ג באלול ה\' תשע\"ח")
|
||||||
|
|
||||||
def test_jewish_calendar_sensor_holiday_name(self):
|
def test_jewish_calendar_sensor_holiday_name(self):
|
||||||
@ -103,8 +92,7 @@ class TestJewishCalenderSensor(unittest.TestCase):
|
|||||||
diaspora=False)
|
diaspora=False)
|
||||||
with patch('homeassistant.util.dt.now', return_value=test_time):
|
with patch('homeassistant.util.dt.now', return_value=test_time):
|
||||||
run_coroutine_threadsafe(
|
run_coroutine_threadsafe(
|
||||||
sensor.async_update(),
|
sensor.async_update(), self.hass.loop).result()
|
||||||
self.hass.loop).result()
|
|
||||||
self.assertEqual(sensor.state, "א\' ראש השנה")
|
self.assertEqual(sensor.state, "א\' ראש השנה")
|
||||||
|
|
||||||
def test_jewish_calendar_sensor_holyness(self):
|
def test_jewish_calendar_sensor_holyness(self):
|
||||||
@ -116,8 +104,7 @@ class TestJewishCalenderSensor(unittest.TestCase):
|
|||||||
diaspora=False)
|
diaspora=False)
|
||||||
with patch('homeassistant.util.dt.now', return_value=test_time):
|
with patch('homeassistant.util.dt.now', return_value=test_time):
|
||||||
run_coroutine_threadsafe(
|
run_coroutine_threadsafe(
|
||||||
sensor.async_update(),
|
sensor.async_update(), self.hass.loop).result()
|
||||||
self.hass.loop).result()
|
|
||||||
self.assertEqual(sensor.state, 1)
|
self.assertEqual(sensor.state, 1)
|
||||||
|
|
||||||
def test_jewish_calendar_sensor_torah_reading(self):
|
def test_jewish_calendar_sensor_torah_reading(self):
|
||||||
@ -129,6 +116,5 @@ class TestJewishCalenderSensor(unittest.TestCase):
|
|||||||
diaspora=False)
|
diaspora=False)
|
||||||
with patch('homeassistant.util.dt.now', return_value=test_time):
|
with patch('homeassistant.util.dt.now', return_value=test_time):
|
||||||
run_coroutine_threadsafe(
|
run_coroutine_threadsafe(
|
||||||
sensor.async_update(),
|
sensor.async_update(), self.hass.loop).result()
|
||||||
self.hass.loop).result()
|
|
||||||
self.assertEqual(sensor.state, "פרשת נצבים")
|
self.assertEqual(sensor.state, "פרשת נצבים")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user