mirror of
https://github.com/home-assistant/core.git
synced 2025-08-03 20:55:10 +02:00
Verify we get a timestamp attribute for input_datetime
This adds a check that when using the default timestamp of 1970-1-1 00:00:00, we get a timestamp attribute. This is waht prompted this PR in the first place, as when specifying an automation trying to access the timestamp attribute for a non- initialized input_datetime HASS wouldn't start.
This commit is contained in:
@@ -221,12 +221,15 @@ def test_default_value(hass):
|
||||
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())
|
||||
assert state_time.attributes.get('timestamp') is not None
|
||||
|
||||
state_date = hass.states.get('input_datetime.test_date')
|
||||
assert state_date.state == str(dt_obj.date())
|
||||
assert state_date.attributes.get('timestamp') is not None
|
||||
|
||||
state_datetime = hass.states.get('input_datetime.test_datetime')
|
||||
assert state_datetime.state == str(dt_obj)
|
||||
assert state_datetime.attributes.get('timestamp') is not None
|
||||
|
||||
|
||||
async def test_input_datetime_context(hass, hass_admin_user):
|
||||
|
Reference in New Issue
Block a user