mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Freeze time for sun automation test
This commit is contained in:
parent
9bec0316ea
commit
95eabe7c0e
@ -6,6 +6,7 @@ Tests sun automation.
|
||||
"""
|
||||
from datetime import datetime
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
import homeassistant.core as ha
|
||||
from homeassistant.components import sun
|
||||
@ -38,8 +39,11 @@ class TestAutomationSun(unittest.TestCase):
|
||||
sun.STATE_ATTR_NEXT_SETTING: '02:00:00 16-09-2015',
|
||||
})
|
||||
|
||||
now = datetime(2015, 9, 15, 23, tzinfo=dt_util.UTC)
|
||||
trigger_time = datetime(2015, 9, 16, 2, tzinfo=dt_util.UTC)
|
||||
|
||||
with patch('homeassistant.components.automation.sun.dt_util.utcnow',
|
||||
return_value=now):
|
||||
self.assertTrue(automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
@ -61,8 +65,11 @@ class TestAutomationSun(unittest.TestCase):
|
||||
sun.STATE_ATTR_NEXT_RISING: '14:00:00 16-09-2015',
|
||||
})
|
||||
|
||||
now = datetime(2015, 9, 13, 23, tzinfo=dt_util.UTC)
|
||||
trigger_time = datetime(2015, 9, 16, 14, tzinfo=dt_util.UTC)
|
||||
|
||||
with patch('homeassistant.components.automation.sun.dt_util.utcnow',
|
||||
return_value=now):
|
||||
self.assertTrue(automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
@ -84,8 +91,11 @@ class TestAutomationSun(unittest.TestCase):
|
||||
sun.STATE_ATTR_NEXT_SETTING: '02:00:00 16-09-2015',
|
||||
})
|
||||
|
||||
now = datetime(2015, 9, 15, 23, tzinfo=dt_util.UTC)
|
||||
trigger_time = datetime(2015, 9, 16, 2, 30, tzinfo=dt_util.UTC)
|
||||
|
||||
with patch('homeassistant.components.automation.sun.dt_util.utcnow',
|
||||
return_value=now):
|
||||
self.assertTrue(automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
@ -108,8 +118,11 @@ class TestAutomationSun(unittest.TestCase):
|
||||
sun.STATE_ATTR_NEXT_RISING: '14:00:00 16-09-2015',
|
||||
})
|
||||
|
||||
now = datetime(2015, 9, 13, 23, tzinfo=dt_util.UTC)
|
||||
trigger_time = datetime(2015, 9, 16, 13, 30, tzinfo=dt_util.UTC)
|
||||
|
||||
with patch('homeassistant.components.automation.sun.dt_util.utcnow',
|
||||
return_value=now):
|
||||
self.assertTrue(automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
|
Loading…
x
Reference in New Issue
Block a user