Fix time trigger tests with leap year (#111785)
parent
675ddaf742
commit
3fbeb7e400
|
@ -210,7 +210,7 @@ async def test_if_not_fires_using_wrong_at(
|
|||
now = dt_util.utcnow()
|
||||
|
||||
time_that_will_not_match_right_away = now.replace(
|
||||
year=now.year + 1, hour=1, minute=0, second=0
|
||||
year=now.year + 1, day=1, hour=1, minute=0, second=0
|
||||
)
|
||||
|
||||
freezer.move_to(time_that_will_not_match_right_away)
|
||||
|
@ -233,7 +233,7 @@ async def test_if_not_fires_using_wrong_at(
|
|||
assert hass.states.get("automation.automation_0").state == STATE_UNAVAILABLE
|
||||
|
||||
async_fire_time_changed(
|
||||
hass, now.replace(year=now.year + 1, hour=1, minute=0, second=5)
|
||||
hass, now.replace(year=now.year + 1, day=1, hour=1, minute=0, second=5)
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
|
|
@ -33,7 +33,7 @@ async def test_if_fires_when_hour_matches(
|
|||
"""Test for firing if hour is matching."""
|
||||
now = dt_util.utcnow()
|
||||
time_that_will_not_match_right_away = dt_util.utcnow().replace(
|
||||
year=now.year + 1, hour=3
|
||||
year=now.year + 1, day=1, hour=3
|
||||
)
|
||||
freezer.move_to(time_that_will_not_match_right_away)
|
||||
assert await async_setup_component(
|
||||
|
@ -55,7 +55,7 @@ async def test_if_fires_when_hour_matches(
|
|||
},
|
||||
)
|
||||
|
||||
async_fire_time_changed(hass, now.replace(year=now.year + 2, hour=0))
|
||||
async_fire_time_changed(hass, now.replace(year=now.year + 2, day=1, hour=0))
|
||||
await hass.async_block_till_done()
|
||||
assert len(calls) == 1
|
||||
|
||||
|
@ -66,7 +66,7 @@ async def test_if_fires_when_hour_matches(
|
|||
blocking=True,
|
||||
)
|
||||
|
||||
async_fire_time_changed(hass, now.replace(year=now.year + 1, hour=0))
|
||||
async_fire_time_changed(hass, now.replace(year=now.year + 1, day=1, hour=0))
|
||||
await hass.async_block_till_done()
|
||||
assert len(calls) == 1
|
||||
assert calls[0].data["id"] == 0
|
||||
|
@ -78,7 +78,7 @@ async def test_if_fires_when_minute_matches(
|
|||
"""Test for firing if minutes are matching."""
|
||||
now = dt_util.utcnow()
|
||||
time_that_will_not_match_right_away = dt_util.utcnow().replace(
|
||||
year=now.year + 1, minute=30
|
||||
year=now.year + 1, day=1, minute=30
|
||||
)
|
||||
freezer.move_to(time_that_will_not_match_right_away)
|
||||
assert await async_setup_component(
|
||||
|
@ -97,7 +97,7 @@ async def test_if_fires_when_minute_matches(
|
|||
},
|
||||
)
|
||||
|
||||
async_fire_time_changed(hass, now.replace(year=now.year + 2, minute=0))
|
||||
async_fire_time_changed(hass, now.replace(year=now.year + 2, day=1, minute=0))
|
||||
|
||||
await hass.async_block_till_done()
|
||||
assert len(calls) == 1
|
||||
|
@ -109,7 +109,7 @@ async def test_if_fires_when_second_matches(
|
|||
"""Test for firing if seconds are matching."""
|
||||
now = dt_util.utcnow()
|
||||
time_that_will_not_match_right_away = dt_util.utcnow().replace(
|
||||
year=now.year + 1, second=30
|
||||
year=now.year + 1, day=1, second=30
|
||||
)
|
||||
freezer.move_to(time_that_will_not_match_right_away)
|
||||
assert await async_setup_component(
|
||||
|
@ -128,7 +128,7 @@ async def test_if_fires_when_second_matches(
|
|||
},
|
||||
)
|
||||
|
||||
async_fire_time_changed(hass, now.replace(year=now.year + 2, second=0))
|
||||
async_fire_time_changed(hass, now.replace(year=now.year + 2, day=1, second=0))
|
||||
|
||||
await hass.async_block_till_done()
|
||||
assert len(calls) == 1
|
||||
|
@ -140,7 +140,7 @@ async def test_if_fires_when_second_as_string_matches(
|
|||
"""Test for firing if seconds are matching."""
|
||||
now = dt_util.utcnow()
|
||||
time_that_will_not_match_right_away = dt_util.utcnow().replace(
|
||||
year=now.year + 1, second=15
|
||||
year=now.year + 1, day=1, second=15
|
||||
)
|
||||
freezer.move_to(time_that_will_not_match_right_away)
|
||||
assert await async_setup_component(
|
||||
|
@ -173,7 +173,7 @@ async def test_if_fires_when_all_matches(
|
|||
"""Test for firing if everything matches."""
|
||||
now = dt_util.utcnow()
|
||||
time_that_will_not_match_right_away = dt_util.utcnow().replace(
|
||||
year=now.year + 1, hour=4
|
||||
year=now.year + 1, day=1, hour=4
|
||||
)
|
||||
freezer.move_to(time_that_will_not_match_right_away)
|
||||
assert await async_setup_component(
|
||||
|
@ -193,7 +193,7 @@ async def test_if_fires_when_all_matches(
|
|||
)
|
||||
|
||||
async_fire_time_changed(
|
||||
hass, now.replace(year=now.year + 2, hour=1, minute=2, second=3)
|
||||
hass, now.replace(year=now.year + 2, day=1, hour=1, minute=2, second=3)
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
@ -206,7 +206,7 @@ async def test_if_fires_periodic_seconds(
|
|||
"""Test for firing periodically every second."""
|
||||
now = dt_util.utcnow()
|
||||
time_that_will_not_match_right_away = dt_util.utcnow().replace(
|
||||
year=now.year + 1, second=1
|
||||
year=now.year + 1, day=1, second=1
|
||||
)
|
||||
freezer.move_to(time_that_will_not_match_right_away)
|
||||
assert await async_setup_component(
|
||||
|
@ -226,7 +226,7 @@ async def test_if_fires_periodic_seconds(
|
|||
)
|
||||
|
||||
async_fire_time_changed(
|
||||
hass, now.replace(year=now.year + 2, hour=0, minute=0, second=10)
|
||||
hass, now.replace(year=now.year + 2, day=1, hour=0, minute=0, second=10)
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
@ -240,7 +240,7 @@ async def test_if_fires_periodic_minutes(
|
|||
|
||||
now = dt_util.utcnow()
|
||||
time_that_will_not_match_right_away = dt_util.utcnow().replace(
|
||||
year=now.year + 1, minute=1
|
||||
year=now.year + 1, day=1, minute=1
|
||||
)
|
||||
freezer.move_to(time_that_will_not_match_right_away)
|
||||
assert await async_setup_component(
|
||||
|
@ -260,7 +260,7 @@ async def test_if_fires_periodic_minutes(
|
|||
)
|
||||
|
||||
async_fire_time_changed(
|
||||
hass, now.replace(year=now.year + 2, hour=0, minute=2, second=0)
|
||||
hass, now.replace(year=now.year + 2, day=1, hour=0, minute=2, second=0)
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
@ -273,7 +273,7 @@ async def test_if_fires_periodic_hours(
|
|||
"""Test for firing periodically every hour."""
|
||||
now = dt_util.utcnow()
|
||||
time_that_will_not_match_right_away = dt_util.utcnow().replace(
|
||||
year=now.year + 1, hour=1
|
||||
year=now.year + 1, day=1, hour=1
|
||||
)
|
||||
freezer.move_to(time_that_will_not_match_right_away)
|
||||
assert await async_setup_component(
|
||||
|
@ -293,7 +293,7 @@ async def test_if_fires_periodic_hours(
|
|||
)
|
||||
|
||||
async_fire_time_changed(
|
||||
hass, now.replace(year=now.year + 2, hour=2, minute=0, second=0)
|
||||
hass, now.replace(year=now.year + 2, day=1, hour=2, minute=0, second=0)
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
@ -306,7 +306,7 @@ async def test_default_values(
|
|||
"""Test for firing at 2 minutes every hour."""
|
||||
now = dt_util.utcnow()
|
||||
time_that_will_not_match_right_away = dt_util.utcnow().replace(
|
||||
year=now.year + 1, minute=1
|
||||
year=now.year + 1, day=1, minute=1
|
||||
)
|
||||
freezer.move_to(time_that_will_not_match_right_away)
|
||||
assert await async_setup_component(
|
||||
|
@ -321,21 +321,21 @@ async def test_default_values(
|
|||
)
|
||||
|
||||
async_fire_time_changed(
|
||||
hass, now.replace(year=now.year + 2, hour=1, minute=2, second=0)
|
||||
hass, now.replace(year=now.year + 2, day=1, hour=1, minute=2, second=0)
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
assert len(calls) == 1
|
||||
|
||||
async_fire_time_changed(
|
||||
hass, now.replace(year=now.year + 2, hour=1, minute=2, second=1)
|
||||
hass, now.replace(year=now.year + 2, day=1, hour=1, minute=2, second=1)
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
assert len(calls) == 1
|
||||
|
||||
async_fire_time_changed(
|
||||
hass, now.replace(year=now.year + 2, hour=2, minute=2, second=0)
|
||||
hass, now.replace(year=now.year + 2, day=1, hour=2, minute=2, second=0)
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
|
Loading…
Reference in New Issue