mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 05:37:44 +00:00
Fix some minor issues and nitpicks in ntfy integration (#143516)
Fix nitpicks
This commit is contained in:
parent
253cc377b4
commit
f6d8868eb6
@ -68,7 +68,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: NtfyConfigEntry) -> bool
|
||||
return True
|
||||
|
||||
|
||||
async def _async_update_listener(hass: HomeAssistant, entry: ConfigEntry) -> None:
|
||||
async def _async_update_listener(hass: HomeAssistant, entry: NtfyConfigEntry) -> None:
|
||||
"""Handle update."""
|
||||
await hass.config_entries.async_reload(entry.entry_id)
|
||||
|
||||
|
@ -6,7 +6,7 @@ import logging
|
||||
import random
|
||||
import re
|
||||
import string
|
||||
from typing import Any
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from aiontfy import Ntfy
|
||||
from aiontfy.exceptions import (
|
||||
@ -138,8 +138,10 @@ class NtfyConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
_LOGGER.exception("Unexpected exception")
|
||||
errors["base"] = "unknown"
|
||||
else:
|
||||
if TYPE_CHECKING:
|
||||
assert url.host
|
||||
return self.async_create_entry(
|
||||
title=url.host or "",
|
||||
title=url.host,
|
||||
data={
|
||||
CONF_URL: url.human_repr(),
|
||||
CONF_USERNAME: username,
|
||||
|
@ -46,6 +46,7 @@ class NtfyNotifyEntity(NotifyEntity):
|
||||
name=None,
|
||||
has_entity_name=True,
|
||||
)
|
||||
_attr_supported_features = NotifyEntityFeature.TITLE
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
@ -57,8 +58,7 @@ class NtfyNotifyEntity(NotifyEntity):
|
||||
self._attr_unique_id = f"{config_entry.entry_id}_{subentry.subentry_id}_{self.entity_description.key}"
|
||||
self.topic = subentry.data[CONF_TOPIC]
|
||||
|
||||
self._attr_supported_features = NotifyEntityFeature.TITLE
|
||||
self.device_info = DeviceInfo(
|
||||
self._attr_device_info = DeviceInfo(
|
||||
entry_type=DeviceEntryType.SERVICE,
|
||||
manufacturer="ntfy LLC",
|
||||
model="ntfy",
|
||||
|
@ -13,7 +13,9 @@ rules:
|
||||
config-flow-test-coverage: done
|
||||
config-flow: done
|
||||
dependency-transparency: done
|
||||
docs-actions: done
|
||||
docs-actions:
|
||||
status: exempt
|
||||
comment: integration has only entity actions
|
||||
docs-high-level-description: done
|
||||
docs-installation-instructions: done
|
||||
docs-removal-instructions: done
|
||||
@ -46,7 +48,7 @@ rules:
|
||||
test-coverage: done
|
||||
|
||||
# Gold
|
||||
devices: todo
|
||||
devices: done
|
||||
diagnostics: todo
|
||||
discovery-update-info: todo
|
||||
discovery: todo
|
||||
@ -67,13 +69,13 @@ rules:
|
||||
comment: only one entity
|
||||
entity-translations:
|
||||
status: exempt
|
||||
comment: the notify entity uses the topic as name, no translation required
|
||||
comment: the notify entity uses the device name as entity name, no translation required
|
||||
exception-translations: done
|
||||
icon-translations: done
|
||||
reconfiguration-flow: todo
|
||||
repair-issues:
|
||||
status: exempt
|
||||
comment: the integration has no repeairs
|
||||
comment: the integration has no repairs
|
||||
stale-devices:
|
||||
status: exempt
|
||||
comment: only one device per entry, is deleted with the entry.
|
||||
|
@ -35,7 +35,7 @@
|
||||
"unknown": "[%key:common::config_flow::error::unknown%]"
|
||||
},
|
||||
"abort": {
|
||||
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]"
|
||||
"already_configured": "[%key:common::config_flow::abort::already_configured_service%]"
|
||||
}
|
||||
},
|
||||
"config_subentries": {
|
||||
@ -69,11 +69,11 @@
|
||||
"error": {
|
||||
"publish_forbidden": "Publishing to this topic is forbidden",
|
||||
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
|
||||
"unknown": "[%key:common::config_flow::error::unknown%]"
|
||||
"unknown": "[%key:common::config_flow::error::unknown%]",
|
||||
"invalid_topic": "Invalid topic. Only letters, numbers, underscores, or dashes allowed."
|
||||
},
|
||||
"abort": {
|
||||
"already_configured": "Topic is already configured",
|
||||
"invalid_topic": "Invalid topic. Only letters, numbers, underscores, or dashes allowed."
|
||||
"already_configured": "Topic is already configured"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -1,7 +1,7 @@
|
||||
"""Test the ntfy config flow."""
|
||||
|
||||
from typing import Any
|
||||
from unittest.mock import AsyncMock, patch
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from aiontfy.exceptions import (
|
||||
NtfyException,
|
||||
@ -56,20 +56,15 @@ async def test_form(
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.ntfy.config_flow.Ntfy.publish",
|
||||
return_value=True,
|
||||
):
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
user_input,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
user_input,
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "ntfy.sh"
|
||||
assert result["data"] == entry_data
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
@ -116,7 +111,7 @@ async def test_form_errors(
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {"base": error}
|
||||
|
||||
mock_aiontfy.account.side_effect = None
|
||||
@ -129,7 +124,7 @@ async def test_form_errors(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "ntfy.sh"
|
||||
assert result["data"] == {
|
||||
CONF_URL: "https://ntfy.sh/",
|
||||
|
Loading…
x
Reference in New Issue
Block a user