From a4f7f3ba7ee0b9d5b4f206952b0c0b3e2fefc360 Mon Sep 17 00:00:00 2001 From: Jan Bouwhuis Date: Tue, 26 Sep 2023 00:32:12 +0200 Subject: [PATCH] Make sure time is changed in mqtt event test (#100889) --- tests/components/mqtt/test_event.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/components/mqtt/test_event.py b/tests/components/mqtt/test_event.py index 401caac8007..37a17ac9a41 100644 --- a/tests/components/mqtt/test_event.py +++ b/tests/components/mqtt/test_event.py @@ -706,10 +706,12 @@ async def test_skipped_async_ha_write_state( await help_test_skipped_async_ha_write_state(hass, topic, payload1, payload2) +@pytest.mark.freeze_time("2023-09-01 00:00:00+00:00") @pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG]) async def test_skipped_async_ha_write_state2( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, + freezer: FrozenDateTimeFactory, ) -> None: """Test a write state command is only called when there is a valid event.""" await mqtt_mock_entry() @@ -724,14 +726,17 @@ async def test_skipped_async_ha_write_state2( await hass.async_block_till_done() assert len(mock_async_ha_write_state.mock_calls) == 1 + freezer.move_to("2023-09-01 00:00:10+00:00") async_fire_mqtt_message(hass, topic, payload1) await hass.async_block_till_done() assert len(mock_async_ha_write_state.mock_calls) == 2 + freezer.move_to("2023-09-01 00:00:20+00:00") async_fire_mqtt_message(hass, topic, payload2) await hass.async_block_till_done() assert len(mock_async_ha_write_state.mock_calls) == 2 + freezer.move_to("2023-09-01 00:00:30+00:00") async_fire_mqtt_message(hass, topic, payload2) await hass.async_block_till_done() assert len(mock_async_ha_write_state.mock_calls) == 2