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 <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2022-01-12 15:07:30 +01:00 committed by GitHub
parent 0fadce751f
commit b71a22557d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 6 deletions

View file

@ -1,4 +1,5 @@
"""Tests for the numato binary_sensor platform.""" """Tests for the numato binary_sensor platform."""
from homeassistant.const import Platform
from homeassistant.helpers import discovery from homeassistant.helpers import discovery
from homeassistant.setup import async_setup_component 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): async def test_binary_sensor_setup_without_discovery_info(hass, config, numato_fixture):
"""Test handling of empty discovery_info.""" """Test handling of empty discovery_info."""
numato_fixture.discover() 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: for entity_id in MOCKUP_ENTITY_IDS:
assert entity_id not in hass.states.async_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 await hass.async_block_till_done() # wait for numato platform to be loaded

View file

@ -1,5 +1,5 @@
"""Tests for the numato sensor platform.""" """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.helpers import discovery
from homeassistant.setup import async_setup_component 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): async def test_sensor_setup_without_discovery_info(hass, config, numato_fixture):
"""Test handling of empty discovery_info.""" """Test handling of empty discovery_info."""
numato_fixture.discover() 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: for entity_id in MOCKUP_ENTITY_IDS:
assert entity_id not in hass.states.async_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 await hass.async_block_till_done() # wait for numato platform to be loaded

View file

@ -1,6 +1,11 @@
"""Tests for the numato switch platform.""" """Tests for the numato switch platform."""
from homeassistant.components import switch 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.helpers import discovery
from homeassistant.setup import async_setup_component 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): async def test_switch_setup_without_discovery_info(hass, config, numato_fixture):
"""Test handling of empty discovery_info.""" """Test handling of empty discovery_info."""
numato_fixture.discover() 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: for entity_id in MOCKUP_ENTITY_IDS:
assert entity_id not in hass.states.async_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 await hass.async_block_till_done() # wait for numato platform to be loaded

View file

@ -2,6 +2,7 @@
from unittest.mock import patch from unittest.mock import patch
from homeassistant import setup from homeassistant import setup
from homeassistant.const import Platform
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.helpers import discovery from homeassistant.helpers import discovery
from homeassistant.helpers.dispatcher import dispatcher_send from homeassistant.helpers.dispatcher import dispatcher_send
@ -129,7 +130,9 @@ class TestHelpersDiscovery:
def component_setup(hass, config): def component_setup(hass, config):
"""Set up mock component.""" """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) component_calls.append(1)
return True return True