Use DhcpServiceInfo in flux_led (#59967)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2021-11-19 12:37:59 +01:00 committed by GitHub
parent a51f2a433f
commit cb306236f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 18 deletions

View File

@ -13,11 +13,7 @@ from flux_led.const import (
) )
from flux_led.protocol import LEDENETRawState from flux_led.protocol import LEDENETRawState
from homeassistant.components.dhcp import ( from homeassistant.components import dhcp
HOSTNAME as DHCP_HOSTNAME,
IP_ADDRESS as DHCP_IP_ADDRESS,
MAC_ADDRESS as DHCP_MAC_ADDRESS,
)
from homeassistant.components.flux_led.const import FLUX_HOST, FLUX_MAC, FLUX_MODEL from homeassistant.components.flux_led.const import FLUX_HOST, FLUX_MAC, FLUX_MODEL
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -30,11 +26,11 @@ FLUX_MAC_ADDRESS = "aabbccddeeff"
DEFAULT_ENTRY_TITLE = f"{MODEL} {FLUX_MAC_ADDRESS}" DEFAULT_ENTRY_TITLE = f"{MODEL} {FLUX_MAC_ADDRESS}"
DHCP_DISCOVERY = { DHCP_DISCOVERY = dhcp.DhcpServiceInfo(
DHCP_HOSTNAME: MODEL, hostname=MODEL,
DHCP_IP_ADDRESS: IP_ADDRESS, ip=IP_ADDRESS,
DHCP_MAC_ADDRESS: MAC_ADDRESS, macaddress=MAC_ADDRESS,
} )
FLUX_DISCOVERY = {FLUX_HOST: IP_ADDRESS, FLUX_MODEL: MODEL, FLUX_MAC: FLUX_MAC_ADDRESS} FLUX_DISCOVERY = {FLUX_HOST: IP_ADDRESS, FLUX_MODEL: MODEL, FLUX_MAC: FLUX_MAC_ADDRESS}

View File

@ -6,6 +6,7 @@ from unittest.mock import patch
import pytest import pytest
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.components import dhcp
from homeassistant.components.flux_led.const import ( from homeassistant.components.flux_led.const import (
CONF_CUSTOM_EFFECT_COLORS, CONF_CUSTOM_EFFECT_COLORS,
CONF_CUSTOM_EFFECT_SPEED_PCT, CONF_CUSTOM_EFFECT_SPEED_PCT,
@ -29,9 +30,6 @@ from homeassistant.data_entry_flow import RESULT_TYPE_ABORT, RESULT_TYPE_FORM
from . import ( from . import (
DEFAULT_ENTRY_TITLE, DEFAULT_ENTRY_TITLE,
DHCP_DISCOVERY, DHCP_DISCOVERY,
DHCP_HOSTNAME,
DHCP_IP_ADDRESS,
DHCP_MAC_ADDRESS,
FLUX_DISCOVERY, FLUX_DISCOVERY,
IP_ADDRESS, IP_ADDRESS,
MAC_ADDRESS, MAC_ADDRESS,
@ -341,11 +339,11 @@ async def test_discovered_by_discovery_and_dhcp(hass):
result3 = await hass.config_entries.flow.async_init( result3 = await hass.config_entries.flow.async_init(
DOMAIN, DOMAIN,
context={"source": config_entries.SOURCE_DHCP}, context={"source": config_entries.SOURCE_DHCP},
data={ data=dhcp.DhcpServiceInfo(
DHCP_HOSTNAME: "any", hostname="any",
DHCP_IP_ADDRESS: IP_ADDRESS, ip=IP_ADDRESS,
DHCP_MAC_ADDRESS: "00:00:00:00:00:00", macaddress="00:00:00:00:00:00",
}, ),
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result3["type"] == RESULT_TYPE_ABORT assert result3["type"] == RESULT_TYPE_ABORT