Add test (#3999)
This commit is contained in:
parent
1707cdf9f3
commit
2604dd89a6
3 changed files with 41 additions and 4 deletions
36
tests/components/sensor/test_worldclock.py
Normal file
36
tests/components/sensor/test_worldclock.py
Normal file
|
@ -0,0 +1,36 @@
|
|||
"""The test for the World clock sensor platform."""
|
||||
import unittest
|
||||
|
||||
from homeassistant.bootstrap import setup_component
|
||||
from tests.common import get_test_home_assistant
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
|
||||
class TestWorldClockSensor(unittest.TestCase):
|
||||
"""Test the World clock sensor."""
|
||||
|
||||
def setUp(self):
|
||||
"""Set up things to be run when tests are started."""
|
||||
self.hass = get_test_home_assistant()
|
||||
self.time_zone = dt_util.get_time_zone('America/New_York')
|
||||
|
||||
config = {
|
||||
'sensor': {
|
||||
'platform': 'worldclock',
|
||||
'time_zone': 'America/New_York',
|
||||
}
|
||||
}
|
||||
|
||||
self.assertTrue(setup_component(self.hass, 'sensor', config))
|
||||
|
||||
def tearDown(self):
|
||||
"""Stop everything that was started."""
|
||||
self.hass.stop()
|
||||
|
||||
def test_time(self):
|
||||
"""Test the time at a different location."""
|
||||
state = self.hass.states.get('sensor.worldclock_sensor')
|
||||
assert state is not None
|
||||
|
||||
assert state.state == dt_util.now(
|
||||
time_zone=self.time_zone).strftime('%H:%M')
|
Loading…
Add table
Add a link
Reference in a new issue