mirror of
https://github.com/home-assistant/core.git
synced 2026-08-24 02:24:51 -05:00
Improve in code comments for file_upload (#169768)
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com> Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
co-authored by
epenet
Martin Hjelmare
parent
944233376c
commit
1d0c72e0d9
@@ -36,7 +36,11 @@ CONFIG_SCHEMA = cv.empty_config_schema(DOMAIN)
|
||||
def process_uploaded_file(hass: HomeAssistant, file_id: str) -> Generator[Path]:
|
||||
"""Get an uploaded file.
|
||||
|
||||
File is removed at the end of the context.
|
||||
File is removed at the end of the context. Should be run on the executor thread pool.
|
||||
Create a wrapper function and call that wrapper function using
|
||||
hass.async_add_executor_job. Running this function directly by scheduling an executor
|
||||
job will result in loop blocking teardown code not running on the executor but
|
||||
rather in the loop.
|
||||
"""
|
||||
if DOMAIN not in hass.data:
|
||||
raise ValueError("File does not exist")
|
||||
|
||||
@@ -17,8 +17,8 @@ from tests.components.image_upload import TEST_IMAGE
|
||||
from tests.typing import ClientSessionGenerator
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
async def uploaded_file_dir(
|
||||
@pytest.fixture(name="uploaded_file_dir")
|
||||
async def upload_file_dir(
|
||||
hass: HomeAssistant, hass_client: ClientSessionGenerator
|
||||
) -> Path:
|
||||
"""Test uploading and using a file."""
|
||||
@@ -51,7 +51,6 @@ async def test_using_file(hass: HomeAssistant, uploaded_file_dir) -> None:
|
||||
assert file_path.parent == uploaded_file_dir
|
||||
assert file_path.read_bytes() == TEST_IMAGE.read_bytes()
|
||||
|
||||
# Test it's removed
|
||||
assert not uploaded_file_dir.exists()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user