Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
joostlek committed Apr 5, 2024
1 parent adbee86 commit efc55d9
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 16 deletions.
30 changes: 15 additions & 15 deletions homeassistant/components/downloader/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,21 +81,21 @@ async def _async_import_config(hass: HomeAssistant, config: ConfigType) -> None:
"url": "/config/integrations/dashboard/add?domain=downloader",
},
)

async_create_issue(
hass,
HOMEASSISTANT_DOMAIN,
f"deprecated_yaml_{DOMAIN}",
breaks_in_ha_version="2024.10.0",
is_fixable=False,
issue_domain=DOMAIN,
severity=IssueSeverity.WARNING,
translation_key="deprecated_yaml",
translation_placeholders={
"domain": DOMAIN,
"integration_title": "Downloader",
},
)
else:
async_create_issue(
hass,
HOMEASSISTANT_DOMAIN,
f"deprecated_yaml_{DOMAIN}",
breaks_in_ha_version="2024.10.0",
is_fixable=False,
issue_domain=DOMAIN,
severity=IssueSeverity.WARNING,
translation_key="deprecated_yaml",
translation_placeholders={
"domain": DOMAIN,
"integration_title": "Downloader",
},
)


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
Expand Down
60 changes: 59 additions & 1 deletion tests/components/downloader/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
SERVICE_DOWNLOAD_FILE,
)
from homeassistant.config_entries import ConfigEntryState
from homeassistant.core import HomeAssistant
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant
from homeassistant.helpers import issue_registry as ir
from homeassistant.setup import async_setup_component

Expand Down Expand Up @@ -51,3 +51,61 @@ async def test_import(hass: HomeAssistant, issue_registry: ir.IssueRegistry) ->
assert config_entry.state is ConfigEntryState.LOADED
assert hass.services.has_service(DOMAIN, SERVICE_DOWNLOAD_FILE)
assert len(issue_registry.issues) == 1
issue = issue_registry.async_get_issue(
issue_id="deprecated_yaml_downloader", domain=HOMEASSISTANT_DOMAIN
)
assert issue


async def test_import_directory_missing(
hass: HomeAssistant, issue_registry: ir.IssueRegistry
) -> None:
"""Test the import of the downloader component."""
with patch("os.path.isdir", return_value=False):
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)) == 0
assert len(issue_registry.issues) == 1
issue = issue_registry.async_get_issue(
issue_id="deprecated_yaml_downloader", domain=DOMAIN
)
assert issue


async def test_import_already_exists(
hass: HomeAssistant, issue_registry: ir.IssueRegistry
) -> None:
"""Test the import 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 async_setup_component(
hass,
DOMAIN,
{
DOMAIN: {
CONF_DOWNLOAD_DIR: "/test_dir",
},
},
)
await hass.async_block_till_done()

assert len(issue_registry.issues) == 1
issue = issue_registry.async_get_issue(
issue_id="deprecated_yaml_downloader", domain=HOMEASSISTANT_DOMAIN
)
assert issue

0 comments on commit efc55d9

Please sign in to comment.