Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
HomeAssistant
Core
Commits
7d74c896
Unverified
Commit
7d74c896
authored
1 year ago
by
Jan-Philipp Benecke
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Use freezegun in image_upload test (#106045)
parent
f84e43bc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/components/image_upload/test_init.py
+4
-1
4 additions, 1 deletion
tests/components/image_upload/test_init.py
with
4 additions
and
1 deletion
tests/components/image_upload/test_init.py
+
4
−
1
View file @
7d74c896
...
@@ -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
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment