Remove YAML configuration from Discord (#71696)

This commit is contained in:
Franck Nijhof
2022-05-13 22:55:02 -05:00
committed by GitHub
parent ef9d8944f1
commit 991f0b40f2
5 changed files with 6 additions and 92 deletions
+1 -5
View File
@@ -6,7 +6,7 @@ import nextcord
from homeassistant.components.discord.const import DOMAIN
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_API_TOKEN, CONF_NAME, CONF_TOKEN
from homeassistant.const import CONF_API_TOKEN, CONF_NAME
from homeassistant.core import HomeAssistant
from tests.common import MockConfigEntry
@@ -21,10 +21,6 @@ CONF_DATA = {
CONF_NAME: NAME,
}
CONF_IMPORT_DATA_NO_NAME = {CONF_TOKEN: TOKEN}
CONF_IMPORT_DATA = CONF_IMPORT_DATA_NO_NAME | {CONF_NAME: NAME}
def create_entry(hass: HomeAssistant) -> ConfigEntry:
"""Add config entry in Home Assistant."""
@@ -1,6 +1,5 @@
"""Test Discord config flow."""
import nextcord
from pytest import LogCaptureFixture
from homeassistant import config_entries, data_entry_flow
from homeassistant.components.discord.const import DOMAIN
@@ -9,8 +8,6 @@ from homeassistant.core import HomeAssistant
from . import (
CONF_DATA,
CONF_IMPORT_DATA,
CONF_IMPORT_DATA_NO_NAME,
CONF_INPUT,
NAME,
create_entry,
@@ -121,49 +118,6 @@ async def test_flow_user_unknown_error(hass: HomeAssistant) -> None:
assert result["data"] == CONF_DATA
async def test_flow_import(hass: HomeAssistant, caplog: LogCaptureFixture) -> None:
"""Test an import flow."""
with mocked_discord_info(), patch_discord_login():
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_IMPORT},
data=CONF_IMPORT_DATA.copy(),
)
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["title"] == NAME
assert result["data"] == CONF_DATA
assert "Discord integration in YAML" in caplog.text
async def test_flow_import_no_name(hass: HomeAssistant) -> None:
"""Test import flow with no name in config."""
with mocked_discord_info(), patch_discord_login():
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_IMPORT},
data=CONF_IMPORT_DATA_NO_NAME,
)
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["title"] == NAME
assert result["data"] == CONF_DATA
async def test_flow_import_already_configured(hass: HomeAssistant) -> None:
"""Test an import flow already configured."""
create_entry(hass)
with mocked_discord_info(), patch_discord_login():
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_IMPORT},
data=CONF_IMPORT_DATA,
)
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
assert result["reason"] == "already_configured"
async def test_flow_reauth(hass: HomeAssistant) -> None:
"""Test a reauth flow."""
entry = create_entry(hass)