Skip to content
Snippets Groups Projects
Unverified Commit 7d74c896 authored by Jan-Philipp Benecke's avatar Jan-Philipp Benecke Committed by GitHub
Browse files

Use freezegun in image_upload test (#106045)

parent f84e43bc
No related branches found
No related tags found
No related merge requests found
...@@ -4,6 +4,7 @@ import tempfile ...@@ -4,6 +4,7 @@ import tempfile
from unittest.mock import patch from unittest.mock import patch
from aiohttp import ClientSession, ClientWebSocketResponse from aiohttp import ClientSession, ClientWebSocketResponse
from freezegun.api import FrozenDateTimeFactory
from homeassistant.components.websocket_api import const as ws_const from homeassistant.components.websocket_api import const as ws_const
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
...@@ -17,15 +18,17 @@ from tests.typing import ClientSessionGenerator, WebSocketGenerator ...@@ -17,15 +18,17 @@ from tests.typing import ClientSessionGenerator, WebSocketGenerator
async def test_upload_image( async def test_upload_image(
hass: HomeAssistant, hass: HomeAssistant,
freezer: FrozenDateTimeFactory,
hass_client: ClientSessionGenerator, hass_client: ClientSessionGenerator,
hass_ws_client: WebSocketGenerator, hass_ws_client: WebSocketGenerator,
) -> None: ) -> None:
"""Test we can upload an image.""" """Test we can upload an image."""
now = dt_util.utcnow() now = dt_util.utcnow()
freezer.move_to(now)
with tempfile.TemporaryDirectory() as tempdir, patch.object( with tempfile.TemporaryDirectory() as tempdir, patch.object(
hass.config, "path", return_value=tempdir hass.config, "path", return_value=tempdir
), patch("homeassistant.util.dt.utcnow", return_value=now): ):
assert await async_setup_component(hass, "image_upload", {}) assert await async_setup_component(hass, "image_upload", {})
ws_client: ClientWebSocketResponse = await hass_ws_client() ws_client: ClientWebSocketResponse = await hass_ws_client()
client: ClientSession = await hass_client() client: ClientSession = await hass_client()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment