-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Downloader YAML import #114844
Merged
Merged
Fix Downloader YAML import #114844
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
"""Tests for the downloader component init.""" | ||
|
||
from unittest.mock import patch | ||
|
||
from homeassistant.components.downloader import ( | ||
CONF_DOWNLOAD_DIR, | ||
DOMAIN, | ||
SERVICE_DOWNLOAD_FILE, | ||
) | ||
from homeassistant.config_entries import ConfigEntryState | ||
from homeassistant.core import HomeAssistant | ||
from homeassistant.setup import async_setup_component | ||
|
||
from tests.common import MockConfigEntry | ||
|
||
|
||
async def test_initialization(hass: HomeAssistant) -> None: | ||
"""Test the initialization of the downloader component.""" | ||
config_entry = MockConfigEntry( | ||
domain=DOMAIN, | ||
data={ | ||
CONF_DOWNLOAD_DIR: "/test_dir", | ||
}, | ||
) | ||
config_entry.add_to_hass(hass) | ||
with patch("os.path.isdir", return_value=True): | ||
assert await hass.config_entries.async_setup(config_entry.entry_id) | ||
|
||
assert hass.services.has_service(DOMAIN, SERVICE_DOWNLOAD_FILE) | ||
assert config_entry.state is ConfigEntryState.LOADED | ||
|
||
|
||
async def test_import(hass: HomeAssistant) -> None: | ||
"""Test the import of the downloader component.""" | ||
with patch("os.path.isdir", return_value=True): | ||
assert await async_setup_component( | ||
hass, | ||
DOMAIN, | ||
{ | ||
DOMAIN: { | ||
CONF_DOWNLOAD_DIR: "/test_dir", | ||
}, | ||
}, | ||
) | ||
await hass.async_block_till_done() | ||
|
||
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 | ||
config_entry = hass.config_entries.async_entries(DOMAIN)[0] | ||
assert config_entry.data == {CONF_DOWNLOAD_DIR: "/test_dir"} | ||
assert config_entry.state is ConfigEntryState.LOADED | ||
assert hass.services.has_service(DOMAIN, SERVICE_DOWNLOAD_FILE) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think eager start makes sense since the component needs to be setup before the config entry is setup, and the config entry will be setup at the end of the config flow. We know that the task will need to yield to the loop to wait for the component setup to complete if we use an eager task. The whole point of this task is that we want it to run in a later iteration of the event loop to avoid a deadlock.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bdraco had it in his comment, do we want to remove it before the hotfix cut?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not a bug it's just confusing.