mirror of
https://github.com/home-assistant/core.git
synced 2025-08-03 20:55:10 +02:00
Add test for default values
Check that if no initial value is set, state returns 1970-01-01 at 00:00
This commit is contained in:
@@ -199,6 +199,36 @@ def test_restore_state(hass):
|
||||
assert state_bogus.state == str(initial)
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_default_value(hass):
|
||||
"""Test default value if none has been set via inital or restore state."""
|
||||
yield from async_setup_component(hass, DOMAIN, {
|
||||
DOMAIN: {
|
||||
'test_time': {
|
||||
'has_time': True,
|
||||
'has_date': False
|
||||
},
|
||||
'test_date': {
|
||||
'has_time': False,
|
||||
'has_date': True
|
||||
},
|
||||
'test_datetime': {
|
||||
'has_time': True,
|
||||
'has_date': True
|
||||
},
|
||||
}})
|
||||
|
||||
dt_obj = datetime.datetime(1970, 1, 1, 0, 0)
|
||||
state_time = hass.states.get('input_datetime.test_time')
|
||||
assert state_time.state == str(dt_obj.time())
|
||||
|
||||
state_date = hass.states.get('input_datetime.test_date')
|
||||
assert state_date.state == str(dt_obj.date())
|
||||
|
||||
state_datetime = hass.states.get('input_datetime.test_datetime')
|
||||
assert state_datetime.state == str(dt_obj)
|
||||
|
||||
|
||||
async def test_input_datetime_context(hass, hass_admin_user):
|
||||
"""Test that input_datetime context works."""
|
||||
assert await async_setup_component(hass, 'input_datetime', {
|
||||
|
Reference in New Issue
Block a user