Migrate geo_rss_events test to use freezegun (#105895)
This commit is contained in:
parent
e3b09a5470
commit
bdaf269ba3
1 changed files with 6 additions and 5 deletions
|
@ -1,6 +1,7 @@
|
|||
"""The test for the geo rss events sensor platform."""
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from freezegun.api import FrozenDateTimeFactory
|
||||
import pytest
|
||||
|
||||
from homeassistant.components import sensor
|
||||
|
@ -56,7 +57,9 @@ def _generate_mock_feed_entry(
|
|||
return feed_entry
|
||||
|
||||
|
||||
async def test_setup(hass: HomeAssistant, mock_feed) -> None:
|
||||
async def test_setup(
|
||||
hass: HomeAssistant, freezer: FrozenDateTimeFactory, mock_feed
|
||||
) -> None:
|
||||
"""Test the general setup of the platform."""
|
||||
# Set up some mock feed entries for this test.
|
||||
mock_entry_1 = _generate_mock_feed_entry(
|
||||
|
@ -68,10 +71,8 @@ async def test_setup(hass: HomeAssistant, mock_feed) -> None:
|
|||
mock_feed.return_value.update.return_value = "OK", [mock_entry_1, mock_entry_2]
|
||||
|
||||
utcnow = dt_util.utcnow()
|
||||
# Patching 'utcnow' to gain more control over the timed update.
|
||||
with patch(
|
||||
"homeassistant.util.dt.utcnow", return_value=utcnow
|
||||
), assert_setup_component(1, sensor.DOMAIN):
|
||||
freezer.move_to(utcnow)
|
||||
with assert_setup_component(1, sensor.DOMAIN):
|
||||
assert await async_setup_component(hass, sensor.DOMAIN, VALID_CONFIG)
|
||||
# Artificially trigger update.
|
||||
hass.bus.fire(EVENT_HOMEASSISTANT_START)
|
||||
|
|
Loading…
Add table
Reference in a new issue