Sabnzbd config flow (#68138)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
parent
b1a6521abd
commit
3f5027834b
18 changed files with 463 additions and 332 deletions
|
@ -16,18 +16,12 @@ from tests.common import async_fire_time_changed, mock_coro
|
|||
SERVICE = "yamaha"
|
||||
SERVICE_COMPONENT = "media_player"
|
||||
|
||||
# sabnzbd is the last no platform integration to be migrated
|
||||
# drop these tests once it is migrated
|
||||
SERVICE_NO_PLATFORM = "sabnzbd"
|
||||
SERVICE_NO_PLATFORM_COMPONENT = "sabnzbd"
|
||||
SERVICE_INFO = {"key": "value"} # Can be anything
|
||||
|
||||
UNKNOWN_SERVICE = "this_service_will_never_be_supported"
|
||||
|
||||
BASE_CONFIG = {discovery.DOMAIN: {"ignore": [], "enable": []}}
|
||||
|
||||
IGNORE_CONFIG = {discovery.DOMAIN: {"ignore": [SERVICE_NO_PLATFORM]}}
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def netdisco_mock():
|
||||
|
@ -88,63 +82,6 @@ async def test_load_platform(hass):
|
|||
)
|
||||
|
||||
|
||||
async def test_load_component(hass):
|
||||
"""Test load a component."""
|
||||
|
||||
def discover(netdisco, zeroconf_instance, suppress_mdns_types):
|
||||
"""Fake discovery."""
|
||||
return [(SERVICE_NO_PLATFORM, SERVICE_INFO)]
|
||||
|
||||
mock_discover, mock_platform = await mock_discovery(hass, discover)
|
||||
|
||||
assert mock_discover.called
|
||||
assert not mock_platform.called
|
||||
mock_discover.assert_called_with(
|
||||
hass,
|
||||
SERVICE_NO_PLATFORM,
|
||||
SERVICE_INFO,
|
||||
SERVICE_NO_PLATFORM_COMPONENT,
|
||||
BASE_CONFIG,
|
||||
)
|
||||
|
||||
|
||||
async def test_ignore_service(hass):
|
||||
"""Test ignore service."""
|
||||
|
||||
def discover(netdisco, zeroconf_instance, suppress_mdns_types):
|
||||
"""Fake discovery."""
|
||||
return [(SERVICE_NO_PLATFORM, SERVICE_INFO)]
|
||||
|
||||
mock_discover, mock_platform = await mock_discovery(hass, discover, IGNORE_CONFIG)
|
||||
|
||||
assert not mock_discover.called
|
||||
assert not mock_platform.called
|
||||
|
||||
|
||||
async def test_discover_duplicates(hass):
|
||||
"""Test load a component."""
|
||||
|
||||
def discover(netdisco, zeroconf_instance, suppress_mdns_types):
|
||||
"""Fake discovery."""
|
||||
return [
|
||||
(SERVICE_NO_PLATFORM, SERVICE_INFO),
|
||||
(SERVICE_NO_PLATFORM, SERVICE_INFO),
|
||||
]
|
||||
|
||||
mock_discover, mock_platform = await mock_discovery(hass, discover)
|
||||
|
||||
assert mock_discover.called
|
||||
assert mock_discover.call_count == 1
|
||||
assert not mock_platform.called
|
||||
mock_discover.assert_called_with(
|
||||
hass,
|
||||
SERVICE_NO_PLATFORM,
|
||||
SERVICE_INFO,
|
||||
SERVICE_NO_PLATFORM_COMPONENT,
|
||||
BASE_CONFIG,
|
||||
)
|
||||
|
||||
|
||||
async def test_discover_config_flow(hass):
|
||||
"""Test discovery triggering a config flow."""
|
||||
discovery_info = {"hello": "world"}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue