From b71a22557dc6ca87b6c1871a0e4d3c3a949759fc Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 12 Jan 2022 15:07:30 +0100 Subject: [PATCH] Use Platform enum in load_platform [tests] (#63904) * Use Platform enum in numato tests * Use Platform enum in discovery tests * Adjust load_platform argument Co-authored-by: epenet --- tests/components/numato/test_binary_sensor.py | 5 ++++- tests/components/numato/test_sensor.py | 4 ++-- tests/components/numato/test_switch.py | 9 +++++++-- tests/helpers/test_discovery.py | 5 ++++- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/tests/components/numato/test_binary_sensor.py b/tests/components/numato/test_binary_sensor.py index 5aa6aea2b8d..41ddabc1a3c 100644 --- a/tests/components/numato/test_binary_sensor.py +++ b/tests/components/numato/test_binary_sensor.py @@ -1,4 +1,5 @@ """Tests for the numato binary_sensor platform.""" +from homeassistant.const import Platform from homeassistant.helpers import discovery from homeassistant.setup import async_setup_component @@ -54,7 +55,9 @@ async def test_hass_binary_sensor_notification(hass, numato_fixture): async def test_binary_sensor_setup_without_discovery_info(hass, config, numato_fixture): """Test handling of empty discovery_info.""" numato_fixture.discover() - await discovery.async_load_platform(hass, "binary_sensor", "numato", None, config) + await discovery.async_load_platform( + hass, Platform.BINARY_SENSOR, "numato", None, config + ) for entity_id in MOCKUP_ENTITY_IDS: assert entity_id not in hass.states.async_entity_ids() await hass.async_block_till_done() # wait for numato platform to be loaded diff --git a/tests/components/numato/test_sensor.py b/tests/components/numato/test_sensor.py index c6d176dbc90..45f3375c2e4 100644 --- a/tests/components/numato/test_sensor.py +++ b/tests/components/numato/test_sensor.py @@ -1,5 +1,5 @@ """Tests for the numato sensor platform.""" -from homeassistant.const import STATE_UNKNOWN +from homeassistant.const import STATE_UNKNOWN, Platform from homeassistant.helpers import discovery from homeassistant.setup import async_setup_component @@ -30,7 +30,7 @@ async def test_failing_sensor_update(hass, numato_fixture, monkeypatch): async def test_sensor_setup_without_discovery_info(hass, config, numato_fixture): """Test handling of empty discovery_info.""" numato_fixture.discover() - await discovery.async_load_platform(hass, "sensor", "numato", None, config) + await discovery.async_load_platform(hass, Platform.SENSOR, "numato", None, config) for entity_id in MOCKUP_ENTITY_IDS: assert entity_id not in hass.states.async_entity_ids() await hass.async_block_till_done() # wait for numato platform to be loaded diff --git a/tests/components/numato/test_switch.py b/tests/components/numato/test_switch.py index 91cda5c2a37..15324a27e47 100644 --- a/tests/components/numato/test_switch.py +++ b/tests/components/numato/test_switch.py @@ -1,6 +1,11 @@ """Tests for the numato switch platform.""" from homeassistant.components import switch -from homeassistant.const import ATTR_ENTITY_ID, SERVICE_TURN_OFF, SERVICE_TURN_ON +from homeassistant.const import ( + ATTR_ENTITY_ID, + SERVICE_TURN_OFF, + SERVICE_TURN_ON, + Platform, +) from homeassistant.helpers import discovery from homeassistant.setup import async_setup_component @@ -106,7 +111,7 @@ async def test_failing_hass_operations(hass, numato_fixture, monkeypatch): async def test_switch_setup_without_discovery_info(hass, config, numato_fixture): """Test handling of empty discovery_info.""" numato_fixture.discover() - await discovery.async_load_platform(hass, "switch", "numato", None, config) + await discovery.async_load_platform(hass, Platform.SWITCH, "numato", None, config) for entity_id in MOCKUP_ENTITY_IDS: assert entity_id not in hass.states.async_entity_ids() await hass.async_block_till_done() # wait for numato platform to be loaded diff --git a/tests/helpers/test_discovery.py b/tests/helpers/test_discovery.py index d0d8580d69d..47255ea6b1f 100644 --- a/tests/helpers/test_discovery.py +++ b/tests/helpers/test_discovery.py @@ -2,6 +2,7 @@ from unittest.mock import patch from homeassistant import setup +from homeassistant.const import Platform from homeassistant.core import callback from homeassistant.helpers import discovery from homeassistant.helpers.dispatcher import dispatcher_send @@ -129,7 +130,9 @@ class TestHelpersDiscovery: def component_setup(hass, config): """Set up mock component.""" - discovery.load_platform(hass, "switch", "test_circular", "disc", config) + discovery.load_platform( + hass, Platform.SWITCH, "test_circular", {"key": "value"}, config + ) component_calls.append(1) return True