mirror of
https://github.com/home-assistant/core.git
synced 2026-11-06 05:32:45 -04:00
Make api_version runtime_data in pi_hole (#148238)
This commit is contained in:
@@ -185,7 +185,6 @@ CONFIG_ENTRY_WITH_API_KEY = {
|
||||
CONF_API_KEY: API_KEY,
|
||||
CONF_SSL: SSL,
|
||||
CONF_VERIFY_SSL: VERIFY_SSL,
|
||||
CONF_API_VERSION: API_VERSION,
|
||||
}
|
||||
|
||||
CONFIG_ENTRY_WITHOUT_API_KEY = {
|
||||
@@ -194,7 +193,6 @@ CONFIG_ENTRY_WITHOUT_API_KEY = {
|
||||
CONF_NAME: NAME,
|
||||
CONF_SSL: SSL,
|
||||
CONF_VERIFY_SSL: VERIFY_SSL,
|
||||
CONF_API_VERSION: API_VERSION,
|
||||
}
|
||||
SWITCH_ENTITY_ID = "switch.pi_hole"
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
from homeassistant.components import pi_hole
|
||||
from homeassistant.components.pi_hole.const import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_USER
|
||||
from homeassistant.const import CONF_API_KEY, CONF_API_VERSION
|
||||
from homeassistant.const import CONF_API_KEY
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
@@ -104,7 +104,7 @@ async def test_flow_user_with_api_key_v5(hass: HomeAssistant) -> None:
|
||||
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == NAME
|
||||
assert result["data"] == {**CONFIG_ENTRY_WITH_API_KEY, CONF_API_VERSION: 5}
|
||||
assert result["data"] == {**CONFIG_ENTRY_WITH_API_KEY}
|
||||
mock_setup.assert_called_once()
|
||||
|
||||
# duplicated server
|
||||
@@ -148,7 +148,7 @@ async def test_flow_reauth(hass: HomeAssistant) -> None:
|
||||
mocked_hole = _create_mocked_hole(has_data=False, api_version=5)
|
||||
entry = MockConfigEntry(
|
||||
domain=pi_hole.DOMAIN,
|
||||
data={**CONFIG_DATA_DEFAULTS, CONF_API_VERSION: 5, CONF_API_KEY: "oldkey"},
|
||||
data={**CONFIG_DATA_DEFAULTS, CONF_API_KEY: "oldkey"},
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
with _patch_init_hole(mocked_hole), _patch_config_flow_hole(mocked_hole):
|
||||
|
||||
@@ -51,7 +51,7 @@ async def test_setup_api_v6(
|
||||
entry.add_to_hass(hass)
|
||||
with _patch_init_hole(mocked_hole) as patched_init_hole:
|
||||
assert await hass.config_entries.async_setup(entry.entry_id)
|
||||
patched_init_hole.assert_called_once_with(
|
||||
patched_init_hole.assert_called_with(
|
||||
host=config_entry_data[CONF_HOST],
|
||||
session=ANY,
|
||||
password=expected_api_token,
|
||||
@@ -78,7 +78,7 @@ async def test_setup_api_v5(
|
||||
entry.add_to_hass(hass)
|
||||
with _patch_init_hole(mocked_hole) as patched_init_hole:
|
||||
assert await hass.config_entries.async_setup(entry.entry_id)
|
||||
patched_init_hole.assert_called_once_with(
|
||||
patched_init_hole.assert_called_with(
|
||||
host=config_entry_data[CONF_HOST],
|
||||
session=ANY,
|
||||
api_token=expected_api_token,
|
||||
@@ -206,7 +206,7 @@ async def test_setup_without_api_version(hass: HomeAssistant) -> None:
|
||||
with _patch_init_hole(mocked_hole):
|
||||
assert await hass.config_entries.async_setup(entry.entry_id)
|
||||
|
||||
assert entry.data[CONF_API_VERSION] == 6
|
||||
assert entry.runtime_data.api_version == 6
|
||||
|
||||
mocked_hole = _create_mocked_hole(api_version=5)
|
||||
config = {**CONFIG_DATA_DEFAULTS}
|
||||
@@ -216,7 +216,7 @@ async def test_setup_without_api_version(hass: HomeAssistant) -> None:
|
||||
with _patch_init_hole(mocked_hole):
|
||||
assert await hass.config_entries.async_setup(entry.entry_id)
|
||||
|
||||
assert entry.data[CONF_API_VERSION] == 5
|
||||
assert entry.runtime_data.api_version == 5
|
||||
|
||||
|
||||
async def test_setup_name_config(hass: HomeAssistant) -> None:
|
||||
|
||||
Reference in New Issue
Block a user