def test_timer_trigger_next_month_rollover(hass): """Run month rollover tests.""" Function.init(hass) TrigTime.init(hass) for test_data in timerTriggerNextTestsMonthRollover: now = dt(2020, 6, 30, 13, 0, 0, 100000) spec, expect_seq = test_data for expect in expect_seq: t_next = TrigTime.timer_trigger_next(spec, now) assert t_next == expect now = t_next
def test_timer_trigger_next(hass): """Run trigger next tests.""" # # Hardcode a location and timezone so we can check sunrise # and sunset. # hass.config.latitude = 38 hass.config.longitude = -122 hass.config.elevation = 0 hass.config.time_zone = "America/Los_Angeles" Function.init(hass) TrigTime.init(hass) for test_data in timerTriggerNextTests: now = dt(2019, 9, 1, 13, 0, 0, 100000) spec, expect_seq = test_data for expect in expect_seq: t_next = TrigTime.timer_trigger_next(spec, now) assert t_next == expect now = t_next
def test_timer_trigger_next(hass): """Run trigger next tests.""" # # Hardcode a location and timezone so we can check sunrise # and sunset. # hass.config.latitude = 38 hass.config.longitude = -122 hass.config.elevation = 0 hass.config.time_zone = "America/Los_Angeles" Function.init(hass) TrigTime.init(hass) for test_data in timerTriggerNextTests: startup_time = now = dt(2019, 9, 1, 13, 0, 0, 100000) spec, expect_seq = test_data for expect in expect_seq: print(f"calling timer_trigger_next({spec}, {now}, {startup_time})") t_next = TrigTime.timer_trigger_next(spec, now, startup_time) assert t_next == expect if t_next is None: break now = t_next + timedelta(microseconds=1)